A / superagent-mocker

Pretty simple in-browser mocks for CRUD and REST API
132 stars 32 forks source link

Request Headers are lowercased #24

Open LeopoldoFu opened 8 years ago

LeopoldoFu commented 8 years ago

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');
    });

});