|
1 | 1 | import { getValueAsGqlStringNode } from '@/GqlParser/valueNode';
|
2 | 2 | import { expectTrimmedEqual } from '@/__tests__/TestUtils';
|
| 3 | +import { Kind } from 'graphql'; |
3 | 4 |
|
4 | 5 | describe('Test generation of value strings from the GqlParserTree', () => {
|
5 | 6 | it('Generates Correct Variable Value', () => {
|
6 |
| - const strValue = getValueAsGqlStringNode({ kind: 'Variable', value: 'Hello' }); |
| 7 | + const strValue = getValueAsGqlStringNode({ kind: Kind.VARIABLE, value: 'Hello' }); |
7 | 8 | expect(strValue).toEqual(`$Hello`);
|
8 | 9 | });
|
9 | 10 | it('Generates Correct String Value', () => {
|
10 |
| - const strValue = getValueAsGqlStringNode({ kind: 'StringValue', value: 'Hello' }); |
| 11 | + const strValue = getValueAsGqlStringNode({ kind: Kind.STRING, value: 'Hello' }); |
11 | 12 | expect(strValue).toEqual(`"Hello"`);
|
12 | 13 | });
|
13 | 14 | it('Generates Correct Int Value', () => {
|
14 |
| - const strValue = getValueAsGqlStringNode({ kind: 'IntValue', value: '100' }); |
| 15 | + const strValue = getValueAsGqlStringNode({ kind: Kind.INT, value: '100' }); |
15 | 16 | expect(strValue).toEqual(`100`);
|
16 | 17 | });
|
17 | 18 | it('Generates Correct Float Value', () => {
|
18 |
| - const strValue = getValueAsGqlStringNode({ kind: 'FloatValue', value: '100.0' }); |
| 19 | + const strValue = getValueAsGqlStringNode({ kind: Kind.FLOAT, value: '100.0' }); |
19 | 20 | expect(strValue).toEqual(`100.0`);
|
20 | 21 | });
|
21 | 22 | it('Generates Correct Boolean Value', () => {
|
22 |
| - const strValue = getValueAsGqlStringNode({ kind: 'BooleanValue', value: false }); |
| 23 | + const strValue = getValueAsGqlStringNode({ kind: Kind.BOOLEAN, value: false }); |
23 | 24 | expect(strValue).toEqual(`false`);
|
24 | 25 | });
|
25 | 26 | it('Generates Correct Enum Value', () => {
|
26 |
| - const strValue = getValueAsGqlStringNode({ kind: 'EnumValue', value: 'HELLO' }); |
| 27 | + const strValue = getValueAsGqlStringNode({ kind: Kind.ENUM, value: 'HELLO' }); |
27 | 28 | expect(strValue).toEqual(`HELLO`);
|
28 | 29 | });
|
29 | 30 | it('Generates Correct Null Value', () => {
|
30 |
| - const strValue = getValueAsGqlStringNode({ kind: 'NullValue', value: null }); |
| 31 | + const strValue = getValueAsGqlStringNode({ kind: Kind.NULL, value: null }); |
31 | 32 | expect(strValue).toEqual(`null`);
|
32 | 33 | });
|
33 | 34 | it('Generates Correct List Value', () => {
|
34 | 35 | const strValue = getValueAsGqlStringNode({
|
35 |
| - kind: 'ListValue', |
| 36 | + kind: Kind.LIST, |
36 | 37 | values: [
|
37 |
| - { kind: 'StringValue', value: 'Hello' }, |
38 |
| - { kind: 'StringValue', value: 'World' }, |
| 38 | + { kind: Kind.STRING, value: 'Hello' }, |
| 39 | + { kind: Kind.STRING, value: 'World' }, |
39 | 40 | ],
|
40 | 41 | });
|
41 | 42 | expectTrimmedEqual(strValue, `["Hello", "World"]`);
|
42 | 43 | });
|
43 | 44 | it('Generates Correct Object Value', () => {
|
44 | 45 | const strValue = getValueAsGqlStringNode({
|
45 |
| - kind: 'ObjectValue', |
| 46 | + kind: Kind.OBJECT, |
46 | 47 | fields: [
|
47 |
| - { kind: 'ObjectField', name: 'word', value: { kind: 'StringValue', value: 'Hello' } }, |
48 |
| - { kind: 'ObjectField', name: 'word2', value: { kind: 'StringValue', value: 'Hello' } }, |
| 48 | + { kind: Kind.OBJECT_FIELD, name: 'word', value: { kind: Kind.STRING, value: 'Hello' } }, |
| 49 | + { kind: Kind.OBJECT_FIELD, name: 'word2', value: { kind: Kind.STRING, value: 'Hello' } }, |
49 | 50 | ],
|
50 | 51 | });
|
51 | 52 | expectTrimmedEqual(
|
|
0 commit comments