import type { IWorker, MeasurementStatistics } from './worker'
export const checkFilePath = (filePath: string): void => {
- if (
- filePath == null ||
- typeof filePath !== 'string' ||
- (typeof filePath === 'string' && filePath.trim().length === 0)
- ) {
- throw new Error('Please specify a file with a worker implementation')
- }
if (!existsSync(filePath)) {
throw new Error(`Cannot find the worker file '${filePath}'`)
}
})
it('Verify that filePath is checked', () => {
- const expectedError = new Error(
- 'Please specify a file with a worker implementation'
- )
expect(() => new FixedThreadPool(numberOfWorkers)).toThrowError(
- expectedError
- )
- expect(() => new FixedThreadPool(numberOfWorkers, '')).toThrowError(
- expectedError
- )
- expect(() => new FixedThreadPool(numberOfWorkers, 0)).toThrowError(
- expectedError
- )
- expect(() => new FixedThreadPool(numberOfWorkers, true)).toThrowError(
- expectedError
+ new Error("Cannot find the worker file 'undefined'")
)
expect(
() => new FixedThreadPool(numberOfWorkers, './dummyWorker.ts')
it('Validation of inputs test', () => {
expect(() => new DynamicClusterPool(min)).toThrowError(
- 'Please specify a file with a worker implementation'
+ "Cannot find the worker file 'undefined'"
)
})
it('Validation of inputs test', () => {
expect(() => new DynamicThreadPool(min)).toThrowError(
- 'Please specify a file with a worker implementation'
+ "Cannot find the worker file 'undefined'"
)
})