update
This commit is contained in:
@@ -55,8 +55,11 @@ export const actions = {
|
||||
commit(types.default.SET_AGENT_CREATING_STATUS, true);
|
||||
try {
|
||||
const response = await AgentAPI.create(agentInfo);
|
||||
commit(types.default.ADD_AGENT, response.data);
|
||||
const agent = { ...response.data };
|
||||
delete agent.temporary_password;
|
||||
commit(types.default.ADD_AGENT, agent);
|
||||
commit(types.default.SET_AGENT_CREATING_STATUS, false);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
commit(types.default.SET_AGENT_CREATING_STATUS, false);
|
||||
throw error;
|
||||
|
||||
@@ -31,8 +31,14 @@ describe('#actions', () => {
|
||||
|
||||
describe('#create', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
axios.post.mockResolvedValue({ data: agentList[0] });
|
||||
await actions.create({ commit }, agentList[0]);
|
||||
const responseAgent = {
|
||||
...agentList[0],
|
||||
temporary_password: 'InitialPassword1!',
|
||||
};
|
||||
axios.post.mockResolvedValue({ data: responseAgent });
|
||||
const createdAgent = await actions.create({ commit }, agentList[0]);
|
||||
|
||||
expect(createdAgent).toEqual(responseAgent);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.default.SET_AGENT_CREATING_STATUS, true],
|
||||
[types.default.ADD_AGENT, agentList[0]],
|
||||
|
||||
Reference in New Issue
Block a user