Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request Headers are lowercased #24

Open
LeopoldoFu opened this issue Feb 3, 2016 · 0 comments
Open

Request Headers are lowercased #24

LeopoldoFu opened this issue Feb 3, 2016 · 0 comments

Comments

@LeopoldoFu
Copy link
Contributor

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

});
@A A self-assigned this Feb 4, 2016
@A A removed their assignment Apr 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants