Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Nov 1, 2021
1 parent 3cdf8dc commit 674cf44
Showing 1 changed file with 35 additions and 19 deletions.
54 changes: 35 additions & 19 deletions packages/core/integration-tests/test/resolver.js
Expand Up @@ -2,8 +2,8 @@ import assert from 'assert';
import path from 'path';
import {bundle, run, ncp, overlayFS, outputFS} from '@parcel/test-utils';

describe('resolver', function() {
it('should support resolving tilde in monorepo packages', async function() {
describe('resolver', function () {
it('should support resolving tilde in monorepo packages', async function () {
let b = await bundle(
path.join(
__dirname,
Expand All @@ -15,7 +15,7 @@ describe('resolver', function() {
assert.strictEqual(output.default, 1234);
});

it('should support node: prefix for node_modules', async function() {
it('should support node: prefix for node_modules', async function () {
let b = await bundle(
path.join(__dirname, '/integration/resolve-node-prefix/src/index.js'),
);
Expand All @@ -27,7 +27,7 @@ describe('resolver', function() {
);
});

it('should correctly resolve tilde in node_modules', async function() {
it('should correctly resolve tilde in node_modules', async function () {
let b = await bundle(
path.join(__dirname, '/integration/resolve-tilde-nodemodules/index.js'),
);
Expand All @@ -36,7 +36,7 @@ describe('resolver', function() {
assert.strictEqual(output.default, 1234);
});

it('should fall back to index.js if the resolved `main` file does not exist', async function() {
it('should fall back to index.js if the resolved `main` file does not exist', async function () {
let b = await bundle(
path.join(
__dirname,
Expand All @@ -48,7 +48,7 @@ describe('resolver', function() {
assert.strictEqual(output.default, 42);
});

it('should fall back to index.js if there is no `main` field at all', async function() {
it('should fall back to index.js if there is no `main` field at all', async function () {
let b = await bundle(
path.join(__dirname, '/integration/resolve-index-fallback/no-entry.js'),
);
Expand All @@ -57,7 +57,7 @@ describe('resolver', function() {
assert.strictEqual(output.default, 42);
});

it('should print a diagnostic when a configured target field will overwrite an entry', async function() {
it('should print a diagnostic when a configured target field will overwrite an entry', async function () {
let errorThrows = 0;
const overwriteDirs = ['browser', 'app', 'main', 'module'];
for (const currDir of overwriteDirs) {
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('resolver', function() {
assert.deepEqual(errorThrows, overwriteDirs.length);
});

it('should throw an error on Webpack loader imports', async function() {
it('should throw an error on Webpack loader imports', async function () {
let didThrow = false;
try {
await bundle(
Expand All @@ -109,7 +109,7 @@ describe('resolver', function() {
assert(didThrow);
});

it('should throw an error with codeframe on invalid js import', async function() {
it('should throw an error with codeframe on invalid js import', async function () {
let didThrow = false;
try {
await bundle(
Expand All @@ -133,7 +133,7 @@ describe('resolver', function() {
assert(didThrow);
});

it('should throw an error with codeframe on invalid css import', async function() {
it('should throw an error with codeframe on invalid css import', async function () {
let didThrow = false;
try {
await bundle(
Expand All @@ -157,7 +157,7 @@ describe('resolver', function() {
assert(didThrow);
});

it('Should return codeframe with hints when package.json is invalid', async function() {
it('Should return codeframe with hints when package.json is invalid', async function () {
let didThrow = false;
try {
await bundle(
Expand Down Expand Up @@ -187,7 +187,7 @@ describe('resolver', function() {
assert(didThrow);
});

it('Should suggest alternative filenames for relative imports', async function() {
it('Should suggest alternative filenames for relative imports', async function () {
let threw = 0;

try {
Expand Down Expand Up @@ -244,7 +244,7 @@ describe('resolver', function() {
assert.equal(threw, 3);
});

it('Should suggest alternative modules for module imports', async function() {
it('Should suggest alternative modules for module imports', async function () {
let threw = false;

try {
Expand All @@ -268,7 +268,7 @@ describe('resolver', function() {
assert(threw);
});

it('should resolve packages to packages through the alias field', async function() {
it('should resolve packages to packages through the alias field', async function () {
let b = await bundle(
path.join(__dirname, '/integration/alias/package-to-package.js'),
);
Expand All @@ -277,7 +277,7 @@ describe('resolver', function() {
assert.strictEqual(output.default, 3);
});

it('should resolve packages to local files through the alias field', async function() {
it('should resolve packages to local files through the alias field', async function () {
let b = await bundle(
path.join(__dirname, '/integration/alias/package-to-local.js'),
);
Expand All @@ -286,7 +286,7 @@ describe('resolver', function() {
assert.strictEqual(output.default, 'bar');
});

it('should exclude local files using the alias field', async function() {
it('should exclude local files using the alias field', async function () {
let b = await bundle(
path.join(__dirname, '/integration/alias/exclude-local.js'),
);
Expand All @@ -295,7 +295,7 @@ describe('resolver', function() {
assert.deepEqual(output.default, {});
});

it('should exclude packages using the alias field', async function() {
it('should exclude packages using the alias field', async function () {
let b = await bundle(
path.join(__dirname, '/integration/alias/exclude-package.js'),
);
Expand All @@ -304,7 +304,7 @@ describe('resolver', function() {
assert.deepEqual(output.default, {});
});

it('should support symlinked node_modules structure', async function() {
it('should support symlinked node_modules structure', async function () {
const rootDir = path.join(
__dirname,
'integration/resolve-symlinked-node_modules-structure',
Expand Down Expand Up @@ -346,7 +346,7 @@ describe('resolver', function() {
assert.strictEqual(output.default, 42);
});

it('should support symlinked monorepos structure', async function() {
it('should support symlinked monorepos structure', async function () {
const rootDir = path.join(
__dirname,
'integration/resolve-symlinked-monorepos',
Expand Down Expand Up @@ -382,4 +382,20 @@ describe('resolver', function() {
let output = await run(b);
assert.strictEqual(output.default, 2);
});

it('should support very long dependency specifiers', async function () {
this.timeout(8000);

let inputDir = path.join(__dirname, 'input');

await outputFS.mkdirp(inputDir);
await outputFS.writeFile(
path.join(inputDir, 'index.html'),
`<img src="data:image/jpeg;base64,/9j/${'A'.repeat(200000)}">`,
);

await bundle(path.join(inputDir, 'index.html'), {
inputFS: overlayFS,
});
});
});

0 comments on commit 674cf44

Please sign in to comment.