diff options
author | 2023-06-06 15:11:47 +0000 | |
---|---|---|
committer | 2023-06-06 15:11:47 +0000 | |
commit | a1144f7fec0cb93eb1fd549beb9f5bc91ee1f485 (patch) | |
tree | 1451b4462c572b88d409faa2e2a01439012afcf3 /packages/integrations/node/test/createOutgoingHttpHeaders.test.js | |
parent | 4929332c3210d1634b8607c7736d9049860a2079 (diff) | |
download | astro-a1144f7fec0cb93eb1fd549beb9f5bc91ee1f485.tar.gz astro-a1144f7fec0cb93eb1fd549beb9f5bc91ee1f485.tar.zst astro-a1144f7fec0cb93eb1fd549beb9f5bc91ee1f485.zip |
[ci] format
Diffstat (limited to 'packages/integrations/node/test/createOutgoingHttpHeaders.test.js')
-rw-r--r-- | packages/integrations/node/test/createOutgoingHttpHeaders.test.js | 128 |
1 files changed, 63 insertions, 65 deletions
diff --git a/packages/integrations/node/test/createOutgoingHttpHeaders.test.js b/packages/integrations/node/test/createOutgoingHttpHeaders.test.js index 1876c9a00..2f7063b1c 100644 --- a/packages/integrations/node/test/createOutgoingHttpHeaders.test.js +++ b/packages/integrations/node/test/createOutgoingHttpHeaders.test.js @@ -3,76 +3,74 @@ import { expect } from 'chai'; import { createOutgoingHttpHeaders } from '../dist/createOutgoingHttpHeaders.js'; describe('createOutgoingHttpHeaders', () => { + it('undefined input headers', async () => { + const result = createOutgoingHttpHeaders(undefined); + expect(result).to.equal(undefined); + }); - it('undefined input headers', async () => { - const result = createOutgoingHttpHeaders(undefined); - expect(result).to.equal(undefined); - }); + it('null input headers', async () => { + const result = createOutgoingHttpHeaders(undefined); + expect(result).to.equal(undefined); + }); - it('null input headers', async () => { - const result = createOutgoingHttpHeaders(undefined); - expect(result).to.equal(undefined); - }); + it('Empty Headers', async () => { + const headers = new Headers(); + const result = createOutgoingHttpHeaders(headers); + expect(result).to.equal(undefined); + }); - it('Empty Headers', async () => { - const headers = new Headers(); - const result = createOutgoingHttpHeaders(headers); - expect(result).to.equal(undefined); - }); + it('Headers with single key', async () => { + const headers = new Headers(); + headers.append('x-test', 'hello world'); + const result = createOutgoingHttpHeaders(headers); + expect(result).to.deep.equal({ 'x-test': 'hello world' }); + }); - it('Headers with single key', async () => { - const headers = new Headers(); - headers.append('x-test', 'hello world'); - const result = createOutgoingHttpHeaders(headers); - expect(result).to.deep.equal({ 'x-test': 'hello world' }); - }); + it('Headers with multiple keys', async () => { + const headers = new Headers(); + headers.append('x-test1', 'hello'); + headers.append('x-test2', 'world'); + const result = createOutgoingHttpHeaders(headers); + expect(result).to.deep.equal({ 'x-test1': 'hello', 'x-test2': 'world' }); + }); - it('Headers with multiple keys', async () => { - const headers = new Headers(); - headers.append('x-test1', 'hello'); - headers.append('x-test2', 'world'); - const result = createOutgoingHttpHeaders(headers); - expect(result).to.deep.equal({ 'x-test1': 'hello', 'x-test2': 'world' }); - }); + it('Headers with multiple values (not set-cookie)', async () => { + const headers = new Headers(); + headers.append('x-test', 'hello'); + headers.append('x-test', 'world'); + const result = createOutgoingHttpHeaders(headers); + expect(result).to.deep.equal({ 'x-test': 'hello, world' }); + }); - it('Headers with multiple values (not set-cookie)', async () => { - const headers = new Headers(); - headers.append('x-test', 'hello'); - headers.append('x-test', 'world'); - const result = createOutgoingHttpHeaders(headers); - expect(result).to.deep.equal({ 'x-test': 'hello, world' }); - }); + it('Headers with multiple values (set-cookie special case)', async () => { + const headers = new Headers(); + headers.append('set-cookie', 'hello'); + headers.append('set-cookie', 'world'); + const result = createOutgoingHttpHeaders(headers); + expect(result).to.deep.equal({ 'set-cookie': ['hello', 'world'] }); + }); - it('Headers with multiple values (set-cookie special case)', async () => { - const headers = new Headers(); - headers.append('set-cookie', 'hello'); - headers.append('set-cookie', 'world'); - const result = createOutgoingHttpHeaders(headers); - expect(result).to.deep.equal({ 'set-cookie': ['hello', 'world'] }); - }); + it('Headers with multiple values (set-cookie case handling)', async () => { + const headers = new Headers(); + headers.append('Set-cookie', 'hello'); + headers.append('Set-Cookie', 'world'); + const result = createOutgoingHttpHeaders(headers); + expect(result).to.deep.equal({ 'set-cookie': ['hello', 'world'] }); + }); - it('Headers with multiple values (set-cookie case handling)', async () => { - const headers = new Headers(); - headers.append('Set-cookie', 'hello'); - headers.append('Set-Cookie', 'world'); - const result = createOutgoingHttpHeaders(headers); - expect(result).to.deep.equal({ 'set-cookie': ['hello', 'world'] }); - }); - - it('Headers with all use cases', async () => { - const headers = new Headers(); - headers.append('x-single', 'single'); - headers.append('x-triple', 'one'); - headers.append('x-triple', 'two'); - headers.append('x-triple', 'three'); - headers.append('Set-cookie', 'hello'); - headers.append('Set-Cookie', 'world'); - const result = createOutgoingHttpHeaders(headers); - expect(result).to.deep.equal({ - 'x-single': 'single', - 'x-triple': 'one, two, three', - 'set-cookie': ['hello', 'world'], - }); - }); - -});
\ No newline at end of file + it('Headers with all use cases', async () => { + const headers = new Headers(); + headers.append('x-single', 'single'); + headers.append('x-triple', 'one'); + headers.append('x-triple', 'two'); + headers.append('x-triple', 'three'); + headers.append('Set-cookie', 'hello'); + headers.append('Set-Cookie', 'world'); + const result = createOutgoingHttpHeaders(headers); + expect(result).to.deep.equal({ + 'x-single': 'single', + 'x-triple': 'one, two, three', + 'set-cookie': ['hello', 'world'], + }); + }); +}); |