Skip to content

Commit

Permalink
infra(vitest): no-alias-methods (#2899)
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT authored May 18, 2024
1 parent 9226945 commit 7dc8a18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ module.exports = defineConfig({
],

'vitest/expect-expect': 'off',
'vitest/no-alias-methods': 'error',
'vitest/prefer-each': 'error',
'vitest/prefer-to-have-length': 'error',
'vitest/valid-expect': ['error', { maxArgs: 2 }],
Expand Down
16 changes: 8 additions & 8 deletions test/modules/helpers-eval.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { fakeEval } from '../../src/modules/helpers/eval';

describe('fakeEval()', () => {
it('does not allow empty string input', () => {
expect(() => fakeEval('', faker)).toThrowError(
expect(() => fakeEval('', faker)).toThrow(
new FakerError('Eval expression cannot be empty.')
);
});

it('does not allow empty entrypoints', () => {
expect(() => fakeEval('foobar', faker, [])).toThrowError(
expect(() => fakeEval('foobar', faker, [])).toThrow(
new FakerError('Eval entrypoints cannot be empty.')
);
});
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('fakeEval()', () => {
});

it('requires a dot after a function call', () => {
expect(() => fakeEval('airline.airline()iataCode', faker)).toThrowError(
expect(() => fakeEval('airline.airline()iataCode', faker)).toThrow(
new FakerError(
"Expected dot ('.'), open parenthesis ('('), or nothing after function call but got 'i'"
)
Expand All @@ -140,22 +140,22 @@ describe('fakeEval()', () => {
});

it('requires a valid expression (trailing dot)', () => {
expect(() => fakeEval('airline.airline.', faker)).toThrowError(
expect(() => fakeEval('airline.airline.', faker)).toThrow(
new FakerError("Found dot without property name in 'airline.'")
);
expect(() => fakeEval('airline.airline.()', faker)).toThrowError(
expect(() => fakeEval('airline.airline.()', faker)).toThrow(
new FakerError("Found dot without property name in 'airline.()'")
);
expect(() => fakeEval('airline.airline.().iataCode', faker)).toThrowError(
expect(() => fakeEval('airline.airline.().iataCode', faker)).toThrow(
new FakerError("Found dot without property name in 'airline.().iataCode'")
);
});

it('requires a valid expression (unclosed parenthesis)', () => {
expect(() => fakeEval('airline.airline(', faker)).toThrowError(
expect(() => fakeEval('airline.airline(', faker)).toThrow(
new FakerError("Missing closing parenthesis in '('")
);
expect(() => fakeEval('airline.airline(.iataCode', faker)).toThrowError(
expect(() => fakeEval('airline.airline(.iataCode', faker)).toThrow(
new FakerError("Missing closing parenthesis in '(.iataCode'")
);
});
Expand Down

0 comments on commit 7dc8a18

Please sign in to comment.