-
Notifications
You must be signed in to change notification settings - Fork 17
/
cashback.test.ts
50 lines (39 loc) · 1.35 KB
/
cashback.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
import { payPayRestSDK } from "../src/lib/paypay-rest-sdk";
import { httpsClient } from '../src/lib/httpsClient';
const { v4: uuidv4 } = require('uuid');
const conf = {
clientId: 'test',
clientSecret: 'test',
merchantId: 'test',
productionMode: false
};
payPayRestSDK.configure(conf);
test('Unit Test - Cash Back', async () => {
const payload = {
"merchantCashbackId": uuidv4(),
"userAuthorizationId": "testId",
"amount": {
"amount": 1,
"currency": "JPY"
},
"requestedAt": 1609749559,
"orderDescription": "order description",
"walletType": "CASHBACK",
"expiryDate": '2021-07-31',
"metadata": ""
}
const response = {
"resultInfo": { "code": "REQUEST_ACCEPTED", "message": "Request accepted", "codeId": "08100001" },
"data": null,
}
const mockHttpsCall = jest.spyOn(httpsClient, 'httpsCall');
mockHttpsCall.mockImplementation(jest.fn((_options: any, _payload = '', _callback: any) => {
_callback(response);
}));
await payPayRestSDK.cashBack(payload, (result: any) => {
expect(result).toEqual(response);
});
expect(mockHttpsCall).toHaveBeenCalledTimes(1);
expect(mockHttpsCall).toHaveBeenCalledWith(expect.anything(), payload, expect.anything());
mockHttpsCall.mockClear();
});