Skip to content

adding tests for when _loaded is not defined or returns falsy #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 25, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions test/crud-store.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ TestCrudConfig = CrudConfig()

ExtendedConfig =
_loaded: (obj, id) ->
nested : obj
nested : obj unless obj.doNotModify

exports:
testExtendedStore : ()->
testExtendedStore : () ->

extendConfig(ExtendedConfig, new CrudConfig())
{actions: ExtendedActions, store: ExtendedStore} = makeSimpleStore(ExtendedConfig)
Expand Down Expand Up @@ -131,8 +132,25 @@ describe 'CRUD Store', ->
expect(ExtendedStore.testExtendedStore).to.be.a('function')


it 'should change what is loaded if _loaded function is defined', ->
it 'should not change what is loaded if _loaded function is undefined', ->
id = 0
storeObj = {hello: 'bar'}
CrudActions.loaded(storeObj, id)
expect(CrudActions._loaded).to.be.undefined
expect(CrudStore.get(id)).to.deep.equal(storeObj)


it 'should change what is loaded if _loaded function is defined and returns', ->
id = 0
nestedStore = {hello: 'bar'}
ExtendedActions.loaded(nestedStore, id)
expect(ExtendedConfig._loaded(nestedStore, id)).to.not.be.undefined
expect(ExtendedStore.get(id).nested).to.deep.equal(nestedStore)


it 'should not change what is loaded if _loaded function returns falsy', ->
id = 0
storeObj = {hello: 'bar', doNotModify: true}
ExtendedActions.loaded(storeObj, id)
expect(ExtendedConfig._loaded(storeObj, id)).to.be.undefined
expect(ExtendedStore.get(id)).to.deep.equal(storeObj)