-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathindex.interface.spec.ts
131 lines (122 loc) · 3.95 KB
/
index.interface.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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
import {
BasicFilterProps,
CustomFilterProps,
CustomizeDialogProps,
SettingsDialogProps
} from './index.interface'
import {Channel, Client} from '../types'
const mockChannel: Channel = {_id: '1', name: 'Test Channel'}
const mockClient: Client = {_id: '1', name: 'Test Client'}
const basicFilterProps: BasicFilterProps = {
status: 'active',
setStatus: (value: string) => {},
searchQuery: 'test',
setSearchQuery: (value: string) => {},
channel: 'channel-1',
setChannel: (value: string) => {},
startDate: new Date(),
setStartDate: (value: Date | null) => {},
endDate: new Date(),
setEndDate: (value: Date | null) => {},
limit: 10,
setLimit: (value: number) => {},
reruns: 'none',
setReruns: (value: string) => {},
channels: [mockChannel],
fetchTransactionLogs: (timestampFilter?: string, filteredResults?: boolean) =>
Promise.resolve()
}
const customFilterProps: CustomFilterProps = {
status: 'active',
setStatus: (value: string) => {},
statusCode: 200,
setStatusCode: (value: number | null) => {},
channel: 'channel-1',
setChannel: (value: string) => {},
startDate: new Date(),
setStartDate: (value: Date | null) => {},
endDate: new Date(),
setEndDate: (value: Date | null) => {},
limit: 20,
setLimit: (value: number) => {},
reruns: 'all',
setReruns: (value: string) => {},
channels: [mockChannel],
host: 'localhost',
setHost: (value: string) => {},
port: 8080,
setPort: (value: number | null) => {},
path: '/api',
setPath: (value: string) => {},
param: 'param',
setParam: (value: string) => {},
client: 'client-1',
setClient: (value: string) => {},
clients: [mockClient],
method: 'GET',
setMethod: (value: string) => {},
fetchTransactionLogs: (timestampFilter?: string, filteredResults?: boolean) =>
Promise.resolve()
}
const customizeDialogProps: CustomizeDialogProps = {
open: true,
onClose: () => {},
onApply: () => {},
visibleFilters: {
status: true,
statusCode: true,
channel: true,
startDate: true,
endDate: true,
limit: true,
reruns: true,
host: true,
port: true,
path: true,
param: true,
client: true,
method: true
},
handleFilterVisibilityChange: (
event: React.ChangeEvent<HTMLInputElement>
) => {},
onRestoreDefaults: () => {},
isDefaultState: true
}
const settingsDialogProps: SettingsDialogProps = {
open: true,
onClose: () => {},
onApply: () => {},
openInNewTab: true,
setOpenInNewTab: (value: boolean) => {},
autoUpdate: false,
setAutoUpdate: (value: boolean) => {}
}
describe('Interface Conformance Tests', () => {
it('should conform to BasicFilterProps interface', () => {
expect(basicFilterProps.status).toBe('active')
expect(typeof basicFilterProps.setStatus).toBe('function')
expect(Array.isArray(basicFilterProps.channels)).toBe(true)
expect(basicFilterProps.channels[0]._id).toBe('1')
expect(typeof basicFilterProps.fetchTransactionLogs).toBe('function')
expect(basicFilterProps.fetchTransactionLogs()).resolves.toBe(undefined)
})
it('should conform to CustomFilterProps interface', () => {
expect(customFilterProps.statusCode).toBe(200)
expect(customFilterProps.host).toBe('localhost')
expect(customFilterProps.clients[0].name).toBe('Test Client')
expect(typeof customFilterProps.setClient).toBe('function')
expect(typeof customFilterProps.fetchTransactionLogs).toBe('function')
expect(customFilterProps.fetchTransactionLogs()).resolves.toBe(undefined)
})
it('should conform to CustomizeDialogProps interface', () => {
expect(customizeDialogProps.open).toBe(true)
expect(typeof customizeDialogProps.onClose).toBe('function')
expect(customizeDialogProps.visibleFilters.status).toBe(true)
})
it('should conform to SettingsDialogProps interface', () => {
expect(settingsDialogProps.openInNewTab).toBe(true)
expect(settingsDialogProps.autoUpdate).toBe(false)
expect(typeof settingsDialogProps.setAutoUpdate).toBe('function')
})
})