Skip to content

Commit

Permalink
Merge branch 'main' into fix-missing-ts-files
Browse files Browse the repository at this point in the history
  • Loading branch information
benjervis authored Dec 13, 2024
2 parents 7b5b7fa + 3054dda commit a1647ca
Show file tree
Hide file tree
Showing 21 changed files with 124 additions and 34 deletions.
41 changes: 25 additions & 16 deletions packages/core/integration-tests/test/image.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import assert from 'assert';
import {extname, join} from 'path';

Expand Down Expand Up @@ -103,14 +104,15 @@ describe('images', function () {
},
});

let {filePath} = b
let jpgBundle = b
.getBundles()
.find((b) => ['jpg', 'jpeg'].includes(b.type));
if (!jpgBundle) return assert.fail();

let input = await inputFS.readFile(img);
let inputRaw = await sharp(input).toFormat('raw').toBuffer();

let output = await outputFS.readFile(filePath);
let output = await outputFS.readFile(jpgBundle.filePath);
let outputRaw = await sharp(output).toFormat('raw').toBuffer();

assert(outputRaw.equals(inputRaw));
Expand All @@ -126,17 +128,18 @@ describe('images', function () {
logLevel: 'verbose',
});

let {filePath} = b
let jpgBundle = b
.getBundles()
.find((b) => ['jpg', 'jpeg'].includes(b.type));
if (!jpgBundle) return assert.fail();

// let input = await inputFS.readFile(img);
// let inputRaw = await sharp(input)
// .toFormat('raw')
// .toBuffer();

// Check validity of image
let output = await outputFS.readFile(filePath);
let output = await outputFS.readFile(jpgBundle.filePath);
await sharp(output).toFormat('raw').toBuffer();

// assert(outputRaw.equals(inputRaw));
Expand All @@ -151,12 +154,13 @@ describe('images', function () {
},
});

let {filePath} = b.getBundles().find((b) => b.type === 'png');
let pngBundle = b.getBundles().find((b) => b.type === 'png');
if (!pngBundle) return assert.fail();

let input = await inputFS.readFile(img);
let inputRaw = await sharp(input).toFormat('raw').toBuffer();

let output = await outputFS.readFile(filePath);
let output = await outputFS.readFile(pngBundle.filePath);
let outputRaw = await sharp(output).toFormat('raw').toBuffer();

assert(outputRaw.equals(inputRaw));
Expand All @@ -166,11 +170,12 @@ describe('images', function () {
it.v2('retain EXIF data when resized with a query string', async () => {
let b = await bundle(join(__dirname, '/integration/image-exif/resized.js'));

let {filePath} = b
let jpgBundle = b
.getBundles()
.find((b) => ['jpg', 'jpeg'].includes(b.type));
if (!jpgBundle) return assert.fail();

let buffer = await outputFS.readFile(filePath);
let buffer = await outputFS.readFile(jpgBundle.filePath);
let image = await sharp(buffer).metadata();

let {exif} = exifReader(image.exif);
Expand All @@ -191,11 +196,12 @@ describe('images', function () {
},
);

let {filePath} = b
let jpgBundle = b
.getBundles()
.find((b) => ['jpg', 'jpeg'].includes(b.type));
if (!jpgBundle) return assert.fail();

let buffer = await outputFS.readFile(filePath);
let buffer = await outputFS.readFile(jpgBundle.filePath);
let image = await sharp(buffer).metadata();

assert.strictEqual(image.exif, undefined);
Expand All @@ -204,11 +210,12 @@ describe('images', function () {
it.v2('uses the EXIF orientation tag when resizing', async () => {
let b = await bundle(join(__dirname, '/integration/image-exif/resized.js'));

let {filePath} = b
let jpgBundle = b
.getBundles()
.find((b) => ['jpg', 'jpeg'].includes(b.type));
if (!jpgBundle) return assert.fail();

let buffer = await outputFS.readFile(filePath);
let buffer = await outputFS.readFile(jpgBundle.filePath);
let image = await sharp(buffer).metadata();

assert.strictEqual(image.orientation, 1);
Expand All @@ -226,9 +233,10 @@ describe('images', function () {
},
);

let {filePath} = b.getBundles().find((b) => b.type === 'jpeg');
let jpgBundle = b.getBundles().find((b) => b.type === 'jpeg');
if (!jpgBundle) return assert.fail();

let buffer = await outputFS.readFile(filePath);
let buffer = await outputFS.readFile(jpgBundle.filePath);
let image = await sharp(buffer).metadata();
let originalSize = 549196;

Expand All @@ -247,9 +255,10 @@ describe('images', function () {
},
);

let {filePath} = b.getBundles().find((b) => b.type === 'png');
let pngBundle = b.getBundles().find((b) => b.type === 'png');
if (!pngBundle) return assert.fail();

let buffer = await outputFS.readFile(filePath);
let buffer = await outputFS.readFile(pngBundle.filePath);
let image = await sharp(buffer).metadata();
let originalSize = 84435;

Expand Down
1 change: 1 addition & 0 deletions packages/core/integration-tests/test/kotlin.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import assert from 'assert';
import {
assertBundleTree,
Expand Down
1 change: 1 addition & 0 deletions packages/core/integration-tests/test/less.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import assert from 'assert';
import {join} from 'path';
import {
Expand Down
1 change: 1 addition & 0 deletions packages/core/integration-tests/test/markdown.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import assert from 'assert';
import path from 'path';
import {
Expand Down
15 changes: 15 additions & 0 deletions packages/core/integration-tests/test/monorepos.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import assert from 'assert';
import path from 'path';
import {
Expand Down Expand Up @@ -606,6 +607,7 @@ describe.v2('monorepos', function () {

subscription = await b.watch();
let evt = await getNextBuild(b);
if (!evt.bundleGraph) return assert.fail();

assertBundles(evt.bundleGraph, [
{
Expand All @@ -624,6 +626,8 @@ describe.v2('monorepos', function () {
);

evt = await getNextBuild(b);
if (!evt.bundleGraph) return assert.fail();

assertBundles(evt.bundleGraph, [
{
name: 'pkg-a.cjs.js',
Expand Down Expand Up @@ -668,6 +672,7 @@ describe.v2('monorepos', function () {

subscription = await b.watch();
let evt = await getNextBuild(b);
if (!evt.bundleGraph) return assert.fail();

assertBundles(evt.bundleGraph, [
{
Expand All @@ -689,6 +694,8 @@ describe.v2('monorepos', function () {

evt = await getNextBuild(b);
assert(evt.type === 'buildSuccess');
if (!evt.bundleGraph) return assert.fail();

assertBundles(evt.bundleGraph, [
{
name: 'pkg-a.cjs.js',
Expand Down Expand Up @@ -729,6 +736,7 @@ describe.v2('monorepos', function () {

subscription = await b.watch();
let evt = await getNextBuild(b);
if (!evt.bundleGraph) return assert.fail();

assertBundles(evt.bundleGraph, [
{
Expand All @@ -753,6 +761,8 @@ describe.v2('monorepos', function () {
);

evt = await getNextBuild(b);
if (!evt.bundleGraph) return assert.fail();

assertBundles(evt.bundleGraph, [
{
name: 'alt.js',
Expand Down Expand Up @@ -1008,6 +1018,7 @@ describe.v2('monorepos', function () {

for (let bundle of b.getBundles()) {
let res = await runBundle(b, bundle);
// $FlowFixMe res is an unknown type
assert.equal(res.default, bundle.name[0]);
}
});
Expand Down Expand Up @@ -1064,6 +1075,7 @@ describe.v2('monorepos', function () {

for (let bundle of b.getBundles()) {
let res = await runBundle(b, bundle);
// $FlowFixMe res is an unknown type
assert.equal(res.default, bundle.name[0]);
}
});
Expand Down Expand Up @@ -1097,6 +1109,7 @@ describe.v2('monorepos', function () {

subscription = await b.watch();
let evt = await getNextBuild(b);
if (!evt.bundleGraph) return assert.fail();

assertBundles(evt.bundleGraph, [
{
Expand All @@ -1110,6 +1123,8 @@ describe.v2('monorepos', function () {
`;

evt = await getNextBuild(b);
if (!evt.bundleGraph) return assert.fail();

assertBundles(evt.bundleGraph, [
{
assets: ['a.js'],
Expand Down
1 change: 1 addition & 0 deletions packages/core/integration-tests/test/parser.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import assert from 'assert';
import path from 'path';
import {
Expand Down
16 changes: 14 additions & 2 deletions packages/core/integration-tests/test/pnp.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import assert from 'assert';
import Module from 'module';
import path from 'path';
Expand All @@ -18,16 +19,21 @@ describe.v2('pnp', function () {
let dir = path.join(__dirname, 'integration/pnp-require');

let origPnpVersion = process.versions.pnp;
process.versions.pnp = 42;
process.versions.pnp = '42';

// $FlowFixMe patching
let origModuleResolveFilename = Module._resolveFilename;
// $FlowFixMe patching
Module.findPnpApi = () => require(path.join(dir, '.pnp.js'));
// $FlowFixMe patching
Module._resolveFilename = (name, ...args) =>
name === 'pnpapi'
? path.join(dir, '.pnp.js')
: origModuleResolveFilename(name, ...args);

// $FlowFixMe patching
let origReadFileSync = inputFS.readFileSync;
// $FlowFixMe patching
inputFS.readFileSync = (p, ...args) => {
return origReadFileSync.call(inputFS, p.replace(ZIPFS, ''), ...args);
};
Expand Down Expand Up @@ -56,7 +62,9 @@ describe.v2('pnp', function () {
assert.equal(output(), 3);
} finally {
process.versions.pnp = origPnpVersion;
// $FlowFixMe patching
Module._resolveFilename = origModuleResolveFilename;
// $FlowFixMe patching
inputFS.readFileSync = origReadFileSync;
inputFS.statSync = origStatSync;
inputFS.realpathSync = origRealpathSync;
Expand All @@ -67,10 +75,13 @@ describe.v2('pnp', function () {
let dir = path.join(__dirname, 'integration/pnp-builtin');

let origPnpVersion = process.versions.pnp;
process.versions.pnp = 42;
process.versions.pnp = '42';

// $FlowFixMe patching
let origModuleResolveFilename = Module._resolveFilename;
// $FlowFixMe patching
Module.findPnpApi = () => require(path.join(dir, '.pnp.js'));
// $FlowFixMe patching
Module._resolveFilename = (name, ...args) =>
name === 'pnpapi'
? path.join(dir, '.pnp.js')
Expand All @@ -90,6 +101,7 @@ describe.v2('pnp', function () {
assert.equal(output(), 3);
} finally {
process.versions.pnp = origPnpVersion;
// $FlowFixMe patching
Module._resolveFilename = origModuleResolveFilename;
}
});
Expand Down
5 changes: 5 additions & 0 deletions packages/core/integration-tests/test/postcss.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import assert from 'assert';
import path from 'path';
import {
Expand Down Expand Up @@ -234,6 +235,7 @@ describe.v2('postcss', () => {
let subscription = await b.watch();
let buildEvent = await getNextBuild(b);
assert.equal(buildEvent.type, 'buildSuccess');
if (!buildEvent.bundleGraph) return assert.fail();

let contents = await outputFS.readFile(
buildEvent.bundleGraph.getBundles()[0].filePath,
Expand All @@ -253,6 +255,7 @@ describe.v2('postcss', () => {

buildEvent = await getNextBuild(b);
assert.equal(buildEvent.type, 'buildSuccess');
if (!buildEvent.bundleGraph) return assert.fail();

contents = await outputFS.readFile(
buildEvent.bundleGraph.getBundles()[0].filePath,
Expand All @@ -272,6 +275,7 @@ describe.v2('postcss', () => {

buildEvent = await getNextBuild(b);
assert.equal(buildEvent.type, 'buildSuccess');
if (!buildEvent.bundleGraph) return assert.fail();

contents = await outputFS.readFile(
buildEvent.bundleGraph.getBundles()[0].filePath,
Expand All @@ -288,6 +292,7 @@ describe.v2('postcss', () => {

buildEvent = await getNextBuild(b);
assert.equal(buildEvent.type, 'buildSuccess');
if (!buildEvent.bundleGraph) return assert.fail();

contents = await outputFS.readFile(
buildEvent.bundleGraph.getBundles()[0].filePath,
Expand Down
3 changes: 3 additions & 0 deletions packages/core/integration-tests/test/posthtml.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import assert from 'assert';
import {
bundle,
Expand Down Expand Up @@ -83,6 +84,7 @@ describe.v2('posthtml', function () {
const b = await bundle(
path.join(__dirname, '/integration/posthtml-assets/index.html'),
);
// $FlowFixMe assets missing
const asset = b.assets.values().next().value;
const other = path.join(
__dirname,
Expand All @@ -96,6 +98,7 @@ describe.v2('posthtml', function () {
const b = await bundle(
path.join(__dirname, '/integration/posthtml-plugin-deps/index.html'),
);
// $FlowFixMe assets missing
const asset = b.assets.values().next().value;
const other = path.join(
__dirname,
Expand Down
3 changes: 3 additions & 0 deletions packages/core/integration-tests/test/reason.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import assert from 'assert';
import path from 'path';
import {bundle, run} from '@atlaspack/test-utils';
Expand All @@ -6,7 +7,9 @@ describe.skip('reason', function () {
it('should produce a bundle', async function () {
let b = await bundle(path.join(__dirname, '/integration/reason/index.js'));

// $FlowFixMe missing assets
assert.equal(b.assets.size, 2);
// $FlowFixMe missing assets
assert.equal(b.childBundles.size, 1);

let output = await run(b);
Expand Down
1 change: 1 addition & 0 deletions packages/core/integration-tests/test/symbol-propagation.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import assert from 'assert';
import path from 'path';
import {
Expand Down
9 changes: 5 additions & 4 deletions packages/core/integration-tests/test/tailwind-tests.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow
import assert from 'assert';
import path from 'path';
import {bundle, describe, it, outputFS} from '@atlaspack/test-utils';
Expand All @@ -7,10 +8,10 @@ describe.v2('tailwind', function () {
let fixture = path.join(__dirname, '/integration/tailwind-scss');
let b = await bundle(path.join(fixture, 'index.html'));

let css = await outputFS.readFile(
b.getBundles().find((b) => b.type === 'css').filePath,
'utf8',
);
let cssBundle = b.getBundles().find((b) => b.type === 'css');
if (!cssBundle) return assert.fail();

let css = await outputFS.readFile(cssBundle.filePath, 'utf8');
assert(css.includes('.p-2'));
assert(!css.includes('.m-2'));
});
Expand Down
Loading

0 comments on commit a1647ca

Please sign in to comment.