@webitel/ui-sdk 3.2.134 → 3.2.135

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webitel/ui-sdk",
3
- "version": "3.2.134",
3
+ "version": "3.2.135",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve-lib": "vue-cli-service serve",
@@ -1,28 +1,24 @@
1
1
  import { AgentServiceApiFactory } from 'webitel-sdk';
2
- import installOptionsRepository from '../../../_install/InstallOptionsRepository';
3
2
 
4
- let apiService;
3
+ const AgentStatusAPIFactory = ({ instance, OpenAPIConfig }) => {
4
+ const service = new AgentServiceApiFactory(OpenAPIConfig, '', instance);
5
5
 
6
- const createApiService = () => apiService = new AgentServiceApiFactory(
7
- installOptionsRepository.get('openAPIConfig'),
8
- '',
9
- installOptionsRepository.get('instance'),
10
- );
6
+ const patchAgentStatus = async ({ agentId, status, pauseCause }) => {
7
+ try {
8
+ const res = await service.updateAgentStatus(agentId, {
9
+ status,
10
+ id: agentId,
11
+ payload: pauseCause,
12
+ });
13
+ return { success: !!res };
14
+ } catch (err) {
15
+ throw err;
16
+ }
17
+ };
11
18
 
12
- export const patchAgentStatus = async ({ agentId, status, pauseCause }) => {
13
- if (!apiService) createApiService();
14
- try {
15
- const res = await apiService.updateAgentStatus(agentId, {
16
- status,
17
- id: agentId,
18
- payload: pauseCause,
19
- }, undefined);
20
- return { success: !!res };
21
- } catch (err) {
22
- throw err;
23
- }
19
+ return {
20
+ patch: patchAgentStatus,
21
+ };
24
22
  };
25
23
 
26
- export default {
27
- patch: patchAgentStatus,
28
- };
24
+ export default AgentStatusAPIFactory;
@@ -1,40 +1,47 @@
1
1
  import { AgentServiceApiFactory } from 'webitel-sdk';
2
- import { SdkListGetterApiConsumer } from 'webitel-sdk/esm2015/api-consumers';
3
- import installOptionsRepository from '../../../_install/InstallOptionsRepository';
2
+ import applyTransform, {
3
+ merge, mergeEach, notify,
4
+ snakeToCamel,
5
+ } from '../../../api/transformers';
6
+ import { getDefaultGetListResponse } from '../../../api/defaults';
4
7
 
5
- const _getAgentPauseCauses = (getList) => function ({
6
- agentId,
7
- } = {}) {
8
- const allowChange = true;
9
- const params = [agentId, allowChange];
10
- return getList(params);
11
- };
12
-
13
- const defaultListObject = {
14
- name: '',
15
- durationMin: 0,
16
- limitMin: 0,
17
- };
8
+ const PauseCauseAPIFactory = ({ instance, OpenAPIConfig }) => {
18
9
 
19
- let apiService;
20
- let listGetter;
10
+ const service = new AgentServiceApiFactory(OpenAPIConfig, '', instance);
21
11
 
22
- const createApiService = () => {
23
- apiService = new AgentServiceApiFactory(
24
- installOptionsRepository.get('openAPIConfig'),
25
- '',
26
- installOptionsRepository.get('instance'),
27
- );
28
- listGetter = new SdkListGetterApiConsumer(apiService.searchPauseCauseForAgent,
29
- { defaultListObject })
30
- .setGetListMethod(_getAgentPauseCauses);
31
- }
12
+ const getList = async ({ agentId }) => {
13
+ const defaultObject = {
14
+ name: '',
15
+ durationMin: 0,
16
+ limitMin: 0,
17
+ };
32
18
 
33
- export const getAgentPauseCauses = (params) => {
34
- if (!apiService) createApiService();
35
- return listGetter.getList(params);
36
- }
19
+ const allowChange = true;
20
+ try {
21
+ const response = await service.searchPauseCauseForAgent(
22
+ agentId,
23
+ allowChange,
24
+ );
25
+ const { items, next } = applyTransform(response.data, [
26
+ snakeToCamel(),
27
+ merge(getDefaultGetListResponse()),
28
+ ]);
29
+ return {
30
+ items: applyTransform(items, [
31
+ mergeEach(defaultObject),
32
+ ]),
33
+ next,
34
+ };
35
+ } catch (err) {
36
+ throw applyTransform(err, [
37
+ notify,
38
+ ]);
39
+ }
40
+ };
37
41
 
38
- export default {
39
- getList: getAgentPauseCauses,
42
+ return {
43
+ getList,
44
+ };
40
45
  };
46
+
47
+ export default PauseCauseAPIFactory;
@@ -1,61 +1,49 @@
1
- import { shallowMount } from '@vue/test-utils';
2
- import AgentStatus from '@webitel/ui-sdk/src/enums/AgentStatus/AgentStatus.enum';
1
+ import { shallowMount, mount } from '@vue/test-utils';
3
2
  import { createStore } from 'vuex';
4
- import AgentStatusAPI from '../../api/agent-status';
5
- import PauseCauseAPI from '../../api/pause-cause';
6
- import statusSelect from '../../store/agent-status-select';
3
+ import AgentStatus from '../../../../enums/AgentStatus/AgentStatus.enum';
4
+ import * as AgentStatusAPIFactory from '../../api/agent-status';
5
+ import * as PauseCauseAPIFactory from '../../api/pause-cause';
7
6
  import WtCcAgentStatusSelect from '../wt-cc-agent-status-select.vue';
8
7
 
9
8
  const pauseCauses = [{ name: 'jest1' }, { name: 'jest2' }];
10
9
  const getAgentPauseCausesMock = jest.fn(() => ({ items: pauseCauses }));
11
- jest.spyOn(PauseCauseAPI, 'getList').mockImplementation(getAgentPauseCausesMock);
10
+ // https://stackoverflow.com/a/63727813
11
+ jest.spyOn(PauseCauseAPIFactory, 'default').mockImplementation(() => ({ getList: getAgentPauseCausesMock }));
12
12
 
13
- const agentStatusMock = jest.fn(() => {
14
- });
15
- jest.spyOn(AgentStatusAPI, 'patch').mockImplementation(agentStatusMock);
13
+ const agentStatusMock = jest.fn(() => {});
14
+ // https://stackoverflow.com/a/63727813
15
+ jest.spyOn(AgentStatusAPIFactory, 'default').mockImplementation(() => ({ patch: agentStatusMock }));
16
16
 
17
- const namespace = 'agents';
18
17
  const agent = {
19
18
  status: '',
20
19
  agentId: 1,
21
20
  };
22
- const updateAgentStatusMock = jest.fn();
23
- jest.spyOn(statusSelect.actions, 'UPDATE_AGENT_STATUS')
24
- .mockImplementation(updateAgentStatusMock);
25
-
26
- const store = createStore({
27
- modules: {
28
- [namespace]: {
29
- state: { agent },
30
- modules: { statusSelect },
31
- namespaced: true,
32
- },
33
- },
34
- });
35
21
 
36
22
  const mountOptions = {
37
- global: { plugins: [store] },
38
23
  props: {
39
24
  agentId: agent.agentId,
40
25
  status: agent.status,
41
26
  },
27
+ global: {
28
+ plugins: [createStore({})],
29
+ },
30
+ shallow: true,
42
31
  };
43
32
 
44
33
  describe('Wt Cc Agent Status Select', () => {
45
34
  beforeEach(() => {
46
- updateAgentStatusMock.mockClear();
47
35
  getAgentPauseCausesMock.mockClear();
48
36
  });
49
37
  it('renders a component', () => {
50
38
  const wrapper = shallowMount(WtCcAgentStatusSelect, mountOptions);
51
39
  expect(wrapper.exists())
52
- .toBe(true);
40
+ .toBe(true);
53
41
  });
54
- it(`at wt-status-select "change" to "online" event, triggers UPDATE_AGENT_STATUS
42
+ it(`at wt-status-select "change" to "online" event, triggers agent status patch
55
43
  with "online" status`, () => {
56
44
  const wrapper = shallowMount(WtCcAgentStatusSelect, mountOptions);
57
45
  wrapper.findComponent({ name: 'wt-status-select' })
58
- .vm.$emit('change', AgentStatus.ONLINE);
46
+ .vm.$emit('change', AgentStatus.ONLINE);
59
47
  const reqPayload = {
60
48
  status: AgentStatus.ONLINE, agentId: agent.agentId, payload: undefined,
61
49
  };
@@ -64,27 +52,29 @@ describe('Wt Cc Agent Status Select', () => {
64
52
  it('at wt-status-select "change" to "pause" event, pause causes are loaded', async () => {
65
53
  const wrapper = shallowMount(WtCcAgentStatusSelect, mountOptions);
66
54
  wrapper.findComponent({ name: 'wt-status-select' })
67
- .vm.$emit('change', AgentStatus.PAUSE);
55
+ .vm.$emit('change', AgentStatus.PAUSE);
68
56
  await wrapper.vm.$nextTick();
69
57
  expect(getAgentPauseCausesMock).toHaveBeenCalled();
70
58
  });
71
59
  it(`at wt-status-select "change" to "pause" event and pause causes truthy response,
72
60
  pause-cause-popup appears`, async () => {
73
- const wrapper = shallowMount(WtCcAgentStatusSelect, mountOptions);
61
+ const wrapper = mount(WtCcAgentStatusSelect, mountOptions);
74
62
  wrapper.findComponent({ name: 'wt-status-select' })
75
- .vm.$emit('change', AgentStatus.PAUSE);
63
+ .vm.$emit('change', AgentStatus.PAUSE);
76
64
  await wrapper.vm.$nextTick(); // load pause causes
65
+ await wrapper.vm.$nextTick();
77
66
  await wrapper.vm.$nextTick(); // render popup
78
- expect(wrapper.findComponent({ name: 'wt-cc-pause-cause-popup' }).isVisible()).toBe(true);
67
+ expect(wrapper.findComponent({ name: 'pause-cause-popup' }).isVisible()).toBe(true);
79
68
  });
80
- it(`at pause-cause-popup "change" event, triggers UPDATE_AGENT_STATUS
69
+ it(`at pause-cause-popup "change" event, triggers patch agent status
81
70
  with "pause" status and passed pauseCause`, async () => {
82
71
  const pauseCause = 'jest';
83
- const wrapper = shallowMount(WtCcAgentStatusSelect, mountOptions);
72
+ const wrapper = mount(WtCcAgentStatusSelect, mountOptions);
84
73
  wrapper.vm.openPauseCausePopup();
85
74
  await wrapper.vm.$nextTick();
86
- wrapper.findComponent({ name: 'wt-cc-pause-cause-popup' })
87
- .vm.$emit('change', pauseCause);
75
+ await wrapper.vm.$nextTick();
76
+ wrapper.findComponent({ name: 'pause-cause-popup' })
77
+ .vm.$emit('change', pauseCause);
88
78
  const reqPayload = {
89
79
  status: AgentStatus.PAUSE, agentId: agent.agentId, pauseCause,
90
80
  };
@@ -8,25 +8,11 @@ describe('Pause cause popup', () => {
8
8
  .toBe(true);
9
9
  });
10
10
  it('at option input event, sets "selected" its value', () => {
11
- const radioValue = 'jest';
11
+ const value = 'jest';
12
12
  const wrapper = mount(WtCcPauseCausePopup, {
13
- props: { options: [radioValue] },
13
+ props: { options: [{ value }] },
14
14
  });
15
15
  wrapper.findComponent({ name: 'wt-radio' }).vm.$emit('input');
16
- expect(wrapper.vm.selected).toEqual(radioValue);
17
- });
18
- it('isDurationOverflow with limit = 0 returns false', () => {
19
- const wrapper = shallowMount(WtCcPauseCausePopup);
20
- const option = { durationMin: 10, limitMin: 0 };
21
- expect(wrapper.vm.isDurationOverflow(option)).toBe(false);
22
- });
23
- it('at "ok" btn click, emits "change" with "selected" value', () => {
24
- const selected = { name: 'jest' };
25
- const expectedValue = selected.name;
26
- const wrapper = shallowMount(WtCcPauseCausePopup, {
27
- data: () => ({ selected }),
28
- });
29
- wrapper.findComponent({ name: 'wt-button' }).vm.$emit('click');
30
- expect(wrapper.emitted().change[0]).toEqual([expectedValue]);
16
+ expect(wrapper.vm.selected.value).toEqual(value);
31
17
  });
32
18
  });
@@ -11,21 +11,21 @@
11
11
  <form @submit.prevent="setPause">
12
12
  <ul>
13
13
  <li
14
- class="wt-cc-pause-cause-popup__option"
14
+ class="wt-cc-pause-cause-popup-option"
15
15
  v-for="(option) of pauseCause"
16
16
  :key="option.id"
17
17
  >
18
18
  <wt-radio
19
- class="wt-cc-pause-cause-popup__option__radio"
19
+ class="wt-cc-pause-cause-popup-option__radio"
20
20
  :selected="selected.id"
21
21
  :value="option.id"
22
22
  :label="option.name"
23
23
  @input="select(option)"
24
24
  ></wt-radio>
25
- <div class="wt-cc-pause-cause-popup__option__limits-wrapper">
25
+ <div class="wt-cc-pause-cause-popup-option__limits-wrapper">
26
26
  <span
27
27
  :class="{
28
- 'wt-cc-pause-cause-popup__option__duration--overflow': option.isOverflow,
28
+ 'wt-cc-pause-cause-popup-option__duration--overflow': option.isOverflow,
29
29
  }"
30
30
  >
31
31
  {{ option.duration }}
@@ -55,9 +55,7 @@
55
55
  <script setup>
56
56
  import { computed, ref, toRef } from 'vue';
57
57
  import { useI18n } from 'vue-i18n';
58
- import {
59
- useRepresentableAgentPauseCause,
60
- } from '../../../../composables/useRepresentableAgentPauseCause/useRepresentableAgentPauseCause';
58
+ import { useRepresentableAgentPauseCause } from '../../../../composables/useRepresentableAgentPauseCause/useRepresentableAgentPauseCause';
61
59
 
62
60
  const props = defineProps({
63
61
  options: {
@@ -101,7 +99,7 @@ function setPause() {
101
99
  </script>
102
100
 
103
101
  <style lang="scss" scoped>
104
- .wt-cc-pause-cause-popup__option {
102
+ .wt-cc-pause-cause-popup-option {
105
103
  display: flex;
106
104
  justify-content: space-between;
107
105
  align-items: center;
@@ -111,13 +109,13 @@ function setPause() {
111
109
  }
112
110
  }
113
111
 
114
- .wt-cc-pause-cause-popup__option__limits-wrapper {
112
+ .wt-cc-pause-cause-popup-option__limits-wrapper {
115
113
  & > span {
116
114
  @extend %typo-caption;
117
115
  padding: 6px 10px;
118
116
  }
119
117
 
120
- .wt-cc-pause-cause-popup__option__duration--overflow {
118
+ .wt-cc-pause-cause-popup-option__duration--overflow {
121
119
  color: var(--false-color);
122
120
  }
123
121
  }
@@ -0,0 +1,56 @@
1
+ <template>
2
+ <wt-popup
3
+ class="wt-cc-status-select-error-popup"
4
+ min-width="480"
5
+ @close="close"
6
+ >
7
+ <template v-slot:header>
8
+ {{ $t('webitelUI.agentStatusSelect.statusSelectErrorPopup.title') }}
9
+ </template>
10
+ <template v-slot:main>
11
+ <article class="wt-cc-status-select-error-popup__main-wrapper">
12
+ <wt-icon
13
+ icon="attention"
14
+ color="danger"
15
+ ></wt-icon>
16
+ <p class="wt-cc-status-select-error-popup__message">
17
+ {{ $t(`webitelUI.agentStatusSelect.statusSelectErrorPopup.${'message'}`) }}
18
+ </p>
19
+ </article>
20
+ </template>
21
+ <template v-slot:actions>
22
+ <wt-button
23
+ color="secondary"
24
+ @click="close"
25
+ >{{ $t('reusable.ok') }}
26
+ </wt-button>
27
+ </template>
28
+ </wt-popup>
29
+ </template>
30
+
31
+ <script setup>
32
+
33
+ const props = defineProps({
34
+ error: {
35
+ type: Object,
36
+ required: true,
37
+ },
38
+ });
39
+
40
+ const emit = defineEmits(['close']);
41
+
42
+ function close() {
43
+ emit('close');
44
+ }
45
+
46
+ </script>
47
+
48
+ <style lang="scss" scoped>
49
+ .wt-cc-status-select-error-popup__main-wrapper {
50
+ display: flex;
51
+ flex-direction: column;
52
+ justify-content: center;
53
+ align-items: center;
54
+ gap: var(--spacing-sm);
55
+ }
56
+ </style>
@@ -1,7 +1,6 @@
1
1
  <template>
2
2
  <article class="wt-cc-agent-status-select">
3
3
  <wt-status-select
4
- class="wt-cc-agent-status-select__status-select"
5
4
  :status="status"
6
5
  :status-duration="statusDuration"
7
6
  @change="handleStatusSelectInput"
@@ -12,88 +11,96 @@
12
11
  @change="handlePauseCauseInput"
13
12
  @close="closePauseCausePopup"
14
13
  ></pause-cause-popup>
14
+ <status-select-error-popup
15
+ v-if="error"
16
+ :error="error"
17
+ @close="error = null"
18
+ ></status-select-error-popup>
15
19
  </article>
16
20
  </template>
17
21
 
18
- <script>
19
- import AgentStatus from '@webitel/ui-sdk/src/enums/AgentStatus/AgentStatus.enum';
20
- import AgentStatusAPI from '../api/agent-status';
21
- import PauseCauseAPI from '../api/pause-cause';
22
+ <script setup>
23
+ import AgentStatus from '../../../enums/AgentStatus/AgentStatus.enum';
24
+ import { ref } from 'vue';
25
+ import { useStore } from 'vuex';
26
+ import AgentStatusAPIFactory from '../api/agent-status';
27
+ import PauseCauseAPIFactory from '../api/pause-cause';
22
28
  import PauseCausePopup from './_internals/wt-cc-pause-cause-popup.vue';
29
+ import StatusSelectErrorPopup from './_internals/wt-cc-status-select-error-popup.vue';
23
30
 
24
- export default {
25
- name: 'wt-cc-agent-status-select',
26
- components: { PauseCausePopup },
27
- props: {
28
- agentId: {
29
- type: [String, Number],
30
- },
31
- status: {
32
- // can be undefined, is agent wasn't loaded yet
33
- default: AgentStatus.OFFLINE,
34
- },
35
- statusDuration: {
36
- type: [Number, String],
37
- default: 0,
38
- },
31
+ const props = defineProps({
32
+ agentId: {
33
+ type: [String, Number],
34
+ required: true,
39
35
  },
40
- data: () => ({
41
- isPauseCausePopup: false,
42
- pauseCauses: [],
43
- }),
44
- methods: {
45
- async updateStatus({ agentId, status, pauseCause }) {
46
- try {
47
- await AgentStatusAPI.patch({ agentId, status, pauseCause });
48
- } catch (err) {
49
- throw err;
50
- }
51
- },
52
- async handleStatusSelectInput(status) {
53
- if (status === AgentStatus.PAUSE) {
54
- await this.loadPauseCauses();
55
- if (this.pauseCauses.length) {
56
- this.openPauseCausePopup();
57
- return;
58
- }
59
- }
60
- if (status === this.status) return;
61
- await this.changeStatus({ status });
62
- },
63
- handlePauseCauseInput(pauseCause) {
64
- const status = AgentStatus.PAUSE;
65
- this.changeStatus({ status, pauseCause });
66
- },
67
- async changeStatus({ status, pauseCause }) {
68
- const statusPayload = { agentId: this.agentId, status, pauseCause };
69
- try {
70
- await this.updateStatus(statusPayload);
71
- this.$emit('changed', statusPayload);
72
- } catch (err) {
73
- console.error(err);
74
- }
75
- },
76
- async loadPauseCauses() {
77
- this.isLoaded = false;
78
- try {
79
- const response = await PauseCauseAPI.getList({ agentId: this.agentId });
80
- this.pauseCauses = response.items;
81
- } catch {
82
- }
83
- this.isLoaded = true;
84
- },
85
- openPauseCausePopup() {
86
- this.isPauseCausePopup = true;
87
- },
88
- closePauseCausePopup() {
89
- this.isPauseCausePopup = false;
90
- },
36
+ status: {
37
+ // can be undefined, is agent wasn't loaded yet
38
+ default: AgentStatus.OFFLINE,
91
39
  },
92
- };
40
+ statusDuration: {
41
+ type: [Number, String],
42
+ default: 0,
43
+ },
44
+ });
45
+
46
+ const emit = defineEmits(['changed']);
47
+
48
+ const { api } = useStore().state;
49
+ const AgentStatusAPI = AgentStatusAPIFactory(api);
50
+ const PauseCauseAPI = PauseCauseAPIFactory(api);
51
+
52
+ const isPauseCausePopup = ref(false);
53
+ const pauseCauses = ref([]);
54
+ const error = ref(null);
55
+
56
+ function openPauseCausePopup() {
57
+ isPauseCausePopup.value = true;
58
+ }
59
+
60
+ function closePauseCausePopup() {
61
+ isPauseCausePopup.value = false;
62
+ }
63
+
64
+ async function loadPauseCauses() {
65
+ const response = await PauseCauseAPI.getList({ agentId: props.agentId });
66
+ pauseCauses.value = response.items;
67
+ }
68
+
69
+ async function updateStatus({ agentId, status, pauseCause }) {
70
+ return AgentStatusAPI.patch({ agentId, status, pauseCause });
71
+ }
72
+
73
+ async function changeStatus({ status, pauseCause }) {
74
+ try {
75
+ const statusPayload = { agentId: props.agentId, status, pauseCause };
76
+ await updateStatus(statusPayload);
77
+ emit('changed', statusPayload);
78
+ } catch (err) {
79
+ error.value = err;
80
+ throw err;
81
+ }
82
+ }
83
+
84
+ async function handleStatusSelectInput(status) {
85
+ if (status === AgentStatus.PAUSE) {
86
+ await loadPauseCauses();
87
+ if (pauseCauses.value.length) {
88
+ openPauseCausePopup();
89
+ return;
90
+ }
91
+ }
92
+ if (status === props.status) return;
93
+ await changeStatus({ status });
94
+ }
95
+
96
+ function handlePauseCauseInput(pauseCause) {
97
+ const status = AgentStatus.PAUSE;
98
+ return changeStatus({ status, pauseCause });
99
+ }
93
100
  </script>
94
101
 
95
102
  <style lang="scss" scoped>
96
- .wt-cc-agent-status-select__status-select {
103
+ .wt-cc-agent-status-select .wt-status-select {
97
104
  max-width: 200px;
98
105
  }
99
106
  </style>
@@ -7,9 +7,9 @@
7
7
  </template>
8
8
 
9
9
  <script setup>
10
- import getNamespacedState from '@webitel/ui-sdk/src/store/helpers/getNamespacedState';
11
10
  import { computed } from 'vue';
12
11
  import { useStore } from 'vuex';
12
+ import getNamespacedState from '../../../store/helpers/getNamespacedState';
13
13
 
14
14
  const props = defineProps({
15
15
  namespace: {
@@ -1,21 +0,0 @@
1
- import installOptionsRepository from '../../../../_install/InstallOptionsRepository';
2
- import AgentStatusAPI from '../agent-status';
3
-
4
- /* mock SDK method api response with instance mock
5
- jest.spyOn(instance) used instead of jest.mock('@/app/api/instance) because WebStorm
6
- doesn't watch path changes in jest.mock()
7
- */
8
- const patchMock = jest.fn();
9
- jest.spyOn(installOptionsRepository.get('instance'), 'request')
10
- .mockImplementation(patchMock);
11
-
12
- describe('Agent Status API', () => {
13
- it('patch: correctly processes response', async () => {
14
- const payload = { agentId: 1, status: 'jest', pauseCause: 'jest' };
15
- const expectedData = { id: 1, status: 'jest', payload: 'jest' };
16
- await AgentStatusAPI.patch(payload);
17
- expect(patchMock).toHaveBeenCalled();
18
- const reqData = JSON.parse(patchMock.mock.calls[0][0].data);
19
- expect(reqData).toEqual(expectedData);
20
- });
21
- });
@@ -1,29 +0,0 @@
1
- import installOptionsRepository from '../../../../_install/InstallOptionsRepository';
2
- import PauseCauseAPI from '../pause-cause';
3
-
4
- const items = [{ id: 1, name: 'jest' }];
5
- const expectedResponse = {
6
- next: false,
7
- items: [{
8
- id: 1,
9
- name: 'jest',
10
- durationMin: 0,
11
- limitMin: 0,
12
- }],
13
- };
14
-
15
- /* mock SDK method api response with instance mock
16
- jest.spyOn(instance) used instead of jest.mock('@/app/api/instance) because WebStorm
17
- doesn't watch path changes in jest.mock()
18
- */
19
- const getMock = jest.fn(() => ({ items }));
20
- jest.spyOn(installOptionsRepository.get('instance'), 'request')
21
- .mockImplementation(getMock);
22
-
23
- describe('Agent Pause Cause API', () => {
24
- it('getList: correctly processes response', async () => {
25
- const response = await PauseCauseAPI.getList({ agentId: 0 });
26
- expect(getMock).toHaveBeenCalled();
27
- expect(response).toEqual(expectedResponse);
28
- });
29
- });