2018-11-06 23:52:06 +00:00
|
|
|
const chai = require('chai')
|
|
|
|
const { expect } = chai
|
|
|
|
|
|
|
|
describe('feature-string parsing', () => {
|
|
|
|
it('is indifferent to whitespace around keys and values', () => {
|
2019-06-02 20:03:03 +00:00
|
|
|
const parseFeaturesString = require('../lib/common/parse-features-string')
|
2018-11-06 23:52:06 +00:00
|
|
|
const checkParse = (string, parsed) => {
|
|
|
|
const features = {}
|
|
|
|
parseFeaturesString(string, (k, v) => { features[k] = v })
|
|
|
|
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' })
|
|
|
|
})
|
|
|
|
})
|