Skip to content

Commit

Permalink
improve zipper tests (exercism#839)
Browse files Browse the repository at this point in the history
* improve zipper tests

Co-authored-by: Derk-Jan Karrenbeld <[email protected]>
  • Loading branch information
joshgoebel and SleeplessByte authored Dec 24, 2020
1 parent 5696d8c commit 536eda4
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions exercises/zipper/zipper.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Zipper } from './zipper';

// Tests adapted from `problem-specifications/zipper/canonical-data.json` @ v1.0.0

function bt(value, left, right) {
return {
value,
Expand Down Expand Up @@ -74,4 +72,34 @@ describe('Zipper', () => {
xtest('setValue on deep focus', () => {
expect(zipper.left().right().setValue(5).toTree()).toEqual(t6);
});

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

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

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

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

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

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

0 comments on commit 536eda4

Please sign in to comment.