Blame view

node_modules/canonical-json/test/index.js 641 Bytes
f7563de62   Palak Handa   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
  
  var assert = require('assert')
  
  var testModule = function(moduleName) {
    describe('stringify in module ' + moduleName, function() {
      var stringify = require('../' + moduleName)
      it('should output objects with sorted keys', function() {
        var object1 = [{a: 1, b: 2, c: 3, d: {c: 1, a: 2}}, 2]
        var object2 = [{d: {a: 2, c: 1}, b: 2, a: 1, c: 3}, 2]
  
        var json1 = stringify(object1)
        var json2 = stringify(object2)
        var expected = '[{"a":1,"b":2,"c":3,"d":{"a":2,"c":1}},2]'
        assert.deepEqual(json1, expected)
        assert.deepEqual(json2, expected)
      })
    })
  }
  
  testModule('index')
  testModule('index2')