viruschidai / diff-json

A javascript object diff tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tests are failing

0x80 opened this issue · comments

I'm getting the following output if I run npm run test

      ✓ should return correct diff for object with embedded array object that does not have key specified
      ✓ should return correct diff for object with embedded array that has key specified
    applyChanges()
      1) should transfer oldObj to newObj with changeset
      ✓ should transfer oldObj to newObj with changesetWithoutEmbeddedKey
    revertChanges()
      ✓ should transfer newObj to oldObj with changeset
      ✓ should transfer newObj to oldObj with changesetWithoutEmbeddedKey


  5 passing (20ms)
  1 failing

  1) changesets
       applyChanges()
         should transfer oldObj to newObj with changeset:

      Error: expected { name: 'smith',
  nested: { inner: 2 },
  date: Mon, 13 Oct 2014 09:13:00 GMT,
  coins: [ 2, 5, 1 ],
  toys: [],
  pets: [],
  children:
   [ { name: 'kid1', age: 0, subset: [Object] },
     { name: 'kid2', age: 2 },
     { name: 'kid3', age: 3 } ],
  mixed: '10' } to sort of equal { name: 'smith',
  mixed: '10',
  nested: { inner: 2 },
  date: Mon, 13 Oct 2014 09:13:00 GMT,
  coins: [ 2, 5, 1 ],
  toys: [],
  pets: [],
  children:
   [ { name: 'kid3', age: 3 },
     { name: 'kid1', age: 0, subset: [Object] },
     { name: 'kid2', age: 2 } ] }
      + expected - actual

       {
         "children": [
           {
      +      "age": 3
      +      "name": "kid3"
      +    }
      +    {
             "age": 0
             "name": "kid1"
             "subset": [
               {
--
           {
             "age": 2
             "name": "kid2"
           }
      -    {
      -      "age": 3
      -      "name": "kid3"
      -    }
         ]
         "coins": [
           2
           5

      at Assertion.assert (node_modules/expect.js/index.js:96:13)
      at Assertion.eql (node_modules/expect.js/index.js:230:10)
      at Context.<anonymous> (test/changesets.coffee:143:25)
      at processImmediate (internal/timers.js:464:21)


It seems to be just the order of the items in the array

Screenshot 2021-12-05 at 12 17 32