Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[test] Do not use the deprecated outgoingMessage._headers property
  • Loading branch information
lpinca committed May 2, 2019
1 parent 092a822 commit fbc077b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions test/websocket.test.js
Expand Up @@ -2049,7 +2049,7 @@ describe('WebSocket', () => {

agent.addRequest = (req) => {
assert.strictEqual(
req._headers.authorization,
req.getHeader('authorization'),
`Basic ${Buffer.from(auth).toString('base64')}`
);
done();
Expand All @@ -2062,7 +2062,7 @@ describe('WebSocket', () => {
const agent = new CustomAgent();

agent.addRequest = (req) => {
assert.strictEqual(req._headers.cookie, 'foo=bar');
assert.strictEqual(req.getHeader('cookie'), 'foo=bar');
done();
};

Expand All @@ -2083,15 +2083,15 @@ describe('WebSocket', () => {

for (const [url, host] of variants) {
const ws = new WebSocket(url, options);
assert.strictEqual(ws._req._headers.host, host);
assert.strictEqual(ws._req.getHeader('host'), host);
}
});

it("doesn't add the origin header by default", (done) => {
const agent = new CustomAgent();

agent.addRequest = (req) => {
assert.strictEqual(req._headers.origin, undefined);
assert.strictEqual(req.getHeader('origin'), undefined);
done();
};

Expand All @@ -2102,7 +2102,7 @@ describe('WebSocket', () => {
const agent = new CustomAgent();

agent.addRequest = (req) => {
assert.strictEqual(req._headers.origin, 'https://example.com:8000');
assert.strictEqual(req.getHeader('origin'), 'https://example.com:8000');
done();
};

Expand All @@ -2117,7 +2117,7 @@ describe('WebSocket', () => {

agent.addRequest = (req) => {
assert.strictEqual(
req._headers['sec-websocket-origin'],
req.getHeader('sec-websocket-origin'),
'https://example.com:8000'
);
done();
Expand All @@ -2137,7 +2137,7 @@ describe('WebSocket', () => {

agent.addRequest = (req) => {
assert.strictEqual(
req._headers['sec-websocket-extensions'],
req.getHeader('sec-websocket-extensions'),
'permessage-deflate; client_max_window_bits'
);
done();
Expand All @@ -2150,7 +2150,10 @@ describe('WebSocket', () => {
const agent = new CustomAgent();

agent.addRequest = (req) => {
assert.strictEqual(req._headers['sec-websocket-extensions'], undefined);
assert.strictEqual(
req.getHeader('sec-websocket-extensions'),
undefined
);
done();
};

Expand All @@ -2169,7 +2172,7 @@ describe('WebSocket', () => {
' client_max_window_bits';

agent.addRequest = (req) => {
assert.strictEqual(req._headers['sec-websocket-extensions'], value);
assert.strictEqual(req.getHeader('sec-websocket-extensions'), value);
done();
};

Expand Down

0 comments on commit fbc077b

Please sign in to comment.