| 
									
										
										
										
											2019-08-28 13:54:42 -07:00
										 |  |  | import { expect } from 'chai' | 
					
						
							| 
									
										
										
										
											2018-11-06 15:52:06 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | describe('feature-string parsing', () => { | 
					
						
							|  |  |  |   it('is indifferent to whitespace around keys and values', () => { | 
					
						
							| 
									
										
										
										
											2019-06-02 13:03:03 -07:00
										 |  |  |     const parseFeaturesString = require('../lib/common/parse-features-string') | 
					
						
							| 
									
										
										
										
											2019-08-28 13:54:42 -07:00
										 |  |  |     const checkParse = (string: string, parsed: Record<string, string | boolean>) => { | 
					
						
							|  |  |  |       const features: Record<string, string | boolean> = {} | 
					
						
							|  |  |  |       parseFeaturesString(string, (k: string, v: any) => { features[k] = v }) | 
					
						
							| 
									
										
										
										
											2018-11-06 15:52:06 -08: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' }) | 
					
						
							|  |  |  |   }) | 
					
						
							|  |  |  | }) |