-
Notifications
You must be signed in to change notification settings - Fork 138
/
Copy pathLCCSubclass.test.ts
73 lines (61 loc) · 2.41 KB
/
LCCSubclass.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* global describe, test, expect */
import { Kind } from 'graphql/language';
import { GraphQLLCCSubclass } from '../src/scalars/library/LCCSubclass.js';
describe('DID', () => {
describe('valid - LCC Subclass', () => {
test('serialize classes', () => {
expect(GraphQLLCCSubclass.serialize('AI')).toBe('AI');
expect(GraphQLLCCSubclass.serialize('E')).toBe('E');
expect(GraphQLLCCSubclass.serialize('KBM')).toBe('KBM');
});
test('parseValue classes', () => {
expect(GraphQLLCCSubclass.parseValue('AI')).toBe('AI');
expect(GraphQLLCCSubclass.parseValue('E')).toBe('E');
expect(GraphQLLCCSubclass.parseValue('KBM')).toBe('KBM');
});
test('parseLiteral classes', () => {
expect(GraphQLLCCSubclass.parseLiteral({ value: 'AI', kind: Kind.STRING }, {})).toBe('AI');
expect(GraphQLLCCSubclass.parseLiteral({ value: 'E', kind: Kind.STRING }, {})).toBe('E');
expect(GraphQLLCCSubclass.parseLiteral({ value: 'KBM', kind: Kind.STRING }, {})).toBe('KBM');
});
});
describe('invalid', () => {
describe('not an LCC Class A', () => {
expect(() => GraphQLLCCSubclass.serialize('invalidexample')).toThrow(
/Value is not a valid LCC Subclass/,
);
});
test(`parseValue invaliddidexample`, () => {
expect(() => GraphQLLCCSubclass.parseValue('invaliddidexample')).toThrow(
/Value is not a valid LCC Subclass/,
);
});
test(`parseLiteral invaliddidexample`, () => {
expect(() =>
GraphQLLCCSubclass.parseLiteral({ value: 'invaliddidexample', kind: Kind.STRING }, {}),
).toThrow(/Value is not a valid LCC Subclass/);
});
});
describe('not a string', () => {
test('serialize', () => {
expect(() => GraphQLLCCSubclass.serialize(123)).toThrow();
});
test('parseValue', () => {
expect(() => GraphQLLCCSubclass.parseValue(123)).toThrow();
});
test('parseLiteral', () => {
expect(() => GraphQLLCCSubclass.parseLiteral({ value: '123', kind: Kind.INT }, {})).toThrow();
});
});
describe('not a empty string', () => {
test('serialize', () => {
expect(() => GraphQLLCCSubclass.serialize('')).toThrow();
});
test('parseValue', () => {
expect(() => GraphQLLCCSubclass.parseValue('')).toThrow();
});
test('parseLiteral', () => {
expect(() => GraphQLLCCSubclass.parseLiteral({ value: '', kind: Kind.STRING }, {})).toThrow();
});
});
});