Skip to content

Commit 95484ba

Browse files
committed
printer and parser tests passing
1 parent 557a986 commit 95484ba

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

src/language/__tests__/parser-test.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -686,15 +686,19 @@ describe('Parser', () => {
686686

687687
it('parses nullable types', () => {
688688
const result = parseType('MyType?', { useSemanticNullability: true });
689-
expectJSON(result).toDeepEqual({
690-
kind: Kind.NAMED_TYPE,
691-
loc: { start: 0, end: 6 },
692-
name: {
693-
kind: Kind.NAME,
694-
loc: { start: 0, end: 6 },
695-
value: 'MyType',
696-
},
697-
});
689+
expectJSON(result).toDeepEqual(
690+
{ kind: Kind.SEMANTIC_OPTIONAL_TYPE,
691+
loc: { start: 0, end: 7 },
692+
type: {
693+
kind: Kind.NAMED_TYPE,
694+
loc: { start: 0, end: 6 },
695+
name: {
696+
kind: Kind.NAME,
697+
loc: { start: 0, end: 6 },
698+
value: 'MyType',
699+
},
700+
}
701+
});
698702
});
699703

700704
it('parses non-nullable types', () => {

src/language/__tests__/schema-printer-test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { dedent } from '../../__testUtils__/dedent';
55
import { kitchenSinkSDL } from '../../__testUtils__/kitchenSinkSDL';
66

77
import { Kind } from '../kinds';
8-
import { parse } from '../parser';
8+
import { parse, parseType } from '../parser';
99
import { print } from '../printer';
1010

1111
describe('Printer: SDL document', () => {
@@ -180,4 +180,21 @@ describe('Printer: SDL document', () => {
180180
}
181181
`);
182182
});
183+
184+
it('prints NamedType', () => {
185+
expect(print(parseType('MyType', { useSemanticNullability: false }))).to.equal(dedent`MyType`);
186+
});
187+
188+
it('prints SemanticOptionalType', () => {
189+
expect(print(parseType('MyType?', { useSemanticNullability: true }))).to.equal(dedent`MyType?`);
190+
});
191+
192+
it('prints SemanticNonNullType', () => {
193+
expect(print(parseType('MyType', { useSemanticNullability: true }))).to.equal(dedent`MyType`);
194+
});
195+
196+
it('prints NonNullType', () => {
197+
expect(print(parseType('MyType!', { useSemanticNullability: true }))).to.equal(dedent`MyType!`);
198+
expect(print(parseType('MyType!', { useSemanticNullability: false }))).to.equal(dedent`MyType!`);
199+
});
183200
});

0 commit comments

Comments
 (0)