forked from MiniProfiler/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconcurrent-async-test.js
More file actions
37 lines (30 loc) · 1.22 KB
/
concurrent-async-test.js
File metadata and controls
37 lines (30 loc) · 1.22 KB
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
'use strict';
var expect = require('chai').expect;
module.exports = function(server) {
describe('Concurrent Async Requests', function() {
before(server.setUp.bind(null, 'async'));
after(server.tearDown);
it('Each profile runs on its own context', function(done) {
let countDone = 0;
const partialDone = () => { if (++countDone === 2) done(); };
server.get('/', (err, response) => {
var ids = JSON.parse(response.headers['x-miniprofiler-ids']);
expect(ids).to.have.lengthOf(1);
server.post('/mini-profiler-resources/results/', { id: ids[0], popup: 1 }, (err, response, body) => {
var result = JSON.parse(body);
expect(result.Root.CustomTimings.async).to.have.lengthOf(2);
partialDone();
});
});
server.get('/?once=true', (err, response) => {
var ids = JSON.parse(response.headers['x-miniprofiler-ids']);
expect(ids).to.have.lengthOf(1);
server.post('/mini-profiler-resources/results/', { id: ids[0], popup: 1 }, (err, response, body) => {
var result = JSON.parse(body);
expect(result.Root.CustomTimings.async).to.have.lengthOf(1);
partialDone();
});
});
});
});
};