forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchart-summary.test.js
More file actions
61 lines (54 loc) · 2.06 KB
/
Copy pathchart-summary.test.js
File metadata and controls
61 lines (54 loc) · 2.06 KB
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
import { GraphQLDate } from 'graphql-scalars'
import { chartSummaryType } from '../chart-summary'
import { categorizedSummaryType } from '../categorized-summary'
describe('given the summary category gql object', () => {
describe('testing its field definitions', () => {
it('has a date field', () => {
const demoType = chartSummaryType.getFields()
expect(demoType).toHaveProperty('date')
expect(demoType.date.type).toMatchObject(GraphQLDate)
})
it('has a https field', () => {
const demoType = chartSummaryType.getFields()
expect(demoType).toHaveProperty('https')
expect(demoType.https.type).toMatchObject(categorizedSummaryType)
})
it('has a dmarc field', () => {
const demoType = chartSummaryType.getFields()
expect(demoType).toHaveProperty('dmarc')
expect(demoType.dmarc.type).toMatchObject(categorizedSummaryType)
})
})
describe('testing the field resolvers', () => {
describe('testing the date resolver', () => {
it('returns the resolved value', () => {
const demoType = chartSummaryType.getFields()
expect(demoType.date.resolve({ date: '2021-01-01' })).toEqual('2021-01-01')
})
})
describe('testing the https resolver', () => {
it('returns the resolved value', () => {
const demoType = chartSummaryType.getFields()
expect(demoType.https.resolve({ https: { pass: 1, fail: 0, total: 1 } })).toEqual({
categories: [
{ name: 'pass', count: 1, percentage: 100 },
{ name: 'fail', count: 0, percentage: 0 },
],
total: 1,
})
})
})
describe('testing the percentage resolver', () => {
it('returns the resolved value', () => {
const demoType = chartSummaryType.getFields()
expect(demoType.dmarc.resolve({ dmarc: { pass: 1, fail: 0, total: 1 } })).toEqual({
categories: [
{ name: 'pass', count: 1, percentage: 100 },
{ name: 'fail', count: 0, percentage: 0 },
],
total: 1,
})
})
})
})
})