1 | var test = require('tape')
|
2 | var stringify = require('../')
|
3 |
|
4 | test('stringify', function (t) {
|
5 | t.is(stringify({
|
6 | a: 1,
|
7 | b: 2
|
8 | }), 'a=1&b=2', 'should stringify simple objects')
|
9 | t.is(stringify({
|
10 | nested: {
|
11 | a: {
|
12 | b: {
|
13 | c: 'd'
|
14 | }
|
15 | }
|
16 | }
|
17 | }), 'nested[a][b][c]=d', 'should nest objects using [xyz] syntax')
|
18 | t.is(stringify({
|
19 | 'key&value': 'key=value'
|
20 | }), 'key%26value=key%3Dvalue', 'should URL encode')
|
21 | t.is(stringify({
|
22 | object: {
|
23 | xyz: 'hello'
|
24 | },
|
25 | array: [0, 1, 2]
|
26 | }), 'object[xyz]=hello&array[0]=0&array[1]=1&array[2]=2', 'should encode arrays')
|
27 | t.end()
|
28 | })
|