Skip to content

Commit 3ea9b7e

Browse files
committed
test: update Jest snapshot format
1 parent 0c635c7 commit 3ea9b7e

10 files changed

+121
-121
lines changed

test/integration/git-lock-file.test.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,17 @@ describe('lint-staged', () => {
4747
// But local modifications are gone
4848
expect(await execGit(['diff'])).not.toEqual(diff)
4949
expect(await execGit(['diff'])).toMatchInlineSnapshot(`
50-
"diff --git a/test.js b/test.js
51-
index 1eff6a0..8baadc8 100644
52-
--- a/test.js
53-
+++ b/test.js
54-
@@ -1,3 +1,3 @@
55-
module.exports = {
56-
- 'foo': 'bar'
57-
-}
58-
+ foo: \\"bar\\",
59-
+};"
60-
`)
50+
"diff --git a/test.js b/test.js
51+
index 1eff6a0..8baadc8 100644
52+
--- a/test.js
53+
+++ b/test.js
54+
@@ -1,3 +1,3 @@
55+
module.exports = {
56+
- 'foo': 'bar'
57+
-}
58+
+ foo: "bar",
59+
+};"
60+
`)
6161

6262
expect(await readFile('test.js')).not.toEqual(uglyJS + appended)
6363
expect(await readFile('test.js')).toEqual(prettyJS)

test/integration/gitWorkFlow.test.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ describe('gitWorkflow', () => {
3939
`"test"`
4040
)
4141
expect(ctx).toMatchInlineSnapshot(`
42-
Object {
42+
{
4343
"errors": Set {
4444
Symbol(GitError),
4545
},
4646
"events": EventEmitter {
47-
"_events": Object {},
47+
"_events": {},
4848
"_eventsCount": 0,
4949
"_maxListeners": undefined,
5050
Symbol(kCapture): false,
5151
},
5252
"hasPartiallyStagedFiles": true,
53-
"output": Array [],
53+
"output": [],
5454
"quiet": false,
5555
"shouldBackup": null,
5656
}
@@ -70,19 +70,19 @@ describe('gitWorkflow', () => {
7070
`"lint-staged automatic backup is missing!"`
7171
)
7272
expect(ctx).toMatchInlineSnapshot(`
73-
Object {
73+
{
7474
"errors": Set {
7575
Symbol(GetBackupStashError),
7676
Symbol(GitError),
7777
},
7878
"events": EventEmitter {
79-
"_events": Object {},
79+
"_events": {},
8080
"_eventsCount": 0,
8181
"_maxListeners": undefined,
8282
Symbol(kCapture): false,
8383
},
8484
"hasPartiallyStagedFiles": null,
85-
"output": Array [],
85+
"output": [],
8686
"quiet": false,
8787
"shouldBackup": null,
8888
}
@@ -144,19 +144,19 @@ describe('gitWorkflow', () => {
144144
`pathspec '${totallyRandom}' did not match any file(s) known to git`
145145
)
146146
expect(ctx).toMatchInlineSnapshot(`
147-
Object {
147+
{
148148
"errors": Set {
149149
Symbol(GitError),
150150
Symbol(HideUnstagedChangesError),
151151
},
152152
"events": EventEmitter {
153-
"_events": Object {},
153+
"_events": {},
154154
"_eventsCount": 0,
155155
"_maxListeners": undefined,
156156
Symbol(kCapture): false,
157157
},
158158
"hasPartiallyStagedFiles": null,
159-
"output": Array [],
159+
"output": [],
160160
"quiet": false,
161161
"shouldBackup": null,
162162
}
@@ -198,19 +198,19 @@ describe('gitWorkflow', () => {
198198
`"Merge state could not be restored due to an error!"`
199199
)
200200
expect(ctx).toMatchInlineSnapshot(`
201-
Object {
201+
{
202202
"errors": Set {
203203
Symbol(GitError),
204204
Symbol(RestoreMergeStatusError),
205205
},
206206
"events": EventEmitter {
207-
"_events": Object {},
207+
"_events": {},
208208
"_eventsCount": 0,
209209
"_maxListeners": undefined,
210210
Symbol(kCapture): false,
211211
},
212212
"hasPartiallyStagedFiles": null,
213-
"output": Array [],
213+
"output": [],
214214
"quiet": false,
215215
"shouldBackup": null,
216216
}

test/integration/merge-conflict.test.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ describe('lint-staged', () => {
5050
await expect(execGit(['merge', 'branch-b'])).rejects.toThrowError('Merge conflict in test.js')
5151

5252
expect(await readFile('test.js')).toMatchInlineSnapshot(`
53-
"<<<<<<< HEAD
54-
module.exports = \\"foo\\";
55-
=======
56-
module.exports = \\"bar\\";
57-
>>>>>>> branch-b
58-
"
59-
`)
53+
"<<<<<<< HEAD
54+
module.exports = "foo";
55+
=======
56+
module.exports = "bar";
57+
>>>>>>> branch-b
58+
"
59+
`)
6060

6161
// Fix conflict and commit using lint-staged
6262
await writeFile('test.js', fileInBranchB)
@@ -115,9 +115,9 @@ describe('lint-staged', () => {
115115

116116
expect(await readFile('test.js')).toMatchInlineSnapshot(`
117117
"<<<<<<< HEAD
118-
module.exports = \\"foo\\";
118+
module.exports = "foo";
119119
=======
120-
module.exports = \\"bar\\";
120+
module.exports = "bar";
121121
>>>>>>> branch-b
122122
"
123123
`)

test/integration/no-stash.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ describe('lint-staged', () => {
6666
expect(await readFile('test.js')).toMatchInlineSnapshot(`
6767
"<<<<<<< ours
6868
module.exports = {
69-
foo: \\"bar\\",
69+
foo: "bar",
7070
};
7171
=======
7272
const obj = {

test/unit/execGit.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jest.mock('execa', () => ({
1212

1313
test('GIT_GLOBAL_OPTIONS', () => {
1414
expect(GIT_GLOBAL_OPTIONS).toMatchInlineSnapshot(`
15-
Array [
15+
[
1616
"-c",
1717
"submodule.recurse=false",
1818
]

test/unit/index2.spec.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ describe('lintStaged', () => {
4646
await lintStaged({ configPath: MOCK_CONFIG_FILE, quiet: true }, makeConsoleMock())
4747

4848
expect(Listr.mock.calls[0][1]).toMatchInlineSnapshot(`
49-
Object {
50-
"ctx": Object {
49+
{
50+
"ctx": {
5151
"errors": Set {},
5252
"events": EventEmitter {
53-
"_events": Object {},
53+
"_events": {},
5454
"_eventsCount": 0,
5555
"_maxListeners": undefined,
5656
Symbol(kCapture): false,
5757
},
5858
"hasPartiallyStagedFiles": null,
59-
"output": Array [],
59+
"output": [],
6060
"quiet": true,
6161
"shouldBackup": true,
6262
},
@@ -79,17 +79,17 @@ describe('lintStaged', () => {
7979
)
8080

8181
expect(Listr.mock.calls[0][1]).toMatchInlineSnapshot(`
82-
Object {
83-
"ctx": Object {
82+
{
83+
"ctx": {
8484
"errors": Set {},
8585
"events": EventEmitter {
86-
"_events": Object {},
86+
"_events": {},
8787
"_eventsCount": 0,
8888
"_maxListeners": undefined,
8989
Symbol(kCapture): false,
9090
},
9191
"hasPartiallyStagedFiles": null,
92-
"output": Array [],
92+
"output": [],
9393
"quiet": false,
9494
"shouldBackup": true,
9595
},

test/unit/loadConfig.spec.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('loadConfig', () => {
3939
)
4040

4141
expect(config).toMatchInlineSnapshot(`
42-
Object {
42+
{
4343
"*": "mytask",
4444
}
4545
`)
@@ -54,7 +54,7 @@ describe('loadConfig', () => {
5454
)
5555

5656
expect(config).toMatchInlineSnapshot(`
57-
Object {
57+
{
5858
"*": "mytask",
5959
}
6060
`)
@@ -69,7 +69,7 @@ describe('loadConfig', () => {
6969
)
7070

7171
expect(config).toMatchInlineSnapshot(`
72-
Object {
72+
{
7373
"*.css": [Function],
7474
"*.js": [Function],
7575
}
@@ -85,7 +85,7 @@ describe('loadConfig', () => {
8585
)
8686

8787
expect(config).toMatchInlineSnapshot(`
88-
Object {
88+
{
8989
"*.css": [Function],
9090
"*.js": [Function],
9191
}
@@ -101,7 +101,7 @@ describe('loadConfig', () => {
101101
)
102102

103103
expect(config).toMatchInlineSnapshot(`
104-
Object {
104+
{
105105
"*": "mytask",
106106
}
107107
`)
@@ -120,7 +120,7 @@ describe('loadConfig', () => {
120120
)
121121

122122
expect(config).toMatchInlineSnapshot(`
123-
Object {
123+
{
124124
"*": "mytask",
125125
}
126126
`)
@@ -139,7 +139,7 @@ describe('loadConfig', () => {
139139
)
140140

141141
expect(config).toMatchInlineSnapshot(`
142-
Object {
142+
{
143143
"*": "mytask",
144144
}
145145
`)
@@ -156,7 +156,7 @@ describe('loadConfig', () => {
156156
)
157157

158158
expect(config).toMatchInlineSnapshot(`
159-
Object {
159+
{
160160
"*": "mytask",
161161
}
162162
`)
@@ -167,14 +167,14 @@ describe('loadConfig', () => {
167167

168168
const result = await loadConfig({ cwd: '/' })
169169

170-
expect(result).toMatchInlineSnapshot(`Object {}`)
170+
expect(result).toMatchInlineSnapshot(`{}`)
171171
})
172172

173173
it('should return empty object when explicit config file is not found', async () => {
174174
expect.assertions(1)
175175

176176
const result = await loadConfig({ configPath: 'fake-config-file.yml' }, logger)
177177

178-
expect(result).toMatchInlineSnapshot(`Object {}`)
178+
expect(result).toMatchInlineSnapshot(`{}`)
179179
})
180180
})

test/unit/resolveTaskFn.spec.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -242,16 +242,16 @@ describe('resolveTaskFn', () => {
242242
const context = getInitialState()
243243
await expect(taskFn(context)).resolves.toMatchInlineSnapshot(`undefined`)
244244
expect(context).toMatchInlineSnapshot(`
245-
Object {
245+
{
246246
"errors": Set {},
247247
"events": EventEmitter {
248-
"_events": Object {},
248+
"_events": {},
249249
"_eventsCount": 0,
250250
"_maxListeners": undefined,
251251
Symbol(kCapture): false,
252252
},
253253
"hasPartiallyStagedFiles": null,
254-
"output": Array [],
254+
"output": [],
255255
"quiet": false,
256256
"shouldBackup": null,
257257
}
@@ -274,16 +274,16 @@ describe('resolveTaskFn', () => {
274274
const context = getInitialState()
275275
await expect(taskFn(context)).resolves.toMatchInlineSnapshot(`undefined`)
276276
expect(context).toMatchInlineSnapshot(`
277-
Object {
277+
{
278278
"errors": Set {},
279279
"events": EventEmitter {
280-
"_events": Object {},
280+
"_events": {},
281281
"_eventsCount": 0,
282282
"_maxListeners": undefined,
283283
Symbol(kCapture): false,
284284
},
285285
"hasPartiallyStagedFiles": null,
286-
"output": Array [
286+
"output": [
287287
"
288288
→ mock cmd:
289289
Mock success",
@@ -310,18 +310,18 @@ describe('resolveTaskFn', () => {
310310
const context = getInitialState({ quiet: true })
311311
await expect(taskFn(context)).rejects.toThrowErrorMatchingInlineSnapshot(`"mock cmd [1]"`)
312312
expect(context).toMatchInlineSnapshot(`
313-
Object {
313+
{
314314
"errors": Set {
315315
Symbol(TaskError),
316316
},
317317
"events": EventEmitter {
318-
"_events": Object {},
318+
"_events": {},
319319
"_eventsCount": 0,
320320
"_maxListeners": undefined,
321321
Symbol(kCapture): false,
322322
},
323323
"hasPartiallyStagedFiles": null,
324-
"output": Array [
324+
"output": [
325325
"stderr",
326326
],
327327
"quiet": true,
@@ -346,18 +346,18 @@ describe('resolveTaskFn', () => {
346346
const context = getInitialState({ quiet: true })
347347
await expect(taskFn(context)).rejects.toThrowErrorMatchingInlineSnapshot(`"mock cmd [1]"`)
348348
expect(context).toMatchInlineSnapshot(`
349-
Object {
349+
{
350350
"errors": Set {
351351
Symbol(TaskError),
352352
},
353353
"events": EventEmitter {
354-
"_events": Object {},
354+
"_events": {},
355355
"_eventsCount": 0,
356356
"_maxListeners": undefined,
357357
Symbol(kCapture): false,
358358
},
359359
"hasPartiallyStagedFiles": null,
360-
"output": Array [],
360+
"output": [],
361361
"quiet": true,
362362
"shouldBackup": null,
363363
}

test/unit/resolveTaskFn.unmocked.spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('resolveTaskFn', () => {
3131
const task2Promise = taskFn2(context)
3232

3333
await expect(task2Promise).rejects.toThrowErrorMatchingInlineSnapshot(
34-
`"node -e \\"process.exit(1)\\" [FAILED]"`
34+
`"node -e "process.exit(1)" [FAILED]"`
3535
)
3636
await expect(taskPromise).rejects.toThrowErrorMatchingInlineSnapshot(`"node [KILLED]"`)
3737
})

0 commit comments

Comments
 (0)