Skip to content

Commit a00ad92

Browse files
authored
revert datasnapshot (#1156)
1 parent 139e1d9 commit a00ad92

File tree

2 files changed

+46
-195
lines changed

2 files changed

+46
-195
lines changed

spec/v1/providers/database.spec.ts

Lines changed: 9 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -639,52 +639,17 @@ describe('Database Functions', () => {
639639
expect(subject.val()).to.equal(0);
640640
populate({ myKey: 0 });
641641
expect(subject.val()).to.deep.equal({ myKey: 0 });
642+
643+
// Null values are still reported as null.
644+
populate({ myKey: null });
645+
expect(subject.val()).to.deep.equal({ myKey: null });
642646
});
643647

644648
// Regression test: .val() was returning array of nulls when there's a property called length (BUG#37683995)
645649
it('should return correct values when data has "length" property', () => {
646650
populate({ length: 3, foo: 'bar' });
647651
expect(subject.val()).to.deep.equal({ length: 3, foo: 'bar' });
648652
});
649-
650-
it('should deal with null-values appropriately', () => {
651-
populate(null);
652-
expect(subject.val()).to.be.null;
653-
654-
populate({ myKey: null });
655-
expect(subject.val()).to.be.null;
656-
});
657-
658-
it('should deal with empty object values appropriately', () => {
659-
populate({});
660-
expect(subject.val()).to.be.null;
661-
662-
populate({ myKey: {} });
663-
expect(subject.val()).to.be.null;
664-
665-
populate({ myKey: { child: null } });
666-
expect(subject.val()).to.be.null;
667-
});
668-
669-
it('should deal with empty array values appropriately', () => {
670-
populate([]);
671-
expect(subject.val()).to.be.null;
672-
673-
populate({ myKey: [] });
674-
expect(subject.val()).to.be.null;
675-
676-
populate({ myKey: [null] });
677-
expect(subject.val()).to.be.null;
678-
679-
populate({ myKey: [{}] });
680-
expect(subject.val()).to.be.null;
681-
682-
populate({ myKey: [{ myKey: null }] });
683-
expect(subject.val()).to.be.null;
684-
685-
populate({ myKey: [{ myKey: {} }] });
686-
expect(subject.val()).to.be.null;
687-
});
688653
});
689654

690655
describe('#child(): DataSnapshot', () => {
@@ -711,37 +676,14 @@ describe('Database Functions', () => {
711676
});
712677

713678
it('should be false for a non-existent value', () => {
714-
populate({ a: { b: 'c', nullChild: null } });
679+
populate({ a: { b: 'c' } });
715680
expect(subject.child('d').exists()).to.be.false;
716-
expect(subject.child('nullChild').exists()).to.be.false;
717681
});
718682

719683
it('should be false for a value pathed beyond a leaf', () => {
720684
populate({ a: { b: 'c' } });
721685
expect(subject.child('a/b/c').exists()).to.be.false;
722686
});
723-
724-
it('should be false for an empty object value', () => {
725-
populate({ a: {} });
726-
expect(subject.child('a').exists()).to.be.false;
727-
728-
populate({ a: { child: null } });
729-
expect(subject.child('a').exists()).to.be.false;
730-
731-
populate({ a: { child: {} } });
732-
expect(subject.child('a').exists()).to.be.false;
733-
});
734-
735-
it('should be false for an empty array value', () => {
736-
populate({ a: [] });
737-
expect(subject.child('a').exists()).to.be.false;
738-
739-
populate({ a: [null] });
740-
expect(subject.child('a').exists()).to.be.false;
741-
742-
populate({ a: [{}] });
743-
expect(subject.child('a').exists()).to.be.false;
744-
});
745687
});
746688

747689
describe('#forEach(action: (a: DataSnapshot) => boolean): boolean', () => {
@@ -770,17 +712,6 @@ describe('Database Functions', () => {
770712

771713
expect(subject.forEach(counter)).to.equal(false);
772714
expect(count).to.eq(0);
773-
774-
populate({
775-
a: 'foo',
776-
nullChild: null,
777-
emptyObjectChild: {},
778-
emptyArrayChild: [],
779-
});
780-
count = 0;
781-
782-
expect(subject.forEach(counter)).to.equal(false);
783-
expect(count).to.eq(1);
784715
});
785716

786717
it('should cancel further enumeration if callback returns true', () => {
@@ -820,51 +751,13 @@ describe('Database Functions', () => {
820751

821752
describe('#numChildren()', () => {
822753
it('should be key count for objects', () => {
823-
populate({
824-
a: 'b',
825-
c: 'd',
826-
nullChild: null,
827-
emptyObjectChild: {},
828-
emptyArrayChild: [],
829-
});
754+
populate({ a: 'b', c: 'd' });
830755
expect(subject.numChildren()).to.eq(2);
831756
});
832757

833758
it('should be 0 for non-objects', () => {
834759
populate(23);
835760
expect(subject.numChildren()).to.eq(0);
836-
837-
populate({
838-
nullChild: null,
839-
emptyObjectChild: {},
840-
emptyArrayChild: [],
841-
});
842-
expect(subject.numChildren()).to.eq(0);
843-
});
844-
});
845-
846-
describe('#hasChildren()', () => {
847-
it('should true for objects', () => {
848-
populate({
849-
a: 'b',
850-
c: 'd',
851-
nullChild: null,
852-
emptyObjectChild: {},
853-
emptyArrayChild: [],
854-
});
855-
expect(subject.hasChildren()).to.be.true;
856-
});
857-
858-
it('should be false for non-objects', () => {
859-
populate(23);
860-
expect(subject.hasChildren()).to.be.false;
861-
862-
populate({
863-
nullChild: null,
864-
emptyObjectChild: {},
865-
emptyArrayChild: [],
866-
});
867-
expect(subject.hasChildren()).to.be.false;
868761
});
869762
});
870763

@@ -876,17 +769,9 @@ describe('Database Functions', () => {
876769
});
877770

878771
it('should return false if a child is missing', () => {
879-
populate({
880-
a: 'b',
881-
nullChild: null,
882-
emptyObjectChild: {},
883-
emptyArrayChild: [],
884-
});
772+
populate({ a: 'b' });
885773
expect(subject.hasChild('c')).to.be.false;
886774
expect(subject.hasChild('a/b')).to.be.false;
887-
expect(subject.hasChild('nullChild')).to.be.false;
888-
expect(subject.hasChild('emptyObjectChild')).to.be.false;
889-
expect(subject.hasChild('emptyArrayChild')).to.be.false;
890775
});
891776
});
892777

@@ -916,21 +801,11 @@ describe('Database Functions', () => {
916801

917802
describe('#toJSON(): Object', () => {
918803
it('should return the current value', () => {
919-
populate({
920-
a: 'b',
921-
nullChild: null,
922-
emptyObjectChild: {},
923-
emptyArrayChild: [],
924-
});
804+
populate({ a: 'b' });
925805
expect(subject.toJSON()).to.deep.equal(subject.val());
926806
});
927807
it('should be stringifyable', () => {
928-
populate({
929-
a: 'b',
930-
nullChild: null,
931-
emptyObjectChild: {},
932-
emptyArrayChild: [],
933-
});
808+
populate({ a: 'b' });
934809
expect(JSON.stringify(subject)).to.deep.equal('{"a":"b"}');
935810
});
936811
});

0 commit comments

Comments
 (0)