Skip to content

Commit

Permalink
add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
mizdra committed Nov 4, 2024
1 parent b30712e commit ef3040e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/happy-css-modules/src/emitter/dts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ test('getDtsFilePath', () => {
expect(getDtsFilePath('/app/src/dir/1.scss', false, undefined)).toBe('/app/src/dir/1.scss.d.ts');
expect(getDtsFilePath('/app/src/dir/1.css', true, undefined)).toBe('/app/src/dir/1.d.css.ts');
expect(getDtsFilePath('/app/src/dir/1.scss', true, undefined)).toBe('/app/src/dir/1.d.scss.ts');
expect(getDtsFilePath('/app/src/dir/1.css', false, { cwd: '/app', outDir: 'dist' })).toBe(
'/app/dist/src/dir/1.css.d.ts',
);
});

describe('generateDtsContentWithSourceMap', () => {
Expand Down
9 changes: 9 additions & 0 deletions packages/happy-css-modules/src/emitter/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,13 @@ describe('emitGeneratedFiles', () => {
expect(mtimeForDts1).not.toEqual(mtimeForDts3); // not skipped
expect(mtimeForSourceMap1).not.toEqual(mtimeForSourceMap3); // not skipped
});
test('changes output directory by outDir', async () => {
await emitGeneratedFiles({ ...defaultArgs, outDir: 'dist' });
expect(await exists(getFixturePath('/test/dist/1.css.d.ts'))).toBeTruthy();
// A link to the source map is not embedded.
expect(await readFile(getFixturePath('/test/dist/1.css.d.ts'), 'utf8')).toEqual(
expect.not.stringContaining('//# sourceMappingURL=1.css.d.ts.map'),
);
expect(await exists(getFixturePath('/test/dist/1.css.d.ts.map'))).toBeTruthy();
});
});

0 comments on commit ef3040e

Please sign in to comment.