-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
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,39 @@ | ||
import _ from 'lodash'; | ||
import { createStore } from "redux"; | ||
import reduxLeaves from '../../../src'; | ||
|
||
describe("leaf.create.assign(...sources): returns an action that, when dispatched, updates the leaf's state by non-mutatively copying over properties from the sources", () => { | ||
|
||
describe("Documentation example 1", () => { | ||
|
||
describe("GIVEN initial state, reducer, actions and store as in example", () => { | ||
const initialState = { | ||
foo: { props: true } | ||
} | ||
|
||
const [reducer, actions] = reduxLeaves(initialState) | ||
let store | ||
|
||
beforeEach(() => store = createStore(reducer)) | ||
|
||
test("THEN store initialises with initialState", () => { | ||
expect(store.getState()).toEqual(initialState) | ||
}) | ||
|
||
describe("WHEN we dispatch actions.foo.create.asObject.assign({ string: 'foo' })", () => { | ||
beforeEach(() => { | ||
store.dispatch(actions.foo.create.asObject.assign({ string: 'foo' })) | ||
}) | ||
|
||
test("THEN store state.foo updates to { props: true, string: 'foo' }", () => { | ||
expect(store.getState()).toEqual({ | ||
foo: { props: true, string: 'foo' } | ||
}) | ||
}) | ||
|
||
}) | ||
}) | ||
|
||
|
||
}) | ||
}) |
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
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