Skip to content

Commit

Permalink
Failing tests for accessing snapshot data with multiple paths
Browse files Browse the repository at this point in the history
  • Loading branch information
rhodgkins committed Oct 15, 2018
1 parent 8d26314 commit fb7ef54
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions test/unit/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ describe('DataSnapshot', function () {
expect(child.val()).to.equal('val');
});

it('uses child data starting with /', function () {
var parent = new Snapshot(ref, {key: 'val'});
var child = parent.child('/key');
expect(child.val()).to.equal('val');
});

it('uses child data ending with /', function () {
var parent = new Snapshot(ref, {key: 'val'});
var child = parent.child('key/');
expect(child.val()).to.equal('val');
});

it('uses child data for false values', function () {
var parent = new Snapshot(ref, {key: false});
var child = parent.child('key');
Expand All @@ -75,6 +87,24 @@ describe('DataSnapshot', function () {
expect(child.val()).to.equal(0);
});

it('uses child data when accessing with multiple paths', function () {
var parent = new Snapshot(ref, { key: { value: 'val' }});
var child = parent.child('key/value');
expect(child.val()).to.equal('val');
});

it('uses child data when accessing with multiple paths for false values', function () {
var parent = new Snapshot(ref, { key: { value: false }});
var child = parent.child('key/value');
expect(child.val()).to.equal(false);
});

it('uses child data when accessing with multiple paths for 0 values', function () {
var parent = new Snapshot(ref, { key: { value: 0 }});
var child = parent.child('key/value');
expect(child.val()).to.equal(0);
});

it('uses null when there is no child data', function () {
var parent = new Snapshot(ref);
var child = parent.child('key');
Expand Down Expand Up @@ -137,6 +167,24 @@ describe('DataSnapshot', function () {
expect(snapshot.hasChild('bar')).to.equal(false);
});

it('tests for the key starting with /', function () {
var snapshot = new Snapshot(ref, {foo: 'bar'});
expect(snapshot.hasChild('/foo')).to.equal(true);
expect(snapshot.hasChild('/bar')).to.equal(false);
});

it('tests for the key ending with /', function () {
var snapshot = new Snapshot(ref, {foo: 'bar'});
expect(snapshot.hasChild('foo/')).to.equal(true);
expect(snapshot.hasChild('bar/')).to.equal(false);
});

it('tests for the key with multiple paths', function () {
var snapshot = new Snapshot(ref, {key: {foo: 'bar'}});
expect(snapshot.hasChild('key/foo')).to.equal(true);
expect(snapshot.hasChild('key/bar')).to.equal(false);
});

});

describe('#hasChildren', function () {
Expand Down

0 comments on commit fb7ef54

Please sign in to comment.