-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
1 changed file
with
17 additions
and
4 deletions.
There are no files selected for viewing
21 changes: 17 additions & 4 deletions
21
packages/gatsby-cli/src/structured-errors/__tests__/error-schema.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 |
---|---|---|
@@ -1,13 +1,26 @@ | ||
import { errorSchema } from "../error-schema" | ||
|
||
test(`throws invalid on an invalid error`, () => { | ||
expect(errorSchema.validate({ lol: `true` })).rejects.toBeDefined() | ||
test(`returns invalid on an invalid error`, () => { | ||
expect(errorSchema.validate({ lol: `true` })).toMatchInlineSnapshot(` | ||
Object { | ||
"error": [ValidationError: "lol" is not allowed], | ||
"value": Object { | ||
"lol": "true", | ||
}, | ||
} | ||
`) | ||
}) | ||
|
||
test(`does not throw on a valid schema`, () => { | ||
test(`returns a valid value`, () => { | ||
expect( | ||
errorSchema.validate({ | ||
context: {}, | ||
}) | ||
).resolves.toEqual(expect.any(Object)) | ||
).toMatchInlineSnapshot(` | ||
Object { | ||
"value": Object { | ||
"context": Object {}, | ||
}, | ||
} | ||
`) | ||
}) |