This repository has been archived by the owner on Feb 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.unit.js
82 lines (69 loc) · 1.95 KB
/
client.unit.js
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
const cadujs = require('../src/client')
const fs = require('fs')
const certPriv = fs.readFileSync(`${__dirname}/middlewares/utils/mytestkey.pem`)
describe('Create client', () => {
test("should have property 'adapters'", () => {
expect(cadujs.adapters).toBeDefined()
})
test("should have property 'connect'", () => {
expect(cadujs.connect).toBeDefined()
})
test('when try connect without config', () => {
expect(() => cadujs.connect())
.toThrow()
})
test('when try connectKycProxy without config', () => {
expect(() => cadujs.connectKycProxy())
.toThrow()
})
test("when try connect without 'privateKey'", () => {
expect(() => cadujs.connect({
environment: 'sandbox',
clientId: 'client_id',
userAgent: 'user_agent',
}))
.toThrow()
})
test("when try connect without 'clientId'", () => {
expect(() => cadujs.connect({
environment: 'sandbox',
privateKey: certPriv,
userAgent: 'user_agent',
}))
.toThrow()
})
test("when try connect without 'userAgent'", () => {
expect(() => cadujs.connect({
environment: 'sandbox',
privateKey: certPriv,
clientId: 'client_id',
}))
.toThrow()
})
test("when try connect without 'environment'", () => {
expect(() => cadujs.connect({
privateKey: certPriv,
clientId: 'client_id',
userAgent: 'user_agent',
}))
.toThrow()
})
test('when try connect with correct values', () => {
const client = cadujs.connect({
environment: 'sandbox',
privateKey: certPriv,
clientId: 'client_id',
userAgent: 'user_agent',
})
expect(client).toBeInstanceOf(Object)
})
test('when try connectKycProxy with correct values', () => {
const client = cadujs.connectKycProxy({
environment: 'sandbox',
privateKey: certPriv,
clientId: 'client_id',
userAgent: 'user_agent',
})
expect(client).toBeInstanceOf(Object)
})
})