I want to test an action from the store. The action looks like this:
<code> moveRow({ dispatch, commit }, [item, i, up]) {
this.$axios
.put('/api/rows/' + (up ? 'up' : 'down'), item)
.then(({ data }) => {
[... do stuff ...]
})
}
</code>
<code> moveRow({ dispatch, commit }, [item, i, up]) {
this.$axios
.put('/api/rows/' + (up ? 'up' : 'down'), item)
.then(({ data }) => {
[... do stuff ...]
})
}
</code>
moveRow({ dispatch, commit }, [item, i, up]) {
this.$axios
.put('/api/rows/' + (up ? 'up' : 'down'), item)
.then(({ data }) => {
[... do stuff ...]
})
}
The test case looks like this:
<code>[... preparing data ...]
store.$axios = {
put: jest.fn(function () {
return { then: row}
})
}
await store.dispatch('moveRow', [row, 0, true])
[... assertions ...]
</code>
<code>[... preparing data ...]
store.$axios = {
put: jest.fn(function () {
return { then: row}
})
}
await store.dispatch('moveRow', [row, 0, true])
[... assertions ...]
</code>
[... preparing data ...]
store.$axios = {
put: jest.fn(function () {
return { then: row}
})
}
await store.dispatch('moveRow', [row, 0, true])
[... assertions ...]
But I get: TypeError: this.$axios.put(...).then is not a function
What do I need to change so the then
part can also be tested?