cookie-parser.spec.js 937 B

1234567891011121314151617181920212223242526
  1. import {expect} from '../chai.js';
  2. import {CookieParser} from './cookie-parser.js';
  3. describe('CookieParser', function () {
  4. describe('parse', function () {
  5. it('returns cookie parameters', function () {
  6. const parser = new CookieParser();
  7. const value = 'pkg=math; equation=E%3Dmc%5E2';
  8. const result = parser.parse({url: '', headers: {cookie: value}});
  9. expect(result).to.have.property('pkg', 'math');
  10. expect(result).to.have.property('equation', 'E=mc^2');
  11. });
  12. it('returns an empty object if no cookies', function () {
  13. const parser = new CookieParser();
  14. const result = parser.parse({url: '', headers: {}});
  15. expect(result).to.be.eql({});
  16. });
  17. it('returns an empty object for an empty string', function () {
  18. const parser = new CookieParser();
  19. const result = parser.parse({url: '', headers: {cookie: ''}});
  20. expect(result).to.be.eql({});
  21. });
  22. });
  23. });