-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathPerson.test.js
More file actions
100 lines (87 loc) · 2.59 KB
/
Person.test.js
File metadata and controls
100 lines (87 loc) · 2.59 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
97
98
99
100
import { authReducerInit, beforeAllAsync } from 'Plugins/auth-server/__tests__/api/setup.test'
import { combineReducers } from '@reduxjs/toolkit'
import authReducer from 'Redux/features/authSlice'
import { expectSaga } from 'redux-saga-test-plan'
import { log } from 'console'
import {
getAttributes,
addAttribute,
editAttribute,
deleteAttribute,
} from 'Plugins/schema/redux/sagas/AttributeSaga'
import {
initialState as attributeInitState,
reducer as attributeReducer,
} from 'Plugins/schema/redux/features/attributeSlice'
let initialState
const formInitState = (token, issuer) => {
initialState = {
authReducer: authReducerInit(token, issuer),
attributeReducer: attributeInitState,
}
}
beforeAll(async () => {
try {
await beforeAllAsync(formInitState)
} catch (error) {
log(error.message)
}
})
const rootReducer = combineReducers({
authReducer,
attributeReducer,
})
const payload = {
jansHideOnDiscovery: false,
selected: false,
scimCustomAttr: false,
oxMultiValuedAttribute: false,
custom: false,
requred: false,
attributeValidation: {
maxLength: null,
regexp: null,
minLength: null,
},
name: 'test',
displayName: 'test',
description: 'test',
status: 'active',
dataType: 'string',
editType: ['admin'],
viewType: ['admin'],
usageType: ['openid'],
maxLength: null,
minLength: null,
regexp: null,
}
describe('perform CRUD for schema person module', () => {
let attribute
it('should call attributes endpoint', async () => {
const result = await expectSaga(getAttributes, { payload: { options: {} } })
.withReducer(rootReducer, initialState)
.silentRun(false)
expect(result.returnValue instanceof Error).toBe(false)
})
it('should create new person', async () => {
const result = await expectSaga(addAttribute, { payload: { data: payload } })
.withReducer(rootReducer, initialState)
.silentRun(false)
attribute = result.returnValue
expect(result.returnValue instanceof Error).toBe(false)
})
it('should edit newly created person', async () => {
const result = await expectSaga(editAttribute, {
payload: { data: { ...attribute, displayName: 'update_test' } },
})
.withReducer(rootReducer, initialState)
.silentRun(false)
expect(result.returnValue instanceof Error).toBe(false)
})
it('should delete newly created person', async () => {
const result = await expectSaga(deleteAttribute, { payload: { inum: attribute.inum } })
.withReducer(rootReducer, initialState)
.silentRun(false)
expect(result.returnValue instanceof Error).toBe(false)
})
})