-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgetParams.test.ts
More file actions
96 lines (91 loc) · 2.85 KB
/
getParams.test.ts
File metadata and controls
96 lines (91 loc) · 2.85 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { Request } from 'express'
import { getParams } from './getParams'
import { expect } from '@jest/globals'
beforeEach(() => {
jest.clearAllMocks()
})
describe('getParams', () => {
it('Should return the parameters', () => {
const req = {
query: {
'search-type': 'some search-type',
'selected-words': 'some selected-words',
'excluded-words': 'some excluded-words',
taxon: 'some taxon',
person: 'some person',
'publishing-organisation': 'some publishing-organisation',
language: 'some language',
'case-sensitive': 'true',
combinator: 'some combinator',
'keyword-location': 'some keyword-location',
'publishing-application': 'some publishing-application',
'link-search-url': 'some link-search-url',
'document-type': 'some document-type',
'phone-number': 'some phone-number',
'publishing-status': 'some publishing-status',
'political-status': 'political',
government: 'some government',
},
} as unknown as Request
expect(getParams(req)).toStrictEqual({
combinator: 'some combinator',
searchType: 'some search-type',
selectedWords: 'some selected-words',
excludedWords: 'some excluded-words',
taxon: 'some taxon',
person: 'some person',
publishingOrganisation: 'some publishing-organisation',
caseSensitive: true,
documentType: 'some document-type',
keywordLocation: 'some keyword-location',
linkSearchUrl: 'some link-search-url',
phoneNumber: 'some phone-number',
publishingApplication: 'some publishing-application',
publishingStatus: 'some publishing-status',
language: 'some language',
politicalStatus: 'political',
government: 'some government',
})
})
it('Should return the parameters with empty values', () => {
const req = {
query: {
'search-type': '',
'selected-words': '',
'excluded-words': '',
taxon: '',
person: '',
'publishing-organisation': '',
language: '',
'case-sensitive': 'true',
combinator: '',
'keyword-location': '',
'publishing-application': '',
'link-search-url': '',
'document-type': '',
'publishing-status': '',
'is-political': '',
government: '',
},
} as unknown as Request
expect(getParams(req)).toStrictEqual({
publishingApplication: 'any',
caseSensitive: true,
combinator: 'all',
excludedWords: '',
linkSearchUrl: '',
phoneNumber: '',
searchType: 'keyword',
language: '',
publishingOrganisation: '',
publishingStatus: '',
taxon: '',
person: '',
selectedWords: '',
keywordLocation: 'all',
documentType: '',
politicalStatus: 'any',
government: '',
})
})
})