-
Notifications
You must be signed in to change notification settings - Fork 227
/
snapshot-processor.test.ts
35 lines (30 loc) · 1.06 KB
/
snapshot-processor.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import * as snapshotProcessor from '../snapshot-processor';
describe('snapshot-processor', () => {
it('exports an object with preprocess and postprocess functions', () => {
expect(snapshotProcessor).toMatchObject({
preprocess: expect.any(Function),
postprocess: expect.any(Function),
});
});
describe('preprocess function', () => {
it('should pass on untouched source code to source array', () => {
const { preprocess } = snapshotProcessor;
const sourceCode = "const name = 'johnny bravo';";
const result = preprocess(sourceCode);
expect(result).toEqual([sourceCode]);
});
});
describe('postprocess function', () => {
it('should only return messages about snapshot specific rules', () => {
const { postprocess } = snapshotProcessor;
const result = postprocess([
[
'no-console',
'global-require',
'jest/no-large-snapshots',
].map(ruleId => ({ ruleId })),
]);
expect(result).toEqual([{ ruleId: 'jest/no-large-snapshots' }]);
});
});
});