UNPKG

1.1 kBJavaScriptView Raw
1'use strict';
2
3const snapshotProcessor = require('../snapshot-processor');
4
5describe('snapshot-processor', () => {
6 it('exports an object with preprocess and postprocess functions', () => {
7 expect(snapshotProcessor).toMatchObject({
8 preprocess: expect.any(Function),
9 postprocess: expect.any(Function),
10 });
11 });
12
13 describe('preprocess function', () => {
14 it('should pass on untouched source code to source array', () => {
15 const { preprocess } = snapshotProcessor;
16 const sourceCode = "const name = 'johnny bravo';";
17 const result = preprocess(sourceCode);
18
19 expect(result).toEqual([sourceCode]);
20 });
21 });
22
23 describe('postprocess function', () => {
24 it('should only return messages about snapshot specific rules', () => {
25 const { postprocess } = snapshotProcessor;
26 const result = postprocess([
27 [
28 { ruleId: 'no-console' },
29 { ruleId: 'global-require' },
30 { ruleId: 'jest/no-large-snapshots' },
31 ],
32 ]);
33
34 expect(result).toEqual([{ ruleId: 'jest/no-large-snapshots' }]);
35 });
36 });
37});