2020-03-20 20:28:31 +00:00
|
|
|
import { expect } from 'chai';
|
2018-11-06 23:52:06 +00:00
|
|
|
|
|
|
|
describe('feature-string parsing', () => {
|
|
|
|
it('is indifferent to whitespace around keys and values', () => {
|
2020-04-21 20:23:00 +00:00
|
|
|
const { parseCommaSeparatedKeyValue } = require('../lib/common/parse-features-string');
|
2019-08-28 20:54:42 +00:00
|
|
|
const checkParse = (string: string, parsed: Record<string, string | boolean>) => {
|
2020-04-21 20:23:00 +00:00
|
|
|
const features = parseCommaSeparatedKeyValue(string, true).parsed;
|
2020-03-20 20:28:31 +00:00
|
|
|
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' });
|
|
|
|
});
|
|
|
|
});
|