mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 11:37:58 +00:00
fix: specs for labels and inboxes
This commit is contained in:
@@ -10,7 +10,19 @@ jest.mock('axios');
|
|||||||
describe('#actions', () => {
|
describe('#actions', () => {
|
||||||
describe('#get', () => {
|
describe('#get', () => {
|
||||||
it('sends correct actions if API is success', async () => {
|
it('sends correct actions if API is success', async () => {
|
||||||
axios.get.mockResolvedValue({ data: { payload: inboxList } });
|
const mockedGet = jest.fn(url => {
|
||||||
|
if (url === '/api/v1/inboxes') {
|
||||||
|
return Promise.resolve({ data: { payload: inboxList } });
|
||||||
|
}
|
||||||
|
if (url === '/api/v1/accounts//cache_keys') {
|
||||||
|
return Promise.resolve({ data: { cache_keys: { inboxes: 0 } } });
|
||||||
|
}
|
||||||
|
// Return default value or throw an error for unexpected requests
|
||||||
|
return Promise.reject(new Error('Unexpected request: ' + url));
|
||||||
|
});
|
||||||
|
|
||||||
|
axios.get = mockedGet;
|
||||||
|
|
||||||
await actions.get({ commit });
|
await actions.get({ commit });
|
||||||
expect(commit.mock.calls).toEqual([
|
expect(commit.mock.calls).toEqual([
|
||||||
[types.default.SET_INBOXES_UI_FLAG, { isFetching: true }],
|
[types.default.SET_INBOXES_UI_FLAG, { isFetching: true }],
|
||||||
|
|||||||
@@ -10,7 +10,19 @@ jest.mock('axios');
|
|||||||
describe('#actions', () => {
|
describe('#actions', () => {
|
||||||
describe('#get', () => {
|
describe('#get', () => {
|
||||||
it('sends correct actions if API is success', async () => {
|
it('sends correct actions if API is success', async () => {
|
||||||
axios.get.mockResolvedValue({ data: { payload: labelsList } });
|
const mockedGet = jest.fn(url => {
|
||||||
|
if (url === '/api/v1/labels') {
|
||||||
|
return Promise.resolve({ data: { payload: labelsList } });
|
||||||
|
}
|
||||||
|
if (url === '/api/v1/accounts//cache_keys') {
|
||||||
|
return Promise.resolve({ data: { cache_keys: { labels: 0 } } });
|
||||||
|
}
|
||||||
|
// Return default value or throw an error for unexpected requests
|
||||||
|
return Promise.reject(new Error('Unexpected request: ' + url));
|
||||||
|
});
|
||||||
|
|
||||||
|
axios.get = mockedGet;
|
||||||
|
|
||||||
await actions.get({ commit });
|
await actions.get({ commit });
|
||||||
expect(commit.mock.calls).toEqual([
|
expect(commit.mock.calls).toEqual([
|
||||||
[types.default.SET_LABEL_UI_FLAG, { isFetching: true }],
|
[types.default.SET_LABEL_UI_FLAG, { isFetching: true }],
|
||||||
|
|||||||
Reference in New Issue
Block a user