-
Notifications
You must be signed in to change notification settings - Fork 3
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 #18 from unexpectedjs/feature/injectIntoCompoundAs…
…sertion with http recorded and injected: Support injecting into a compound assertion
- Loading branch information
Showing
6 changed files
with
178 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/*global describe, it, beforeEach, afterEach*/ | ||
var http = require('http'); | ||
var expect = require('unexpected'); | ||
|
||
describe('example with http recorded and injected file', function () { | ||
expect = expect.clone() | ||
.use(require('../lib/unexpectedMitm')) | ||
.use(require('unexpected-http')); | ||
|
||
var handleRequest, | ||
server, | ||
serverAddress, | ||
serverHostname, | ||
serverUrl; | ||
beforeEach(function () { | ||
handleRequest = undefined; | ||
server = http.createServer(function (req, res) { | ||
res.sendDate = false; | ||
handleRequest(req, res); | ||
}).listen(59891); | ||
serverAddress = server.address(); | ||
serverHostname = serverAddress.address === '::' ? 'localhost' : serverAddress.address; | ||
serverUrl = 'http://' + serverHostname + ':' + serverAddress.port + '/'; | ||
}); | ||
|
||
afterEach(function () { | ||
server.close(); | ||
}); | ||
|
||
it('should record', function () { | ||
handleRequest = function (req, res) { | ||
res.statusCode = 405; | ||
res.end(); | ||
}; | ||
return expect({ | ||
url: 'GET ' + serverUrl | ||
}, 'with http mocked out', { | ||
request: { | ||
url: 'GET /', headers: { Host: '0.0.0.0:59891' }, host: '0.0.0.0', | ||
port: 59891 | ||
}, | ||
response: 405 | ||
}, 'to yield response', 405); | ||
}); | ||
}); |
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,47 @@ | ||
/*global describe, it, beforeEach, afterEach*/ | ||
var http = require('http'); | ||
var expect = require('unexpected'); | ||
|
||
describe('example with http recorded and injected file', function () { | ||
expect = expect.clone() | ||
.use(require('../lib/unexpectedMitm')) | ||
.use(require('unexpected-http')); | ||
|
||
var handleRequest, | ||
server, | ||
serverAddress, | ||
serverHostname, | ||
serverUrl; | ||
beforeEach(function () { | ||
handleRequest = undefined; | ||
server = http.createServer(function (req, res) { | ||
res.sendDate = false; | ||
handleRequest(req, res); | ||
}).listen(59891); | ||
serverAddress = server.address(); | ||
serverHostname = serverAddress.address === '::' ? 'localhost' : serverAddress.address; | ||
serverUrl = 'http://' + serverHostname + ':' + serverAddress.port + '/'; | ||
}); | ||
|
||
afterEach(function () { | ||
server.close(); | ||
}); | ||
|
||
it('should record', function () { | ||
handleRequest = function (req, res) { | ||
res.statusCode = 405; | ||
res.end(); | ||
}; | ||
return expect({ | ||
url: 'GET ' + serverUrl | ||
}, 'with http mocked out', { | ||
request: { | ||
url: 'GET /', | ||
headers: { Host: 'localhost:59891' }, | ||
host: 'localhost', | ||
port: 59891 | ||
}, | ||
response: 405 | ||
}, 'to yield response', 405); | ||
}); | ||
}); |
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,39 @@ | ||
/*global describe, it, beforeEach, afterEach*/ | ||
var http = require('http'); | ||
var expect = require('unexpected'); | ||
|
||
describe('example with http recorded and injected file', function () { | ||
expect = expect.clone() | ||
.use(require('../lib/unexpectedMitm')) | ||
.use(require('unexpected-http')); | ||
|
||
var handleRequest, | ||
server, | ||
serverAddress, | ||
serverHostname, | ||
serverUrl; | ||
beforeEach(function () { | ||
handleRequest = undefined; | ||
server = http.createServer(function (req, res) { | ||
res.sendDate = false; | ||
handleRequest(req, res); | ||
}).listen(59891); | ||
serverAddress = server.address(); | ||
serverHostname = serverAddress.address === '::' ? 'localhost' : serverAddress.address; | ||
serverUrl = 'http://' + serverHostname + ':' + serverAddress.port + '/'; | ||
}); | ||
|
||
afterEach(function () { | ||
server.close(); | ||
}); | ||
|
||
it('should record', function () { | ||
handleRequest = function (req, res) { | ||
res.statusCode = 405; | ||
res.end(); | ||
}; | ||
return expect({ | ||
url: 'GET ' + serverUrl | ||
}, 'with http recorded and injected to yield response', 405); | ||
}); | ||
}); |
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,39 @@ | ||
/*global describe, it, beforeEach, afterEach*/ | ||
var http = require('http'); | ||
var expect = require('unexpected'); | ||
|
||
describe('example with http recorded and injected file', function () { | ||
expect = expect.clone() | ||
.use(require('../lib/unexpectedMitm')) | ||
.use(require('unexpected-http')); | ||
|
||
var handleRequest, | ||
server, | ||
serverAddress, | ||
serverHostname, | ||
serverUrl; | ||
beforeEach(function () { | ||
handleRequest = undefined; | ||
server = http.createServer(function (req, res) { | ||
res.sendDate = false; | ||
handleRequest(req, res); | ||
}).listen(59891); | ||
serverAddress = server.address(); | ||
serverHostname = serverAddress.address === '::' ? 'localhost' : serverAddress.address; | ||
serverUrl = 'http://' + serverHostname + ':' + serverAddress.port + '/'; | ||
}); | ||
|
||
afterEach(function () { | ||
server.close(); | ||
}); | ||
|
||
it('should record', function () { | ||
handleRequest = function (req, res) { | ||
res.statusCode = 405; | ||
res.end(); | ||
}; | ||
return expect({ | ||
url: 'GET ' + serverUrl | ||
}, 'with http recorded and injected', 'to yield response', 405); | ||
}); | ||
}); |