-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.test.js
36 lines (31 loc) · 906 Bytes
/
index.test.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
const nock = require('nock');
const core = require('@actions/core');
const action = require('./lib');
test('returns expired and expiration date', async () => {
// Given
const inputs = {
'api-key': 'test-key',
name: 'opt',
ext: 'nc',
};
jest.spyOn(core, 'getInput').mockImplementation(n => inputs[n]);
const setOutput = jest.spyOn(core, 'setOutput');
nock('https://domaine-nc.p.rapidapi.com', {
reqheaders: {
'x-rapidapi-host': 'domaine-nc.p.rapidapi.com',
'x-rapidapi-key': 'test-key',
},
})
.get('/opt/nc')
.reply(200, {
expired: false,
dateExpiration: '2021-12-28',
nbDaysBeforeExpires: 45,
});
// When
await action();
// Then
expect(setOutput).toBeCalledWith('expired', false);
expect(setOutput).toBeCalledWith('expirationDate', '2021-12-28');
expect(setOutput).toBeCalledWith('daysBeforeExpiration', 45);
});