-
Notifications
You must be signed in to change notification settings - Fork 3
/
primitive.spec.ts
41 lines (40 loc) · 1.09 KB
/
primitive.spec.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
import { describe, it, expect } from 'vitest'
import { PackPrimitive } from './primitive.js'
import { RGQLPrimitive_Kind } from './rgraphql.pb.js'
const Kind = RGQLPrimitive_Kind
describe('PackPrimitive', () => {
it('should pack a string', () => {
expect(PackPrimitive('test')).toEqual({
kind: Kind.PRIMITIVE_KIND_STRING,
stringValue: 'test',
})
})
it('should pack a int', () => {
expect(PackPrimitive(1)).toEqual({
kind: Kind.PRIMITIVE_KIND_INT,
intValue: 1,
})
})
it('should pack a float', () => {
expect(PackPrimitive(1.05235)).toEqual({
kind: Kind.PRIMITIVE_KIND_FLOAT,
floatValue: 1.05235,
})
})
it('should pack an empty array', () => {
expect(PackPrimitive([])).toEqual({
kind: Kind.PRIMITIVE_KIND_ARRAY,
})
})
it('should pack a object', () => {
expect(PackPrimitive({ hello: 'world' })).toEqual({
kind: Kind.PRIMITIVE_KIND_OBJECT,
stringValue: '{"hello":"world"}',
})
})
it('should pack null', () => {
expect(PackPrimitive(null)).toEqual({
kind: Kind.PRIMITIVE_KIND_NULL,
})
})
})