Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Commit

Permalink
Merge pull request #21 from elmerbulthuis/master
Browse files Browse the repository at this point in the history
include deepkit
  • Loading branch information
Elmer Bulthuis committed Oct 28, 2020
2 parents 97b9a31 + 19f42a8 commit ec30870
Show file tree
Hide file tree
Showing 8 changed files with 812 additions and 10 deletions.
8 changes: 0 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"@types/http-errors": "^1.6.2",
"@types/isomorphic-fetch": "0.0.35",
"@types/uuid": "^3.4.5",
"deepkit": "^1.1.0",
"http-errors": "^1.7.3",
"isomorphic-fetch": "^2.2.1",
"msecs": "^1.0.0",
Expand Down
44 changes: 44 additions & 0 deletions src/utils/deep.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import * as test from "blue-tape";
import { getIn, setIn } from "./deep";

test("getIn", async t => {
interface TestState {
t: {
[key: string]: true,
};
f: {
[key: string]: false,
};
}

const state: TestState = {
t: {
1: true,
2: true,
},
f: {
one: false,
two: false,
},
};
t.strictEqual(getIn(state, []), state);
t.strictEqual(getIn(state, ["t"]), state.t);
t.strictEqual(getIn(state, ["t", "2"]), state.t[2]);
t.strictEqual(getIn(state, ["f", "2"]), state.f[2]);
});

test("setIn", async t => {
const value: any = {};
const state: any = {};

const state1 = setIn(state, ["1", "2"], value);

t.notStrictEqual(state1, state);
t.notDeepEqual(state1, state);
t.deepEqual(state1, {
1: {
2: {},
},
});
t.strictEqual(state1[1][2], value);
});
Loading

0 comments on commit ec30870

Please sign in to comment.