forked from 2BAD/bitrix
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.unit.test.ts
68 lines (57 loc) · 1.62 KB
/
index.unit.test.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
/* tslint-env jest */
// tslint:disable: no-expression-statement object-literal-sort-keys
import Statuses from '.'
const mockCall = jest.fn(() => Promise.resolve()) as any
const mockList = jest.fn(() => Promise.resolve()) as any
const statuses = Statuses({ call: mockCall })
const ID = '77'
describe('Statuses', () => {
beforeEach(() => {
mockCall.mockClear()
mockList.mockClear()
})
it('should expose API methods', () => {
expect(statuses).toMatchSnapshot()
})
describe('`create`', () => {
it('should invoke `call`', async () => {
await statuses.create({
NAME: 'Test name'
})
expect(mockCall.mock.calls).toMatchSnapshot()
})
})
describe('`get`', () => {
it('should invoke `call`', async () => {
await statuses.get(ID)
expect(mockCall.mock.calls).toMatchSnapshot()
})
})
describe('`list`', () => {
it('should invoke `call`', async () => {
await statuses.list({
order: { NAME: 'ASC' },
filter: { ENTITY_ID: 'STATUS' }
})
expect(mockCall.mock.calls).toMatchSnapshot()
})
it('should work without optional params', async () => {
await statuses.list()
expect(mockCall.mock.calls).toMatchSnapshot()
})
})
describe('`update`', () => {
it('should invoke `call`', async () => {
await statuses.update(ID, {
NAME: 'Test name'
})
expect(mockCall.mock.calls).toMatchSnapshot()
})
it('should work without optional params', async () => {
await statuses.update(ID, {
NAME: 'Test name'
})
expect(mockCall.mock.calls).toMatchSnapshot()
})
})
})