aca2e4f968
* test: add pre-change snapshot of new-window event * move to .ts file for easier diff * refactor: improve feature string parsing logic * test: update snapshots * update type names per review * update comma-separated parse test * use for loop instead of reduce per review * tighten up types * avoid variable guest contents id returnValue in test snapshot
21 lines
995 B
TypeScript
21 lines
995 B
TypeScript
import { expect } from 'chai';
|
|
|
|
describe('feature-string parsing', () => {
|
|
it('is indifferent to whitespace around keys and values', () => {
|
|
const { parseCommaSeparatedKeyValue } = require('../lib/common/parse-features-string');
|
|
const checkParse = (string: string, parsed: Record<string, string | boolean>) => {
|
|
const features = parseCommaSeparatedKeyValue(string, true).parsed;
|
|
expect(features).to.deep.equal(parsed);
|
|
};
|
|
checkParse('a=yes,c=d', { a: true, c: 'd' });
|
|
checkParse('a=yes ,c=d', { a: true, c: 'd' });
|
|
checkParse('a=yes, c=d', { a: true, c: 'd' });
|
|
checkParse('a=yes , c=d', { a: true, c: 'd' });
|
|
checkParse(' a=yes , c=d', { a: true, c: 'd' });
|
|
checkParse(' a= yes , c=d', { a: true, c: 'd' });
|
|
checkParse(' a = yes , c=d', { a: true, c: 'd' });
|
|
checkParse(' a = yes , c =d', { a: true, c: 'd' });
|
|
checkParse(' a = yes , c = d', { a: true, c: 'd' });
|
|
checkParse(' a = yes , c = d ', { a: true, c: 'd' });
|
|
});
|
|
});
|