internal-spec.js 978 B

1234567891011121314151617181920212223
  1. const chai = require('chai')
  2. const { expect } = chai
  3. describe('feature-string parsing', () => {
  4. it('is indifferent to whitespace around keys and values', () => {
  5. const parseFeaturesString = require('@electron/internal/common/parse-features-string')
  6. const checkParse = (string, parsed) => {
  7. const features = {}
  8. parseFeaturesString(string, (k, v) => { features[k] = v })
  9. expect(features).to.deep.equal(parsed)
  10. }
  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. checkParse(' a = yes , c = d', { a: true, c: 'd' })
  20. checkParse(' a = yes , c = d ', { a: true, c: 'd' })
  21. })
  22. })