This repository has been archived by the owner on Oct 28, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from elmerbulthuis/master
include deepkit
- Loading branch information
Showing
8 changed files
with
812 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
Oops, something went wrong.