Skip to content

Commit 776e005

Browse files
committed
refactor(detector): test cases structure
1 parent 00bd7b3 commit 776e005

File tree

3 files changed

+28
-22
lines changed

3 files changed

+28
-22
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export const IF_STATEMENT = 'if-statement';
2+
export const FOR_OF = 'for-of-statement';
3+
export const FOR_IN = 'for-in-statement';
4+
export const FOR = 'for-statement';
5+
export const TIMEOUT = 'timeout';
6+
export const CONSOLE = 'console-statement';
7+
export const MOCKERY = 'excessive-jest-mock';
8+
9+
export const JAVASCRIPT = 'javascript';
10+
export const TYPESCRIPT = 'typescript';

detector/test/smells-detector.test.ts renamed to detector/test/smells-detector-with-smells.test.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
import { describe, expect, test } from 'vitest';
22
import { SmellDetector } from '../src/index';
3+
import { CONSOLE, FOR, FOR_IN, FOR_OF, IF_STATEMENT, JAVASCRIPT, MOCKERY, TIMEOUT, TYPESCRIPT } from './smells-detector-builder';
34

4-
const IF_STATEMENT = 'if-statement';
5-
const FOR_OF = 'for-of-statement';
6-
const FOR_IN = 'for-in-statement';
7-
const FOR = 'for-statement';
8-
const TIMEOUT = 'timeout';
9-
const CONSOLE = 'console-statement';
10-
const MOCKERY = 'excessive-jest-mock';
11-
12-
const JAVASCRIPT = 'javascript';
13-
const TYPESCRIPT = 'typescript';
145

156
describe('Smelly Test Smell Detection Suite', () => {
167
test.each([[{
@@ -383,16 +374,4 @@ jest.mock("../");`,
383374
expect(result[index].description).toEqual(description);
384375
expect(result[index].diagnostic).toEqual(diagnostic);
385376
});
386-
387-
test.each([{
388-
code: `
389-
jest.mock("../");`,
390-
language: TYPESCRIPT,
391-
}
392-
])(`detect code without smells`, ({ code, language }) => {
393-
const smellDetector = new SmellDetector(code, language);
394-
const result = smellDetector.findAll();
395-
396-
expect(result.length).toEqual(0);
397-
});
398377
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { describe, expect, test } from 'vitest';
2+
import { SmellDetector } from '../src/index';
3+
import { TYPESCRIPT } from './smells-detector-builder';
4+
5+
describe('Smelly Test Smell Detection Suite', () => {
6+
test.each([{
7+
code: `
8+
jest.mock("../");`,
9+
language: TYPESCRIPT,
10+
}
11+
])(`detect code without smells`, ({ code, language }) => {
12+
const smellDetector = new SmellDetector(code, language);
13+
const result = smellDetector.findAll();
14+
15+
expect(result.length).toEqual(0);
16+
});
17+
});

0 commit comments

Comments
 (0)