-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from yahoo/multi-protect
Prevent multiple copies of express-state from overwriting `expose()`
- Loading branch information
Showing
5 changed files
with
113 additions
and
10 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
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
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 |
---|---|---|
|
@@ -45,6 +45,7 @@ | |
"express3-handlebars": "*", | ||
"istanbul" : "*", | ||
"mocha" : "*", | ||
"mockery" : "*", | ||
"xunit-file" : "*" | ||
}, | ||
|
||
|
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 @@ | ||
/* global describe, it, beforeEach, afterEach */ | ||
'use strict'; | ||
|
||
var expect = require('chai').expect, | ||
mockery = require('mockery'); | ||
|
||
describe('multiple', function () { | ||
beforeEach(function () { | ||
mockery.enable({ | ||
useCleanCache : true, | ||
warnOnReplace : false, | ||
warnOnUnregistered: false | ||
}); | ||
|
||
mockery.registerMock('express', { | ||
application: {}, | ||
response : {} | ||
}); | ||
}); | ||
|
||
afterEach(function () { | ||
mockery.disable(); | ||
}); | ||
|
||
it('should not override `expose()` if it exists', function () { | ||
var expose = function () {}, | ||
express, state; | ||
|
||
express = require('express'); | ||
express.application.expose = express.response.expose = expose; | ||
state = require('../'); | ||
|
||
expect(express.application.expose).to.equal(expose); | ||
expect(express.response.expose).to.equal(expose); | ||
}); | ||
}); |
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