Skip to content

Commit

Permalink
chore: move test into describe block
Browse files Browse the repository at this point in the history
  • Loading branch information
unional committed Jan 3, 2023
1 parent ef1d106 commit 3de5feb
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions packages/jest-resolve/src/__tests__/resolve.test.ts
Expand Up @@ -356,38 +356,40 @@ describe('findNodeModule', () => {
);
});

test('supports array pattern - resolve to first found', () => {
const result = Resolver.findNodeModule('#array-import', {
basedir: path.resolve(importsRoot, './array-import/index.cjs'),
conditions: ['import'],
describe('array pattern', () => {
test('supports array pattern - resolve to first found', () => {
const result = Resolver.findNodeModule('#array-import', {
basedir: path.resolve(importsRoot, './array-import/index.cjs'),
conditions: ['import'],
});

expect(result).toEqual(
path.resolve(importsRoot, './array-import/node.mjs'),
);
});

expect(result).toEqual(
path.resolve(importsRoot, './array-import/node.mjs'),
);
});
test('supports array pattern - ignore not exist internal file', () => {
const result = Resolver.findNodeModule('#array-import', {
basedir: path.resolve(importsRoot, './array-import/index.cjs'),
conditions: ['browser'],
});

test('supports array pattern - ignore not exist internal file', () => {
const result = Resolver.findNodeModule('#array-import', {
basedir: path.resolve(importsRoot, './array-import/index.cjs'),
conditions: ['browser'],
expect(result).toEqual(
path.resolve(importsRoot, './array-import/browser.cjs'),
);
});

expect(result).toEqual(
path.resolve(importsRoot, './array-import/browser.cjs'),
);
});
test('supports array pattern - ignore not exist external module', () => {
// this is for optional dependency
const result = Resolver.findNodeModule('#array-import', {
basedir: path.resolve(importsRoot, './array-import/index.cjs'),
conditions: ['require'],
});

test('supports array pattern - ignore not exist external module', () => {
// this is for optional dependency
const result = Resolver.findNodeModule('#array-import', {
basedir: path.resolve(importsRoot, './array-import/index.cjs'),
conditions: ['require'],
expect(result).toEqual(
path.resolve(importsRoot, './array-import/node.cjs'),
);
});

expect(result).toEqual(
path.resolve(importsRoot, './array-import/node.cjs'),
);
});

test('fails for non-existent mapping', () => {
Expand Down

0 comments on commit 3de5feb

Please sign in to comment.