2017-07-13 20:22:02 -04:00
|
|
|
/**
|
|
|
|
* @license
|
2020-05-19 15:08:49 -04:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2017-07-13 20:22:02 -04:00
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2020-04-13 19:40:21 -04:00
|
|
|
* @license
|
2020-05-19 15:08:49 -04:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2020-04-13 19:40:21 -04:00
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
2017-07-13 20:22:02 -04:00
|
|
|
|
|
|
|
import {parseCookieValue} from '@angular/common/src/cookie';
|
|
|
|
import {describe, expect, it} from '@angular/core/testing/src/testing_internal';
|
|
|
|
|
2017-12-16 17:42:55 -05:00
|
|
|
{
|
2017-07-13 20:22:02 -04:00
|
|
|
describe('cookies', () => {
|
|
|
|
it('parses cookies', () => {
|
|
|
|
const cookie = 'other-cookie=false; xsrf-token=token-value; is_awesome=true; ffo=true;';
|
|
|
|
expect(parseCookieValue(cookie, 'xsrf-token')).toBe('token-value');
|
|
|
|
});
|
|
|
|
it('handles encoded keys', () => {
|
|
|
|
expect(parseCookieValue('whitespace%20token=token-value', 'whitespace token'))
|
|
|
|
.toBe('token-value');
|
|
|
|
});
|
|
|
|
it('handles encoded values', () => {
|
|
|
|
expect(parseCookieValue('token=whitespace%20', 'token')).toBe('whitespace ');
|
|
|
|
expect(parseCookieValue('token=whitespace%0A', 'token')).toBe('whitespace\n');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|