Skip to content

Commit

Permalink
feat(transformer): extract repeated error in a constant, fixed error …
Browse files Browse the repository at this point in the history
…wording
  • Loading branch information
Pmyl committed Jun 27, 2020
1 parent 16506e5 commit dd73b57
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
6 changes: 2 additions & 4 deletions src/create-mock-list.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { NoTransformerError } from './errors/no-transformer.error';
import { DeepPartial } from './partial/deepPartial';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function createMockList<T extends object>(quantity: number, iterator?: (index: number) => DeepPartial<T>): T[] {
throw new Error(`
ts-auto-mock is not been configured as a transformer. Please follow the instructions in https://typescript-tdd.github.io/ts-auto-mock/installation
If help is required you can find us on https://typescript-tdd.github.io
`);
throw new Error(NoTransformerError);
}
6 changes: 2 additions & 4 deletions src/create-mock.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { NoTransformerError } from './errors/no-transformer.error';
import { DeepPartial } from './partial/deepPartial';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function createMock<T extends object>(values?: DeepPartial<T>): T {
throw new Error(`
ts-auto-mock is not been configured as a transformer. Please follow the instructions in https://typescript-tdd.github.io/ts-auto-mock/installation
If help is required you can find us on https://typescript-tdd.github.io
`);
throw new Error(NoTransformerError);
}
4 changes: 4 additions & 0 deletions src/errors/no-transformer.error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const NoTransformerError: string = `
hey, it looks like ts-auto-mock is not configured correctly! You can find the instructions here https://typescript-tdd.github.io/ts-auto-mock/installation.
If you need further assistance feel free to drop a message on slack. (link at the bottom of https://typescript-tdd.github.io/ts-auto-mock)
`;
7 changes: 3 additions & 4 deletions src/register-mock.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { NoTransformerError } from './errors/no-transformer.error';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function registerMock<T extends object>(factory: () => T): void {
throw new Error(`
ts-auto-mock is not been configured as a transformer. Please follow the instructions in https://typescript-tdd.github.io/ts-auto-mock/installation
If help is required you can find us on https://typescript-tdd.github.io
`);
throw new Error(NoTransformerError);
}

0 comments on commit dd73b57

Please sign in to comment.