Skip to content

Commit

Permalink
improve zipper tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joshgoebel authored and SleeplessByte committed Dec 16, 2020
1 parent 77f4761 commit 9524afe
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions exercises/zipper/zipper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,36 @@ describe('Zipper', () => {
zipper = Zipper.fromTree(t1);
});

test('left returns a new Zipper', () => {
let left = zipper.left();
expect(left).not.toBe(zipper)
})

test('right returns a new Zipper', () => {
let right = zipper.right();
expect(right).not.toBe(zipper)
})

test('setValue returns a new Zipper', () => {
let anotherZipper = zipper.setValue(99);
expect(anotherZipper).not.toBe(zipper)
})

test('setRight returns a new Zipper', () => {
let right = zipper.setRight(bt(55,null,null));
expect(right).not.toBe(zipper)
})

test('setLeft returns a new Zipper', () => {
let left = zipper.setLeft(bt(55,null,null));
expect(left).not.toBe(zipper)
})

test('up returns a new Zipper', () => {
let up = zipper.right().up();
expect(zipper).not.toBe(up)
})

test('data is retained', () => {
expect(zipper.toTree()).toEqual(t1);
});
Expand Down

0 comments on commit 9524afe

Please sign in to comment.