-
Notifications
You must be signed in to change notification settings - Fork 128
/
Copy pathindex.spec.js
60 lines (45 loc) · 2.06 KB
/
index.spec.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
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
const axios = require("axios");
const MockAdapter = require("axios-mock-adapter");
const lambda = require("./index.js");
const _taskCount = 30;
describe("#SEND METRICS", () => {
it('should return "200" on a send metrics success for simple test', async () => {
let mock = new MockAdapter(axios);
mock.onPost().reply(200, {});
let response = await lambda.send({ taskCount: _taskCount, testType: "simple" });
expect(response).toEqual(200);
});
it('should return "200" on a send metrics success for zip JMeter test', async () => {
let mock = new MockAdapter(axios);
mock.onPost().reply(200, {});
let response = await lambda.send({ taskCount: _taskCount, testType: "jmter", fileType: "zip" });
expect(response).toEqual(200);
});
it('should return "200" on a send metrics success for script JMeter test', async () => {
let mock = new MockAdapter(axios);
mock.onPost().reply(200, {});
let response = await lambda.send({ taskCount: _taskCount, testType: "jemter" });
expect(response).toEqual(200);
});
it('should return "200" on a send metrics success for zip K6 test', async () => {
let mock = new MockAdapter(axios);
mock.onPost().reply(200, {});
let response = await lambda.send({ taskCount: _taskCount, testType: "k6", fileType: "zip" });
expect(response).toEqual(200);
});
it('should return "200" on a send metrics success for script K6 test', async () => {
let mock = new MockAdapter(axios);
mock.onPost().reply(200, {});
let response = await lambda.send({ taskCount: _taskCount, testType: "k6" });
expect(response).toEqual(200);
});
it('should return "Network Error" on connection timedout', async () => {
let mock = new MockAdapter(axios);
mock.onPut().networkError();
await lambda.send({ taskCount: _taskCount, testType: "simple" }).catch((err) => {
expect(err.toString()).toEqual("TypeError: Cannot read properties of undefined (reading 'status')");
});
});
});