|
1 | 1 | var expect = require('chai').expect; |
2 | | -var server = require('./server/default'); |
3 | 2 |
|
4 | | -describe('MiniProfiler Tests', function() { |
5 | | - before(server.start); |
6 | | - after(server.stop); |
| 3 | +for (var fw of ['express', 'koa']) { |
| 4 | + var server = require(`./server/${fw}/default`); |
7 | 5 |
|
8 | | - it('Profiled routes should always return Profiler ID', function(done) { |
9 | | - server.get('/', (err, response) => { |
10 | | - expect(response.headers).to.include.keys('x-miniprofiler-ids'); |
11 | | - done(); |
12 | | - }); |
13 | | - }); |
| 6 | + describe(`[${fw}] MiniProfiler Tests`, function() { |
| 7 | + before(server.start); |
| 8 | + after(server.stop); |
14 | 9 |
|
15 | | - it('Custom timed query should be profiled', function(done) { |
16 | | - server.get('/js-sleep', (err, response) => { |
17 | | - var ids = JSON.parse(response.headers['x-miniprofiler-ids']); |
18 | | - expect(ids).to.have.lengthOf(1); |
19 | | - |
20 | | - server.post('/mini-profiler-resources/results', { id: ids[0], popup: 1 }, (err, response, body) => { |
21 | | - var result = JSON.parse(body); |
22 | | - expect(result.Id).to.equal(ids[0]); |
23 | | - expect(result.Name).to.equal('/js-sleep'); |
24 | | - expect(result.DurationMilliseconds).to.be.above(200); |
25 | | - expect(result.Root.Children).to.be.empty; |
26 | | - expect(result.Root.CustomTimings).to.have.property('custom'); |
27 | | - expect(result.Root.CustomTimings.custom).to.have.lengthOf(1); |
28 | | - |
29 | | - expect(result.Root.CustomTimings.custom[0].ExecuteType).to.be.equal('custom'); |
30 | | - expect(result.Root.CustomTimings.custom[0].CommandString).to.be.equal('Sleeping...'); |
31 | | - expect(result.Root.CustomTimings.custom[0].DurationMilliseconds).to.be.below(result.DurationMilliseconds); |
| 10 | + it('Profiled routes should always return Profiler ID', function(done) { |
| 11 | + server.get('/', (err, response) => { |
| 12 | + expect(response.headers).to.include.keys('x-miniprofiler-ids'); |
32 | 13 | done(); |
33 | 14 | }); |
34 | 15 | }); |
35 | 16 |
|
36 | | - }); |
| 17 | + it('Custom timed query should be profiled', function(done) { |
| 18 | + server.get('/js-sleep', (err, response) => { |
| 19 | + var ids = JSON.parse(response.headers['x-miniprofiler-ids']); |
| 20 | + expect(ids).to.have.lengthOf(1); |
37 | 21 |
|
38 | | -}); |
| 22 | + server.post('/mini-profiler-resources/results', { id: ids[0], popup: 1 }, (err, response, body) => { |
| 23 | + var result = JSON.parse(body); |
| 24 | + expect(result.Id).to.equal(ids[0]); |
| 25 | + expect(result.Name).to.equal('/js-sleep'); |
| 26 | + expect(result.DurationMilliseconds).to.be.above(200); |
| 27 | + expect(result.Root.Children).to.be.empty; |
| 28 | + expect(result.Root.CustomTimings).to.have.property('custom'); |
| 29 | + expect(result.Root.CustomTimings.custom).to.have.lengthOf(1); |
| 30 | + |
| 31 | + expect(result.Root.CustomTimings.custom[0].ExecuteType).to.be.equal('custom'); |
| 32 | + expect(result.Root.CustomTimings.custom[0].CommandString).to.be.equal('Sleeping...'); |
| 33 | + expect(result.Root.CustomTimings.custom[0].DurationMilliseconds).to.be.below(result.DurationMilliseconds); |
| 34 | + done(); |
| 35 | + }); |
| 36 | + }); |
| 37 | + |
| 38 | + }); |
| 39 | + |
| 40 | + }); |
| 41 | +} |
0 commit comments