mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
test: utils.params
This commit is contained in:
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user