blob: 05627f8ed0e6526d97dc454c8e7a33a06985aad3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import MockAdapter from 'axios-mock-adapter';
import testAction from 'helpers/vuex_action_helper';
import { TEST_HOST } from 'helpers/test_constants';
import axios from '~/lib/utils/axios_utils';
import * as actions from '~/ide/stores/modules/clientside/actions';
const TEST_PROJECT_URL = `${TEST_HOST}/lorem/ipsum`;
const TEST_USAGE_URL = `${TEST_PROJECT_URL}/usage_ping/web_ide_clientside_preview`;
describe('IDE store module clientside actions', () => {
let rootGetters;
let mock;
beforeEach(() => {
rootGetters = {
currentProject: {
web_url: TEST_PROJECT_URL,
},
};
mock = new MockAdapter(axios);
});
afterEach(() => {
mock.restore();
});
describe('pingUsage', () => {
it('posts to usage endpoint', (done) => {
const usageSpy = jest.fn(() => [200]);
mock.onPost(TEST_USAGE_URL).reply(() => usageSpy());
testAction(actions.pingUsage, null, rootGetters, [], [], () => {
expect(usageSpy).toHaveBeenCalled();
done();
});
});
});
});
|