Skip to content

Commit

Permalink
feat(lens.spec): Add the lens array length test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Miller committed Oct 11, 2017
1 parent 930df38 commit d4b9e6a
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions src/lens.spec.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { idLens } from "./lens";

const testObj = {
a: {
b: {
c: "d",
},
e: "f",
},
g: "h",
};
const testLens = idLens<typeof testObj>();
const deepLens = testLens.thenKey("a").thenKey("b").thenKey("c");

describe("with deep lens and object", () => {

const testObj = {
a: {
b: {
c: "d",
},
e: "f",
},
g: "h",
};
const testLens = idLens<typeof testObj>();
const deepLens = testLens.thenKey("a").thenKey("b").thenKey("c");

test("get a value deep", () => {
expect(deepLens.get(testObj)).toBe("d");
});
Expand Down Expand Up @@ -41,3 +41,14 @@ describe("with deep lens and object", () => {

});
});

describe("with array", () => {

const testObj = [0, 1];
const testLens = idLens<typeof testObj>();
const deepLens = testLens.thenKey("length");

test("get a length from list", () => {
expect(deepLens.get(testObj)).toBe(2);
});
});

0 comments on commit d4b9e6a

Please sign in to comment.