|
| 1 | +const perfrep = require('.'); |
| 2 | + |
| 3 | +describe('notate', async() => { |
| 4 | + it('Should return numeric results in percent (between 0 and 100)', async() => { |
| 5 | + const {cpu, memory, heap} = await perfrep(); |
| 6 | + |
| 7 | + expect(cpu).to.be.at.least(0); |
| 8 | + expect(cpu).to.be.at.most(100); |
| 9 | + expect(memory).to.be.at.least(0); |
| 10 | + expect(memory).to.be.at.most(100); |
| 11 | + expect(heap).to.be.at.least(0); |
| 12 | + expect(heap).to.be.at.most(100); |
| 13 | + }); |
| 14 | + it('Should take about a second', async() => { |
| 15 | + let cpu, memory, heap; |
| 16 | + async function results() { |
| 17 | + const results = await perfrep(); |
| 18 | + cpu = results.cpu; |
| 19 | + memory = results.memory; |
| 20 | + heap = results.heap; |
| 21 | + } |
| 22 | + |
| 23 | + expect(cpu).to.not.be.a('number'); |
| 24 | + expect(memory).to.not.be.a('number'); |
| 25 | + expect(heap).to.not.be.a('number'); |
| 26 | + |
| 27 | + results(); |
| 28 | + |
| 29 | + expect(cpu).to.not.be.a('number'); |
| 30 | + expect(memory).to.not.be.a('number'); |
| 31 | + expect(heap).to.not.be.a('number'); |
| 32 | + |
| 33 | + await sleep(100); |
| 34 | + |
| 35 | + expect(cpu).to.not.be.a('number'); |
| 36 | + expect(memory).to.not.be.a('number'); |
| 37 | + expect(heap).to.not.be.a('number'); |
| 38 | + |
| 39 | + await sleep(1000); |
| 40 | + |
| 41 | + expect(cpu).to.be.a('number'); |
| 42 | + expect(memory).to.be.a('number'); |
| 43 | + expect(heap).to.be.a('number'); |
| 44 | + }); |
| 45 | +}); |
0 commit comments