parse-features-string-spec.ts 975 B

12345678910111213141516171819202122
  1. import { expect } from 'chai';
  2. import { parseCommaSeparatedKeyValue } from '../lib/browser/parse-features-string';
  3. describe('feature-string parsing', () => {
  4. it('is indifferent to whitespace around keys and values', () => {
  5. const checkParse = (string: string, parsed: Record<string, string | boolean>) => {
  6. const features = parseCommaSeparatedKeyValue(string);
  7. expect(features).to.deep.equal(parsed);
  8. };
  9. checkParse('a=yes,c=d', { a: true, c: 'd' });
  10. checkParse('a=yes ,c=d', { a: true, c: 'd' });
  11. checkParse('a=yes, c=d', { a: true, c: 'd' });
  12. checkParse('a=yes , c=d', { a: true, c: 'd' });
  13. checkParse(' a=yes , c=d', { a: true, c: 'd' });
  14. checkParse(' a= yes , c=d', { a: true, c: 'd' });
  15. checkParse(' a = yes , c=d', { a: true, c: 'd' });
  16. checkParse(' a = yes , c =d', { a: true, c: 'd' });
  17. checkParse(' a = yes , c = d', { a: true, c: 'd' });
  18. checkParse(' a = yes , c = d ', { a: true, c: 'd' });
  19. });
  20. });