Skip to content

Commit

Permalink
Merge pull request #20 from Karibash/feature/improve-inject-test-cove…
Browse files Browse the repository at this point in the history
…rage

Add test code for specifying arrays in the path
  • Loading branch information
Karibash authored Dec 26, 2022
2 parents a4d462e + 1cbbff5 commit 3142107
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/inject/test/fixtures/1/2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const two = '2';
20 changes: 16 additions & 4 deletions packages/inject/test/internals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('getFilePaths', () => {
expect.stringMatching(/fixtures\/a\/b.ts$/),
expect.stringMatching(/fixtures\/a\/b\/abc.ts$/),
expect.stringMatching(/fixtures\/a\/b\/c.ts$/),
expect.stringMatching(/fixtures\/1\/2.ts$/),
];
expect(paths).toEqual(expect.arrayContaining(expected));
});
Expand Down Expand Up @@ -59,7 +60,18 @@ describe('getInjectables', () => {
path: fixturesDirectory,
});

expect(injectables).toEqual(['ab', 'b', 'abc', 'c']);
expect(injectables).toEqual(['2', 'ab', 'b', 'abc', 'c']);
});

it('multiple path', async () => {
const injectables = await getInjectables({
path: [
path.resolve(fixturesDirectory, '1'),
path.resolve(fixturesDirectory, 'a'),
],
});

expect(injectables).toEqual(['2', 'ab', 'b', 'abc', 'c']);
});

it('with includeFileNames', async () => {
Expand All @@ -77,7 +89,7 @@ describe('getInjectables', () => {
excludeFileNames: ['ab'],
});

expect(injectables).toEqual(['b', 'abc', 'c']);
expect(injectables).toEqual(['2', 'b', 'abc', 'c']);
});

it('with includeFileExtensions', async () => {
Expand Down Expand Up @@ -113,7 +125,7 @@ describe('getInjectables', () => {
excludeExportNames: ['ab'],
});

expect(injectables).toEqual(['b', 'abc', 'c']);
expect(injectables).toEqual(['2', 'b', 'abc', 'c']);
});

it('with injects', async () => {
Expand All @@ -122,6 +134,6 @@ describe('getInjectables', () => {
injects: ['inject'],
});

expect(injectables).toEqual(['ab', 'b', 'abc', 'c', 'inject']);
expect(injectables).toEqual(['2', 'ab', 'b', 'abc', 'c', 'inject']);
});
});

0 comments on commit 3142107

Please sign in to comment.