forked from capricorn86/happy-dom
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [capricorn86#1315] Implement the getSetCookie method of Headers
- Loading branch information
ushiboy
committed
Mar 16, 2024
1 parent
8b2eb74
commit d774b93
Showing
5 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
packages/happy-dom/test/cookie/urilities/CookieStringUtility.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import CookieStringUtility from '../../../src/cookie/urilities/CookieStringUtility.js'; | ||
import { describe, it, expect } from 'vitest'; | ||
|
||
describe('CookieStringUtility', () => { | ||
describe('splitCookiesString()', () => { | ||
it('Should parse empty string.', () => { | ||
expect(CookieStringUtility.splitCookiesString('')).toEqual([]); | ||
}); | ||
|
||
it('Should parse single cookie without params.', () => { | ||
expect(CookieStringUtility.splitCookiesString('key=value')).toEqual(['key=value']); | ||
}); | ||
|
||
it('Should parse single cookie with params.', () => { | ||
expect( | ||
CookieStringUtility.splitCookiesString( | ||
'key=value; HttpOnly; Path=/; Expires=Fri, 01 Jan 2100 00:00:00 GMT' | ||
) | ||
).toEqual(['key=value; HttpOnly; Path=/; Expires=Fri, 01 Jan 2100 00:00:00 GMT']); | ||
}); | ||
|
||
it('Should parse multiple cookies without params.', () => { | ||
expect(CookieStringUtility.splitCookiesString('key1=value1, key2=value2')).toEqual([ | ||
'key1=value1', | ||
'key2=value2' | ||
]); | ||
}); | ||
|
||
it('Should parse multiple cookies with params.', () => { | ||
expect( | ||
CookieStringUtility.splitCookiesString( | ||
'key1=value1; HttpOnly; Path=/; Expires=Fri, 01 Jan 2100 00:00:00 GMT, key2=value2; Domain=example.com; Max-Age=1' | ||
) | ||
).toEqual([ | ||
'key1=value1; HttpOnly; Path=/; Expires=Fri, 01 Jan 2100 00:00:00 GMT', | ||
'key2=value2; Domain=example.com; Max-Age=1' | ||
]); | ||
}); | ||
|
||
it('Should parse multiple cookies including those with and without params.', () => { | ||
expect( | ||
CookieStringUtility.splitCookiesString( | ||
'key1=value1, key2=value2; Expires=Fri, 01 Jan 2100 00:00:00 GMT; Path=/' | ||
) | ||
).toEqual(['key1=value1', 'key2=value2; Expires=Fri, 01 Jan 2100 00:00:00 GMT; Path=/']); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters