https://github.com/angular/angular
Raw File
Tip revision: 257a30d7b394867be59dbdaf56cfe8e572c02fb8 authored by Dylan Hunn on 01 December 2021, 21:04:18 UTC
release: cut the v13.0.3 release (#44332)
Tip revision: 257a30d
cookie_spec.ts
/**
 * @license
 * Copyright Google LLC All Rights Reserved.
 *
 * 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
 */



/**
 * @license
 * Copyright Google LLC All Rights Reserved.
 *
 * 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
 */

import {parseCookieValue} from '@angular/common/src/cookie';

{
  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');
    });
  });
}
back to top