The headers in the request object passed into the callback for get or post mocks are getting lower-cased. While generally speaking, http headers are case-insensitive, it may actually matter for some http handling implementations.
import {default as request} from 'superagent';
import superagentMocker from 'superagent-mocker';
describe('making an api call', function() {
beforeEach(function(done) {
const mock = this.mock = superagentMocker(request);
const data = this.data = {
someDataProp: 'data!'
};
mock.get('/api/some-url', (req) => {
// req.headers keys are all lowercased. They should not be
this.request = req;
return {body: data};
});
const promise = getData();
promise.then(() => done()).catch(done);
});
it('should have correct headers', function() {
expect(this.request).to.have.deep.property('headers.Authorization', 'Bearer some token');
});
});
The headers in the request object passed into the callback for
get
orpost
mocks are getting lower-cased. While generally speaking, http headers are case-insensitive, it may actually matter for some http handling implementations.