-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix recycling values that are not set
- Loading branch information
1 parent
540d84c
commit 1f8da1b
Showing
2 changed files
with
33 additions
and
4 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,29 @@ | ||
import { assert } from 'chai' | ||
import Alt from '../' | ||
import sinon from 'sinon' | ||
|
||
export default { | ||
'Recycling': { | ||
'recycles a store with no initial state'() { | ||
const alt = new Alt() | ||
const actions = alt.generateActions('fire') | ||
|
||
const store = alt.createStore(function () { | ||
this.bindAction(actions.fire, () => { | ||
this.test = (this.test || 0) + 1 | ||
}) | ||
}, 'Store') | ||
|
||
|
||
assert(Object.keys(store.getState()).length === 0, 'store has no state') | ||
actions.fire() | ||
|
||
assert(store.getState().test === 1, 'store has some state') | ||
|
||
alt.recycle() | ||
|
||
assert(Object.keys(store.getState()).length === 0, 'store was emptied') | ||
assert.isUndefined(store.getState().test, 'store was recycled to initial state') | ||
}, | ||
} | ||
} |