-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a4d7dec
commit ebc0c37
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* eslint-env node, mocha */ | ||
|
||
var assert = require('assert'); | ||
|
||
function clearRequireCache() { | ||
Object.keys(require.cache).forEach(function(key) { | ||
delete require.cache[key]; | ||
}); | ||
} | ||
|
||
describe('express', function() { | ||
beforeEach(clearRequireCache); | ||
describe('timings', function() { | ||
it('uses server-timings middleware when enableServerTimings is true', function() { | ||
var hopsConfig = require('hops-config'); | ||
hopsConfig.enableServerTimings = true; | ||
var hopsExpressTimings = require('hops-express').utils.timings; | ||
var res = { locals: {} }; | ||
var req = {}; | ||
|
||
hopsExpressTimings(req, res, function() {}); | ||
assert(typeof res.locals.timings.start('foo') !== 'undefined'); | ||
}); | ||
|
||
it('uses noop timings middleware when enableServerTimings is false', function() { | ||
var hopsConfig = require('hops-config'); | ||
hopsConfig.enableServerTimings = false; | ||
var hopsExpressTimings = require('hops-express').utils.timings; | ||
var res = { locals: {} }; | ||
var req = {}; | ||
|
||
hopsExpressTimings(req, res, function() {}); | ||
assert(typeof res.locals.timings.start('foo') === 'undefined'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters