katowulf / mockfirebase

Firebase mock library for writing unit tests (experimental)
157 stars 40 forks source link

Nodes with values set to null should not be created #95

Open ginovva320 opened 8 years ago

ginovva320 commented 8 years ago

I'm running across this issue with both set and update. If part of the submitted data contains a new node whose value is null, the mock data returned includes that node when it should not. Here's a sample test to demonstrate:

test/unit/firebase.js:

describe('#set', function () {
    beforeEach(function () {
      ref.autoFlush();
    });

    it('should not create children which have null values', function() {
      var dataToSet = {
          a: 'test',
          f: null
        },
        dataToExpect = {
          a: 'test'
        };

      ref.set(dataToSet);

      expect(ref.getData()).to.deep.equal(dataToExpect);
    });
});

output:

1) MockFirebase #set should not create children which have null values:

      AssertionError: expected { a: 'test', f: null } to deeply equal { a: 'test' }
      + expected - actual

       {
         "a": "test"
      -  "f": [null]
       }