This repository has been archived by the owner on May 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(externals): sanatize external name
- Loading branch information
1 parent
3370f3e
commit a8be702
Showing
2 changed files
with
23 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,7 +91,28 @@ describe('Esbuild plugin timeBuild', () => { | |
expect(fs.promises.writeFile).toHaveBeenCalledTimes(1); | ||
expect(fs.promises.writeFile).toHaveBeenCalledWith('.esbuild-stats.mockBundleName.json', '{"file.js":{},"durationMs":3}'); | ||
}); | ||
it('should sanatize bundlename replacing `/` with `-`', async () => { | ||
const plugin = timeBuild({ bundleName: '@scoped/mockBundleName', watch: false }); | ||
const hooks = runSetupAndGetLifeHooks(plugin); | ||
const onStart = hooks.onStart[0]; | ||
const onEnd = hooks.onEnd[0]; | ||
|
||
process.hrtime.bigint.mockImplementation(() => BigInt(1000000)); // 1ms in nanoseconds | ||
onStart(); // call onStart to load in the start time | ||
jest.clearAllMocks(); | ||
|
||
process.hrtime.bigint.mockImplementation(() => BigInt(4000000)); // 4ms in nanoseconds | ||
|
||
await onEnd({ | ||
metafile: { | ||
outputs: { | ||
'file.js': {}, | ||
}, | ||
}, | ||
}); | ||
|
||
expect(fs.promises.writeFile).toHaveBeenCalledWith('[email protected]', '{"file.js":{},"durationMs":3}'); | ||
}); | ||
it('should not log in watch mode', async () => { | ||
const plugin = timeBuild({ bundleName: 'mockBundleName', watch: true }); | ||
const hooks = runSetupAndGetLifeHooks(plugin); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters