Skip to content

Commit

Permalink
test: update Jest snapshot format
Browse files Browse the repository at this point in the history
  • Loading branch information
iiroj committed Nov 25, 2022
1 parent 0c635c7 commit 3ea9b7e
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 121 deletions.
22 changes: 11 additions & 11 deletions test/integration/git-lock-file.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,17 @@ describe('lint-staged', () => {
// But local modifications are gone
expect(await execGit(['diff'])).not.toEqual(diff)
expect(await execGit(['diff'])).toMatchInlineSnapshot(`
"diff --git a/test.js b/test.js
index 1eff6a0..8baadc8 100644
--- a/test.js
+++ b/test.js
@@ -1,3 +1,3 @@
module.exports = {
- 'foo': 'bar'
-}
+ foo: \\"bar\\",
+};"
`)
"diff --git a/test.js b/test.js
index 1eff6a0..8baadc8 100644
--- a/test.js
+++ b/test.js
@@ -1,3 +1,3 @@
module.exports = {
- 'foo': 'bar'
-}
+ foo: "bar",
+};"
`)

expect(await readFile('test.js')).not.toEqual(uglyJS + appended)
expect(await readFile('test.js')).toEqual(prettyJS)
Expand Down
24 changes: 12 additions & 12 deletions test/integration/gitWorkFlow.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,18 @@ describe('gitWorkflow', () => {
`"test"`
)
expect(ctx).toMatchInlineSnapshot(`
Object {
{
"errors": Set {
Symbol(GitError),
},
"events": EventEmitter {
"_events": Object {},
"_events": {},
"_eventsCount": 0,
"_maxListeners": undefined,
Symbol(kCapture): false,
},
"hasPartiallyStagedFiles": true,
"output": Array [],
"output": [],
"quiet": false,
"shouldBackup": null,
}
Expand All @@ -70,19 +70,19 @@ describe('gitWorkflow', () => {
`"lint-staged automatic backup is missing!"`
)
expect(ctx).toMatchInlineSnapshot(`
Object {
{
"errors": Set {
Symbol(GetBackupStashError),
Symbol(GitError),
},
"events": EventEmitter {
"_events": Object {},
"_events": {},
"_eventsCount": 0,
"_maxListeners": undefined,
Symbol(kCapture): false,
},
"hasPartiallyStagedFiles": null,
"output": Array [],
"output": [],
"quiet": false,
"shouldBackup": null,
}
Expand Down Expand Up @@ -144,19 +144,19 @@ describe('gitWorkflow', () => {
`pathspec '${totallyRandom}' did not match any file(s) known to git`
)
expect(ctx).toMatchInlineSnapshot(`
Object {
{
"errors": Set {
Symbol(GitError),
Symbol(HideUnstagedChangesError),
},
"events": EventEmitter {
"_events": Object {},
"_events": {},
"_eventsCount": 0,
"_maxListeners": undefined,
Symbol(kCapture): false,
},
"hasPartiallyStagedFiles": null,
"output": Array [],
"output": [],
"quiet": false,
"shouldBackup": null,
}
Expand Down Expand Up @@ -198,19 +198,19 @@ describe('gitWorkflow', () => {
`"Merge state could not be restored due to an error!"`
)
expect(ctx).toMatchInlineSnapshot(`
Object {
{
"errors": Set {
Symbol(GitError),
Symbol(RestoreMergeStatusError),
},
"events": EventEmitter {
"_events": Object {},
"_events": {},
"_eventsCount": 0,
"_maxListeners": undefined,
Symbol(kCapture): false,
},
"hasPartiallyStagedFiles": null,
"output": Array [],
"output": [],
"quiet": false,
"shouldBackup": null,
}
Expand Down
18 changes: 9 additions & 9 deletions test/integration/merge-conflict.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ describe('lint-staged', () => {
await expect(execGit(['merge', 'branch-b'])).rejects.toThrowError('Merge conflict in test.js')

expect(await readFile('test.js')).toMatchInlineSnapshot(`
"<<<<<<< HEAD
module.exports = \\"foo\\";
=======
module.exports = \\"bar\\";
>>>>>>> branch-b
"
`)
"<<<<<<< HEAD
module.exports = "foo";
=======
module.exports = "bar";
>>>>>>> branch-b
"
`)

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

expect(await readFile('test.js')).toMatchInlineSnapshot(`
"<<<<<<< HEAD
module.exports = \\"foo\\";
module.exports = "foo";
=======
module.exports = \\"bar\\";
module.exports = "bar";
>>>>>>> branch-b
"
`)
Expand Down
2 changes: 1 addition & 1 deletion test/integration/no-stash.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('lint-staged', () => {
expect(await readFile('test.js')).toMatchInlineSnapshot(`
"<<<<<<< ours
module.exports = {
foo: \\"bar\\",
foo: "bar",
};
=======
const obj = {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/execGit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jest.mock('execa', () => ({

test('GIT_GLOBAL_OPTIONS', () => {
expect(GIT_GLOBAL_OPTIONS).toMatchInlineSnapshot(`
Array [
[
"-c",
"submodule.recurse=false",
]
Expand Down
16 changes: 8 additions & 8 deletions test/unit/index2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ describe('lintStaged', () => {
await lintStaged({ configPath: MOCK_CONFIG_FILE, quiet: true }, makeConsoleMock())

expect(Listr.mock.calls[0][1]).toMatchInlineSnapshot(`
Object {
"ctx": Object {
{
"ctx": {
"errors": Set {},
"events": EventEmitter {
"_events": Object {},
"_events": {},
"_eventsCount": 0,
"_maxListeners": undefined,
Symbol(kCapture): false,
},
"hasPartiallyStagedFiles": null,
"output": Array [],
"output": [],
"quiet": true,
"shouldBackup": true,
},
Expand All @@ -79,17 +79,17 @@ describe('lintStaged', () => {
)

expect(Listr.mock.calls[0][1]).toMatchInlineSnapshot(`
Object {
"ctx": Object {
{
"ctx": {
"errors": Set {},
"events": EventEmitter {
"_events": Object {},
"_events": {},
"_eventsCount": 0,
"_maxListeners": undefined,
Symbol(kCapture): false,
},
"hasPartiallyStagedFiles": null,
"output": Array [],
"output": [],
"quiet": false,
"shouldBackup": true,
},
Expand Down
20 changes: 10 additions & 10 deletions test/unit/loadConfig.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('loadConfig', () => {
)

expect(config).toMatchInlineSnapshot(`
Object {
{
"*": "mytask",
}
`)
Expand All @@ -54,7 +54,7 @@ describe('loadConfig', () => {
)

expect(config).toMatchInlineSnapshot(`
Object {
{
"*": "mytask",
}
`)
Expand All @@ -69,7 +69,7 @@ describe('loadConfig', () => {
)

expect(config).toMatchInlineSnapshot(`
Object {
{
"*.css": [Function],
"*.js": [Function],
}
Expand All @@ -85,7 +85,7 @@ describe('loadConfig', () => {
)

expect(config).toMatchInlineSnapshot(`
Object {
{
"*.css": [Function],
"*.js": [Function],
}
Expand All @@ -101,7 +101,7 @@ describe('loadConfig', () => {
)

expect(config).toMatchInlineSnapshot(`
Object {
{
"*": "mytask",
}
`)
Expand All @@ -120,7 +120,7 @@ describe('loadConfig', () => {
)

expect(config).toMatchInlineSnapshot(`
Object {
{
"*": "mytask",
}
`)
Expand All @@ -139,7 +139,7 @@ describe('loadConfig', () => {
)

expect(config).toMatchInlineSnapshot(`
Object {
{
"*": "mytask",
}
`)
Expand All @@ -156,7 +156,7 @@ describe('loadConfig', () => {
)

expect(config).toMatchInlineSnapshot(`
Object {
{
"*": "mytask",
}
`)
Expand All @@ -167,14 +167,14 @@ describe('loadConfig', () => {

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

expect(result).toMatchInlineSnapshot(`Object {}`)
expect(result).toMatchInlineSnapshot(`{}`)
})

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

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

expect(result).toMatchInlineSnapshot(`Object {}`)
expect(result).toMatchInlineSnapshot(`{}`)
})
})
24 changes: 12 additions & 12 deletions test/unit/resolveTaskFn.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,16 @@ describe('resolveTaskFn', () => {
const context = getInitialState()
await expect(taskFn(context)).resolves.toMatchInlineSnapshot(`undefined`)
expect(context).toMatchInlineSnapshot(`
Object {
{
"errors": Set {},
"events": EventEmitter {
"_events": Object {},
"_events": {},
"_eventsCount": 0,
"_maxListeners": undefined,
Symbol(kCapture): false,
},
"hasPartiallyStagedFiles": null,
"output": Array [],
"output": [],
"quiet": false,
"shouldBackup": null,
}
Expand All @@ -274,16 +274,16 @@ describe('resolveTaskFn', () => {
const context = getInitialState()
await expect(taskFn(context)).resolves.toMatchInlineSnapshot(`undefined`)
expect(context).toMatchInlineSnapshot(`
Object {
{
"errors": Set {},
"events": EventEmitter {
"_events": Object {},
"_events": {},
"_eventsCount": 0,
"_maxListeners": undefined,
Symbol(kCapture): false,
},
"hasPartiallyStagedFiles": null,
"output": Array [
"output": [
"
→ mock cmd:
Mock success",
Expand All @@ -310,18 +310,18 @@ describe('resolveTaskFn', () => {
const context = getInitialState({ quiet: true })
await expect(taskFn(context)).rejects.toThrowErrorMatchingInlineSnapshot(`"mock cmd [1]"`)
expect(context).toMatchInlineSnapshot(`
Object {
{
"errors": Set {
Symbol(TaskError),
},
"events": EventEmitter {
"_events": Object {},
"_events": {},
"_eventsCount": 0,
"_maxListeners": undefined,
Symbol(kCapture): false,
},
"hasPartiallyStagedFiles": null,
"output": Array [
"output": [
"stderr",
],
"quiet": true,
Expand All @@ -346,18 +346,18 @@ describe('resolveTaskFn', () => {
const context = getInitialState({ quiet: true })
await expect(taskFn(context)).rejects.toThrowErrorMatchingInlineSnapshot(`"mock cmd [1]"`)
expect(context).toMatchInlineSnapshot(`
Object {
{
"errors": Set {
Symbol(TaskError),
},
"events": EventEmitter {
"_events": Object {},
"_events": {},
"_eventsCount": 0,
"_maxListeners": undefined,
Symbol(kCapture): false,
},
"hasPartiallyStagedFiles": null,
"output": Array [],
"output": [],
"quiet": true,
"shouldBackup": null,
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/resolveTaskFn.unmocked.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('resolveTaskFn', () => {
const task2Promise = taskFn2(context)

await expect(task2Promise).rejects.toThrowErrorMatchingInlineSnapshot(
`"node -e \\"process.exit(1)\\" [FAILED]"`
`"node -e "process.exit(1)" [FAILED]"`
)
await expect(taskPromise).rejects.toThrowErrorMatchingInlineSnapshot(`"node [KILLED]"`)
})
Expand Down
Loading

0 comments on commit 3ea9b7e

Please sign in to comment.