[SignalingServer] Optimize dependent modules
[platform/framework/web/wrtjs.git] / device_home / node_modules / parseqs / test.js
1 var assert = require('better-assert');
2 var expect = require('expect.js');
3 var util = require('./index.js');
4
5 describe('querystring test suite', function(){
6         it('should parse a querystring and return an object', function () {
7                 
8                 // Single assignment
9                 var queryObj = util.decode("foo=bar");
10                 expect(queryObj.foo).to.be("bar");
11                 
12                 // Multiple assignments
13                 queryObj = util.decode("france=paris&germany=berlin");
14                 expect(queryObj.france).to.be("paris");
15                 expect(queryObj.germany).to.be("berlin");
16                 
17                 // Assignments containing non-alphanumeric characters
18                 queryObj = util.decode("india=new%20delhi");
19                 expect(queryObj.india).to.be("new delhi");
20         });
21         
22         it('should construct a query string from an object', function () {
23                 expect(util.encode({ a: 'b' })).to.be('a=b');
24                 expect(util.encode({ a: 'b', c: 'd' })).to.be('a=b&c=d');
25                 expect(util.encode({ a: 'b', c: 'tobi rocks' })).to.be('a=b&c=tobi%20rocks');
26         });
27 });