Skip to content

Commit 57fcc6b

Browse files
zlodagdavideast
authored andcommitted
Added unit tests to demonstrate bug fix
1 parent 1c182b1 commit 57fcc6b

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/database/firebase_list_factory.spec.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,43 @@ describe('FirebaseListFactory', () => {
563563
ref.push('in-the-zone');
564564
});
565565
});
566+
567+
describe('Removing and replacing a child key', () => {
568+
const firstKey = 'index1';
569+
const middleKey = 'index2';
570+
const lastKey = 'index3';
571+
const initialData = {
572+
[firstKey]: true,
573+
[middleKey]: true,
574+
[lastKey]: true,
575+
};
576+
let keyToRemove: string;
577+
578+
afterEach((done: any) => {
579+
subscription = questions
580+
.skip(2)
581+
.take(1)
582+
.subscribe((items: any[]) => {
583+
expect(items.length).toBe(3);
584+
done();
585+
}, done.fail);
586+
questions.$ref.ref.set(initialData)
587+
.then(() => ref.child(keyToRemove).remove())
588+
.then(() => ref.child(keyToRemove).set(true));
589+
});
590+
591+
it('should work with the first item in the list', () => {
592+
keyToRemove = firstKey;
593+
});
594+
595+
it('should work with the middle item in the list', () => {
596+
keyToRemove = middleKey;
597+
});
598+
599+
it('should work with the last item in the list', () => {
600+
keyToRemove = lastKey;
601+
});
602+
});
566603
});
567604
});
568605

0 commit comments

Comments
 (0)