-
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('../../jest.config'); |
5 changes: 5 additions & 0 deletions
5
packages/cspell-json-reporter/src/utils/__snapshots__/setToJSONReplacer.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`setToJSONReplacer converts Set to Array 1`] = `"{\\"foo\\":[\\"foo\\",\\"bar\\",123]}"`; | ||
|
||
exports[`setToJSONReplacer ignores other values 1`] = `"{\\"123\\":\\"1\\",\\"foo\\":\\"bar\\",\\"obj\\":{\\"key\\":\\"value\\"},\\"array\\":[1,2,3]}"`; |
9 changes: 9 additions & 0 deletions
9
packages/cspell-json-reporter/src/utils/__snapshots__/validateSettings.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`validateSettings throws for invalid settings 1`] = `"cspell-json-reporter settings.outFile must be a string"`; | ||
|
||
exports[`validateSettings throws for invalid settings 2`] = `"cspell-json-reporter settings.outFile must be a string"`; | ||
|
||
exports[`validateSettings throws for invalid settings 3`] = `"cspell-json-reporter settings.verbose must be a boolean"`; | ||
|
||
exports[`validateSettings throws for invalid settings 4`] = `"cspell-json-reporter settings.debug must be a boolean"`; |
20 changes: 20 additions & 0 deletions
20
packages/cspell-json-reporter/src/utils/setToJSONReplacer.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { setToJSONReplacer } from "./setToJSONReplacer"; | ||
|
||
describe('setToJSONReplacer', () => { | ||
it('converts Set to Array', () => { | ||
const input = { | ||
foo: new Set(['foo', 'bar', 123]), | ||
}; | ||
expect(JSON.stringify(input, setToJSONReplacer)).toMatchSnapshot(); | ||
}); | ||
|
||
it('ignores other values', () => { | ||
const input = { | ||
foo: 'bar', | ||
'123': '1', | ||
obj: { key: 'value' }, | ||
array: [1, 2, 3], | ||
}; | ||
expect(JSON.stringify(input, setToJSONReplacer)).toMatchSnapshot(); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
packages/cspell-json-reporter/src/utils/validateSettings.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { CSpellJSONReporterSettings } from "../CSpellJSONReporterSettings"; | ||
import { validateSettings } from "./validateSettings"; | ||
|
||
describe('validateSettings', () => { | ||
it('passes valid settings', () => { | ||
const valid: CSpellJSONReporterSettings[] = [ | ||
{ outFile: 'foobar' }, | ||
{ outFile: 'foobar', verbose: true }, | ||
{ outFile: 'foobar', debug: false }, | ||
{ outFile: 'foobar', progress: true }, | ||
{ outFile: 'foobar', verbose: undefined }, | ||
]; | ||
valid.forEach((settings) => { | ||
expect(validateSettings(settings)).toEqual(undefined); | ||
}); | ||
}); | ||
|
||
it('throws for invalid settings', () => { | ||
const invalid = [ | ||
{ }, | ||
{ outFile: 1 }, | ||
{ outFile: 'foobar', verbose: 123 }, | ||
{ outFile: 'foobar', debug: [] }, | ||
]; | ||
invalid.forEach((settings) => { | ||
expect(() => validateSettings(settings)).toThrowErrorMatchingSnapshot(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters