-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move up path name logic, add cookie util test
- Loading branch information
1 parent
a8022c5
commit 7061657
Showing
4 changed files
with
49 additions
and
28 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
21 changes: 21 additions & 0 deletions
21
app/scripts/components/common/cookie-consent/utils.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,21 @@ | ||
import { readCookie, COOKIE_CONSENT_KEY } from './utils'; | ||
|
||
describe('onCookie', () => { | ||
let cookieValue; | ||
beforeEach(() => { | ||
cookieValue = { responded: false, answer: false }; | ||
// Mutating docmument cookie property for test | ||
// eslint-disable-next-line fp/no-mutating-methods | ||
Object.defineProperty(window.document, 'cookie', { | ||
writable: true, | ||
value: `CookieConsent={"responded":true,"answer":false}; _somethingelse=GS1.1.17303800; ${COOKIE_CONSENT_KEY}=${JSON.stringify( | ||
cookieValue | ||
)}` | ||
}); | ||
}); | ||
|
||
it('should parse cookie value correctly', () => { | ||
const cookieJsonVal = readCookie(COOKIE_CONSENT_KEY); | ||
expect(JSON.parse(cookieJsonVal)).toMatchObject(cookieValue); | ||
}); | ||
}); |
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