Skip to content

Commit 1d3a9b1

Browse files
committed
Update tests
1 parent 4669f68 commit 1d3a9b1

File tree

5 files changed

+56
-83
lines changed

5 files changed

+56
-83
lines changed

src/__snapshots__/index.test.ts.snap

Lines changed: 35 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2,87 +2,46 @@
22

33
exports[`plugin should match expected export 1`] = `
44
Object {
5-
"configs": Object {
6-
"diff": Object {
7-
"overrides": Array [
8-
Object {
9-
"files": Array [
10-
"*",
11-
],
12-
"processor": "diff/diff",
13-
},
14-
],
15-
"plugins": Array [
16-
"diff",
17-
],
18-
},
19-
"staged": Object {
20-
"overrides": Array [
21-
Object {
22-
"files": Array [
23-
"*",
24-
],
25-
"processor": "diff/staged",
26-
},
27-
],
28-
"plugins": Array [
29-
"diff",
30-
],
31-
},
32-
},
33-
"default": Object {
34-
"configs": Object {
35-
"diff": Object {
36-
"overrides": Array [
37-
Object {
38-
"files": Array [
39-
"*",
40-
],
41-
"processor": "diff/diff",
42-
},
43-
],
44-
"plugins": Array [
45-
"diff",
5+
"diff": Object {
6+
"ignorePatterns": Array [],
7+
"overrides": Array [
8+
Object {
9+
"files": Array [
10+
"*",
4611
],
12+
"processor": "diff/diff",
4713
},
48-
"staged": Object {
49-
"overrides": Array [
50-
Object {
51-
"files": Array [
52-
"*",
53-
],
54-
"processor": "diff/staged",
55-
},
56-
],
57-
"plugins": Array [
58-
"diff",
14+
],
15+
"plugins": Array [
16+
"diff",
17+
],
18+
},
19+
"staged": Object {
20+
"ignorePatterns": Array [],
21+
"overrides": Array [
22+
Object {
23+
"files": Array [
24+
"*",
5925
],
26+
"processor": "diff/staged",
6027
},
61-
},
62-
"processors": Object {
63-
"diff": Object {
64-
"postprocess": [Function],
65-
"preprocess": [Function],
66-
"supportsAutofix": true,
67-
},
68-
"staged": Object {
69-
"postprocess": [Function],
70-
"preprocess": [Function],
71-
"supportsAutofix": true,
72-
},
73-
},
28+
],
29+
"plugins": Array [
30+
"diff",
31+
],
32+
},
33+
}
34+
`;
35+
36+
exports[`plugin should match expected export 2`] = `
37+
Object {
38+
"diff": Object {
39+
"postprocess": [Function],
40+
"supportsAutofix": true,
7441
},
75-
"processors": Object {
76-
"diff": Object {
77-
"postprocess": [Function],
78-
"preprocess": [Function],
79-
"supportsAutofix": true,
80-
},
81-
"staged": Object {
82-
"postprocess": [Function],
83-
"preprocess": [Function],
84-
"supportsAutofix": true,
85-
},
42+
"staged": Object {
43+
"postprocess": [Function],
44+
"supportsAutofix": true,
8645
},
8746
}
8847
`;

src/__snapshots__/processors.test.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
exports[`configs diff 1`] = `
44
Object {
5+
"ignorePatterns": Array [],
56
"overrides": Array [
67
Object {
78
"files": Array [
@@ -18,6 +19,7 @@ Object {
1819

1920
exports[`configs staged 1`] = `
2021
Object {
22+
"ignorePatterns": Array [],
2123
"overrides": Array [
2224
Object {
2325
"files": Array [

src/index.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
import * as index from "./index";
1+
import * as child_process from "child_process";
2+
import { mocked } from "ts-jest/utils";
3+
4+
jest.mock("child_process");
5+
const mockedChildProcess = mocked(child_process, true);
6+
mockedChildProcess.execSync.mockReturnValue(Buffer.from("line1\nline2\nline3"));
7+
8+
import { configs, processors } from "./index";
29

310
describe("plugin", () => {
411
it("should match expected export", () => {
5-
expect(index).toMatchSnapshot();
12+
expect(configs).toMatchSnapshot();
13+
expect(processors).toMatchSnapshot();
614
});
715
});

src/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { diff, diffConfig, staged, stagedConfig } from "./processors";
22

3-
module.exports = {
4-
configs: { diff: diffConfig, staged: stagedConfig },
5-
processors: { diff, staged },
6-
};
3+
const configs = { diff: diffConfig, staged: stagedConfig };
4+
const processors = { diff, staged };
5+
6+
export { configs, processors };
7+
module.exports = { configs, processors };

src/processors.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ import {
66
} from "./__fixtures__/diff";
77

88
jest.mock("child_process");
9-
109
const mockedChildProcess = mocked(child_process, true);
10+
mockedChildProcess.execSync.mockReturnValue(
11+
Buffer.from(`/mock filename with quotes ", semicolons ; and spaces.js`)
12+
);
13+
1114
import { diff, diffConfig, staged, stagedConfig } from "./processors";
1215
import { postprocessArguments } from "./__fixtures__/postprocessArguments";
1316

0 commit comments

Comments
 (0)