Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve zipper tests #839

Merged
merged 3 commits into from
Dec 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
});
});