This repository has been archived by the owner on Oct 27, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improved validation error messages (#89)
- Loading branch information
1 parent
fe5f341
commit 074bcdc
Showing
10 changed files
with
1,371 additions
and
952 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
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 |
---|---|---|
@@ -1,7 +1,4 @@ | ||
module.exports = { | ||
ignore: ['package-lock.json', 'CHANGELOG.md'], | ||
linters: { | ||
'*.js': ['prettier --write', 'eslint --fix', 'git add'], | ||
'*.{json,md,yml,css}': ['prettier --write', 'git add'], | ||
}, | ||
'*.js': ['prettier --write', 'eslint --fix', 'git add'], | ||
'*.{json,md,yml,css}': ['prettier --write', 'git add'], | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
This file was deleted.
Oops, something went wrong.
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,25 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`validate options error (pitch) 1`] = ` | ||
"Invalid options object. Cache Loader (Pitch) has been initialised using an options object that does not match the API schema. | ||
- options.cacheIdentifier should be a string. | ||
-> Provide a cache directory where cache items should be stored (used for default read/write implementation)." | ||
`; | ||
|
||
exports[`validate options error 1`] = ` | ||
"Invalid options object. Cache Loader has been initialised using an options object that does not match the API schema. | ||
- options.cacheIdentifier should be a string. | ||
-> Provide a cache directory where cache items should be stored (used for default read/write implementation)." | ||
`; | ||
|
||
exports[`validate options unknown (pitch) 1`] = ` | ||
"Invalid options object. Cache Loader (Pitch) has been initialised using an options object that does not match the API schema. | ||
- options has an unknown property 'unknown'. These properties are valid: | ||
object { cacheContext?, cacheKey?, cacheIdentifier?, cacheDirectory?, compare?, precision?, read?, readOnly?, write? }" | ||
`; | ||
exports[`validate options unknown 1`] = ` | ||
"Invalid options object. Cache Loader has been initialised using an options object that does not match the API schema. | ||
- options has an unknown property 'unknown'. These properties are valid: | ||
object { cacheContext?, cacheKey?, cacheIdentifier?, cacheDirectory?, compare?, precision?, read?, readOnly?, write? }" | ||
`; |
This file was deleted.
Oops, something went wrong.
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,35 @@ | ||
import loader, { pitch } from '../src'; | ||
|
||
// Needed for `schema-utils` to not call | ||
// process.exit(1) when running tests | ||
process.env.JEST = true; | ||
|
||
describe('validate options', () => { | ||
test('error', () => { | ||
const err = () => loader.call({ query: { cacheIdentifier: 1 } }); | ||
|
||
expect(err).toThrow(); | ||
expect(err).toThrowErrorMatchingSnapshot(); | ||
}); | ||
|
||
test('unknown', () => { | ||
const err = () => loader.call({ query: { unknown: 'unknown' } }); | ||
|
||
expect(err).toThrow(); | ||
expect(err).toThrowErrorMatchingSnapshot(); | ||
}); | ||
|
||
test('error (pitch)', () => { | ||
const err = () => pitch.call({ query: { cacheIdentifier: 1 } }); | ||
|
||
expect(err).toThrow(); | ||
expect(err).toThrowErrorMatchingSnapshot(); | ||
}); | ||
|
||
test('unknown (pitch)', () => { | ||
const err = () => pitch.call({ query: { unknown: 'unknown' } }); | ||
|
||
expect(err).toThrow(); | ||
expect(err).toThrowErrorMatchingSnapshot(); | ||
}); | ||
}); |