1 回答

TA貢獻(xiàn)1805條經(jīng)驗(yàn) 獲得超10個(gè)贊
這是因?yàn)槟愕牡诙€(gè)提交函數(shù)調(diào)用是在 Promise then 方法內(nèi)部。
您需要等待 users.actions.list()。
例如:
beforeEach(() => {
commit = sinon.spy();
// Note: add users_response here.
sinon.stub(api.users, "list").resolves(users_response);
});
// Use async here.
it("should list users", async () => {
// Use await here.
await users.actions.list({ commit }, { page, itemsPerPage });
expect(commit).to.have.been.calledWith("UNSET_ERROR");
// Note: expect with property data, because called with: users.data.
expect(commit).to.have.been.calledWith("GET_PAGINATED", users_response.data);
});
添加回答
舉報(bào)