mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	test: utils.params
This commit is contained in:
		| @@ -662,7 +662,7 @@ | ||||
| 					if (!hash[key]) { | ||||
| 						hash[key] = value; | ||||
| 					} else { | ||||
| 						if (!$.isArray(hash[key])) { | ||||
| 						if (!Array.isArray(hash[key])) { | ||||
| 							hash[key] = [hash[key]]; | ||||
| 						} | ||||
| 						hash[key].push(value); | ||||
|   | ||||
| @@ -318,6 +318,14 @@ describe('Utility Methods', () => { | ||||
| 		done(); | ||||
| 	}); | ||||
|  | ||||
| 	it('should get url params as arrays', (done) => { | ||||
| 		const params = utils.params({ url: 'http://nodebb.org?foo=1&bar=test&herp[]=2&herp[]=3' }); | ||||
| 		assert.equal(params.foo, 1); | ||||
| 		assert.equal(params.bar, 'test'); | ||||
| 		assert.deepStrictEqual(params.herp, [2, 3]); | ||||
| 		done(); | ||||
| 	}); | ||||
|  | ||||
| 	it('should get a single param', (done) => { | ||||
| 		assert.equal(utils.param('somekey'), undefined); | ||||
| 		done(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user