Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
community
pount
pount-front
Commits
6bb80138
Commit
6bb80138
authored
Oct 05, 2021
by
Jean Rabreau
Browse files
✅
loadItem load now template if not specify otherwise
parent
4a2daeee
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/unit/store/community.spec.js
View file @
6bb80138
...
...
@@ -49,17 +49,28 @@ describe('store/community', () => {
})
})
describe
(
'
loadItem
'
,
()
=>
{
beforeEach
(
async
()
=>
{
getStub
.
resolves
({
data
:
{
id
:
objectId
}})
await
store
.
dispatch
(
'
community/loadItem
'
,
objectId
)
})
it
(
'
should get item detail
'
,
()
=>
{
it
(
'
should get item detail
'
,
async
()
=>
{
getStub
.
resolves
({
data
:
{
id
:
objectId
}})
await
store
.
dispatch
(
'
community/loadItem
'
,
{
itemId
:
objectId
,
withTemplate
:
false
})
expect
(
getStub
.
calledOnce
,
'
api call
'
).
to
.
be
.
true
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
)
})
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
'
,
()
=>
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment