Skip to content

Commit

Permalink
add failing test for isomorphic-fetch and basicAuth
Browse files Browse the repository at this point in the history
  • Loading branch information
unstubbable committed Feb 9, 2017
1 parent 8f20a6d commit d8b6d62
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion tests/test_isomorphic_fetch.js
Expand Up @@ -32,7 +32,7 @@ test("string-based reqheaders match works", function(t) {
get('/path2').
reply(200, 'somemoardata');

fetch('http://isomorphicfetchland.com/path2', {
return fetch('http://isomorphicfetchland.com/path2', {
headers: {
'header': 'header value',
}
Expand All @@ -49,3 +49,30 @@ test("string-based reqheaders match works", function(t) {
throw err;
});
});

test("basicAuth match works", function (t) {
var scope = nock('http://isomorphicfetchland.com').
get('/path2').
basicAuth({
user: 'username',
pass: 'password'
}).
reply(200, 'somemoardata');

return fetch('http://isomorphicfetchland.com/path2', {
headers: {
'Authorization': 'Basic ' + new Buffer('username:password').toString('base64'),
}
}).
then(function (res) {
return res.text();
}).
then(function (text) {
scope.done();
t.equal(text, 'somemoardata', "response should match");
t.end();
}).
catch(function (err) {
throw err;
});
});

0 comments on commit d8b6d62

Please sign in to comment.