-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(amplify-appsync-simulator): parse AWSTimestamp literals as Ints (#…
- Loading branch information
Showing
2 changed files
with
24 additions
and
3 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
packages/amplify-appsync-simulator/src/__tests__/scalars/AWSTimestamp.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,17 @@ | ||
import { ValueNode } from 'graphql'; | ||
import { scalars } from '../../schema/appsync-scalars'; | ||
|
||
describe('AWSTimestamp parseLiteral', () => { | ||
it('Returns literals as integers', () => { | ||
const astNode = { kind: 'IntValue', value: '1234', loc: { start: 68, end: 74 } } as ValueNode; | ||
expect(scalars.AWSTimestamp.parseLiteral(astNode, null)).toEqual(1234); | ||
}); | ||
|
||
it('Rejects non-integer literals', () => { | ||
const astNode = { kind: 'StringValue', value: '1234', loc: { start: 68, end: 74 } } as ValueNode; | ||
|
||
expect(() => { | ||
scalars.AWSTimestamp.parseLiteral(astNode, null); | ||
}).toThrow('Can only validate integers but received: StringValue'); | ||
}); | ||
}); |
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