-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathspec.js
45 lines (36 loc) · 1.11 KB
/
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
const perfrep = require('.');
describe('notate', async() => {
it('Should return numeric results in percent (between 0 and 100)', async() => {
const { cpu, memory, heap } = await perfrep();
expect(cpu).to.be.at.least(0);
expect(cpu).to.be.at.most(100);
expect(memory).to.be.at.least(0);
expect(memory).to.be.at.most(100);
expect(heap).to.be.at.least(0);
expect(heap).to.be.at.most(100);
});
it('Should take about a second', async() => {
let cpu, memory, heap;
async function results() {
const results = await perfrep();
cpu = results.cpu;
memory = results.memory;
heap = results.heap;
}
expect(cpu).to.not.be.a('number');
expect(memory).to.not.be.a('number');
expect(heap).to.not.be.a('number');
results();
expect(cpu).to.not.be.a('number');
expect(memory).to.not.be.a('number');
expect(heap).to.not.be.a('number');
await wait(100);
expect(cpu).to.not.be.a('number');
expect(memory).to.not.be.a('number');
expect(heap).to.not.be.a('number');
await wait(1000);
expect(cpu).to.be.a('number');
expect(memory).to.be.a('number');
expect(heap).to.be.a('number');
});
});