Commit 6bb80138 authored by Jean Rabreau's avatar Jean Rabreau
Browse files

loadItem load now template if not specify otherwise

parent 4a2daeee
...@@ -49,17 +49,28 @@ describe('store/community', () => { ...@@ -49,17 +49,28 @@ describe('store/community', () => {
}) })
}) })
describe('loadItem', () => { describe('loadItem', () => {
beforeEach(async () => { it('should get item detail', async () => {
getStub.resolves({data: { id: objectId }}) getStub.resolves({data: { id: objectId}})
await store.dispatch('community/loadItem', objectId) await store.dispatch('community/loadItem', { itemId: objectId, withTemplate: false})
})
it('should get item detail', () => {
expect(getStub.calledOnce, 'api call').to.be.true expect(getStub.calledOnce, 'api call').to.be.true
expect(getStub.firstCall.args[0]).to.equal(`items/${objectId}/`, 'url check') expect(getStub.firstCall.args[0]).to.equal(`items/${objectId}/`, 'url check')
}) })
it('should load item with received data', () => { it('should load item with received data', async () => {
getStub.resolves({data: { id: objectId}})
await store.dispatch('community/loadItem', { itemId: objectId, withTemplate: false})
expect(store.getters['community/currentItem'].id).to.equal(objectId) expect(store.getters['community/currentItem'].id).to.equal(objectId)
}) })
it('should load template with received templateId if not specify', async () => {
const templateId = "xx"
const dispatchSpy = sinon.spy(store, 'dispatch')
getStub.resolves({data: { id: objectId, set: { templateId } }})
await store.dispatch('community/loadItem', { itemId: objectId})
expect(dispatchSpy.calledTwice, 'extra dispatch').to.be.true
const [action, param] = dispatchSpy.secondCall.args
dispatchSpy.restore()
expect(action).to.equal('community/loadTemplate', 'action check')
expect(param).to.equal(templateId, 'payload check')
})
}) })
}) })
describe('lists', () => { describe('lists', () => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment