test: utils.params

isekai-main
Barış Soner Uşaklı 3 years ago
parent f72af319fb
commit 7b99dc46eb

@ -662,7 +662,7 @@
if (!hash[key]) { if (!hash[key]) {
hash[key] = value; hash[key] = value;
} else { } else {
if (!$.isArray(hash[key])) { if (!Array.isArray(hash[key])) {
hash[key] = [hash[key]]; hash[key] = [hash[key]];
} }
hash[key].push(value); hash[key].push(value);

@ -318,6 +318,14 @@ describe('Utility Methods', () => {
done(); 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) => { it('should get a single param', (done) => {
assert.equal(utils.param('somekey'), undefined); assert.equal(utils.param('somekey'), undefined);
done(); done();

Loading…
Cancel
Save