@webitel/ui-sdk 0.9.62 → 0.9.66
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/dist/ui-sdk.common.js +68 -68
- package/dist/ui-sdk.common.js.map +1 -1
- package/dist/ui-sdk.css +1 -1
- package/dist/ui-sdk.umd.js +68 -68
- package/dist/ui-sdk.umd.js.map +1 -1
- package/dist/ui-sdk.umd.min.js +1 -1
- package/dist/ui-sdk.umd.min.js.map +1 -1
- package/package.json +3 -4
- package/src/components/atoms/wt-badge/wt-badge.vue +1 -1
- package/src/css/components/atoms/wt-badge/wt-badge.scss +4 -0
- package/src/locale/en/en.js +28 -3
- package/src/locale/ru/ru.js +26 -1
- package/src/locale/ua/ua.js +26 -1
- package/src/modules/QueryFilters/api/__tests__/defaults.spec.js +18 -0
- package/src/modules/QueryFilters/api/defaults.js +16 -0
- package/src/modules/QueryFilters/components/__tests__/abstract-enum-filter.spec.js +0 -7
- package/src/modules/QueryFilters/components/__tests__/filter-search.spec.js +28 -23
- package/src/modules/QueryFilters/components/filter-search.vue +1 -1
- package/src/modules/QueryFilters/mixins/__tests__/apiFilterMixin.spec.js +14 -15
- package/src/modules/QueryFilters/mixins/__tests__/enumFilterMixin.spec.js +35 -50
- package/src/modules/QueryFilters/mixins/__tests__/paginationFilterMixin.spec.js +86 -0
- package/src/modules/QueryFilters/mixins/__tests__/sortFilterMixin.spec.js +11 -16
- package/src/modules/QueryFilters/mixins/__tests__/urlControllerMixin.spec.js +48 -0
- package/src/modules/QueryFilters/mixins/_urlControllerMixin/_urlControllerMixin.js +39 -0
- package/src/modules/QueryFilters/mixins/baseFilterMixin/baseFilterMixin.js +2 -8
- package/src/modules/QueryFilters/mixins/enumFilterMixin.js +9 -11
- package/src/modules/QueryFilters/mixins/paginationFilterMixin.js +76 -0
- package/src/modules/QueryFilters/store/QueryFiltersStoreModule.js +0 -6
- package/src/modules/QueryFilters/store/queryFilters.js +6 -0
- package/src/modules/QueryFilters/components/__tests__/filter-pagination.spec.js +0 -71
- package/src/modules/QueryFilters/components/filter-pagination.vue +0 -110
- package/src/modules/QueryFilters/store/QueryControllerStoreModule.js +0 -64
- package/src/modules/QueryFilters/store/__tests__/QueryControllerStoreModule.spec.js +0 -42
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webitel/ui-sdk",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.66",
|
|
4
4
|
"private": false,
|
|
5
5
|
"scripts": {
|
|
6
6
|
"serve-lib": "vue-cli-service serve",
|
|
@@ -8,8 +8,7 @@
|
|
|
8
8
|
"test:unit": "vue-cli-service test:unit",
|
|
9
9
|
"lint": "vue-cli-service lint --fix",
|
|
10
10
|
"build-lib": "vue-cli-service build --target lib --name ui-sdk ./src/install.js",
|
|
11
|
-
"build-publish-lib": "npm run test:unit && npm run build-lib && npm publish --access public"
|
|
12
|
-
"build-publish-lib:testless": "npm run build-lib && npm publish --access public"
|
|
11
|
+
"build-publish-lib": "npm run test:unit && npm run build-lib && npm publish --access public"
|
|
13
12
|
},
|
|
14
13
|
"main": "./dist/@webitel/ui-sdk.common.js",
|
|
15
14
|
"files": [
|
|
@@ -42,7 +41,7 @@
|
|
|
42
41
|
"vue-observe-visibility": "^1.0.0",
|
|
43
42
|
"vue-router": "^3.2.0",
|
|
44
43
|
"vuejs-datepicker": "^1.6.2",
|
|
45
|
-
"webitel-sdk": "^0.1.
|
|
44
|
+
"webitel-sdk": "^0.1.91"
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
48
47
|
"@testing-library/jest-dom": "^5.11.4",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
color: {
|
|
12
12
|
type: String,
|
|
13
13
|
default: 'main',
|
|
14
|
-
options: ['main', 'outline', 'accent', 'secondary', 'success', 'danger', 'transfer'],
|
|
14
|
+
options: ['main', 'outline', 'accent', 'secondary', 'secondary-50', 'success', 'danger', 'transfer'],
|
|
15
15
|
notes: '"main" and "outline" are badge-specific colors',
|
|
16
16
|
},
|
|
17
17
|
},
|
package/src/locale/en/en.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AgentStatus,
|
|
3
|
+
CallDirection,
|
|
4
|
+
ChannelState,
|
|
5
|
+
ChannelType,
|
|
6
|
+
} from 'webitel-sdk';
|
|
2
7
|
import { QueueType } from 'webitel-sdk/esm2015/enums';
|
|
3
|
-
import { snakeToCamel } from '../../scripts/caseConverters';
|
|
4
8
|
import AdminSections from '../../enums/WebitelApplications/AdminSections.enum';
|
|
5
9
|
import SupervisorSections from '../../enums/WebitelApplications/SupervisorSections.enum';
|
|
6
10
|
import WebitelApplications from '../../enums/WebitelApplications/WebitelApplications.enum';
|
|
11
|
+
import { snakeToCamel } from '../../scripts/caseConverters';
|
|
7
12
|
|
|
8
13
|
export default {
|
|
9
14
|
// describes reusable buttons, actions, default titles, and other ui elements
|
|
@@ -58,6 +63,26 @@ export default {
|
|
|
58
63
|
},
|
|
59
64
|
},
|
|
60
65
|
},
|
|
66
|
+
channel: {
|
|
67
|
+
state: {
|
|
68
|
+
[ChannelState.Waiting]: 'Waiting',
|
|
69
|
+
[ChannelState.Distribute]: 'Distribute',
|
|
70
|
+
[ChannelState.Offering]: 'Offering',
|
|
71
|
+
[ChannelState.Answered]: 'Answered',
|
|
72
|
+
[ChannelState.Active]: 'Active',
|
|
73
|
+
[ChannelState.Bridged]: 'Bridged',
|
|
74
|
+
[ChannelState.Hold]: 'Hold',
|
|
75
|
+
[ChannelState.Missed]: 'Missed',
|
|
76
|
+
[snakeToCamel(ChannelState.WrapTime)]: 'Wrap time',
|
|
77
|
+
[ChannelState.Processing]: 'Processing',
|
|
78
|
+
[ChannelState.Transfer]: 'Transfer',
|
|
79
|
+
},
|
|
80
|
+
type: {
|
|
81
|
+
[ChannelType.Call]: 'Call',
|
|
82
|
+
[ChannelType.Email]: 'Email',
|
|
83
|
+
[ChannelType.Chat]: 'Chat',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
61
86
|
calls: {
|
|
62
87
|
direction: {
|
|
63
88
|
[CallDirection.Inbound]: 'Inbound',
|
|
@@ -186,7 +211,7 @@ export default {
|
|
|
186
211
|
text: 'Sorry, you have not enough privileges to see this page.',
|
|
187
212
|
},
|
|
188
213
|
page404: {
|
|
189
|
-
title:
|
|
214
|
+
title: 'Looks like you\'re lost',
|
|
190
215
|
text: 'Sorry, we can\'t find the page you want.',
|
|
191
216
|
},
|
|
192
217
|
},
|
package/src/locale/ru/ru.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AgentStatus,
|
|
3
|
+
CallDirection,
|
|
4
|
+
ChannelState,
|
|
5
|
+
ChannelType,
|
|
6
|
+
} from 'webitel-sdk';
|
|
2
7
|
import { QueueType } from 'webitel-sdk/esm2015/enums';
|
|
3
8
|
import AdminSections from '../../enums/WebitelApplications/AdminSections.enum';
|
|
4
9
|
import SupervisorSections from '../../enums/WebitelApplications/SupervisorSections.enum';
|
|
@@ -58,6 +63,26 @@ export default {
|
|
|
58
63
|
},
|
|
59
64
|
},
|
|
60
65
|
},
|
|
66
|
+
channel: {
|
|
67
|
+
state: {
|
|
68
|
+
[ChannelState.Waiting]: 'Ожидание',
|
|
69
|
+
[ChannelState.Distribute]: 'Зарезервирован',
|
|
70
|
+
[ChannelState.Offering]: 'Распределение',
|
|
71
|
+
[ChannelState.Answered]: 'Отвечен',
|
|
72
|
+
[ChannelState.Active]: 'Активный',
|
|
73
|
+
[ChannelState.Bridged]: 'Соединён',
|
|
74
|
+
[ChannelState.Hold]: 'Удержание',
|
|
75
|
+
[ChannelState.Missed]: 'Пропущен',
|
|
76
|
+
[snakeToCamel(ChannelState.WrapTime)]: 'Постобработка',
|
|
77
|
+
[ChannelState.Processing]: 'Обработка',
|
|
78
|
+
[ChannelState.Transfer]: 'Перевод',
|
|
79
|
+
},
|
|
80
|
+
type: {
|
|
81
|
+
[ChannelType.Call]: 'Звонок',
|
|
82
|
+
[ChannelType.Email]: 'Почта',
|
|
83
|
+
[ChannelType.Chat]: 'Чат',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
61
86
|
calls: {
|
|
62
87
|
direction: {
|
|
63
88
|
[CallDirection.Inbound]: 'Входящий | Входящие',
|
package/src/locale/ua/ua.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
AgentStatus,
|
|
3
|
+
CallDirection,
|
|
4
|
+
ChannelState,
|
|
5
|
+
ChannelType,
|
|
6
|
+
} from 'webitel-sdk';
|
|
2
7
|
import { QueueType } from 'webitel-sdk/esm2015/enums';
|
|
3
8
|
import AdminSections from '../../enums/WebitelApplications/AdminSections.enum';
|
|
4
9
|
import SupervisorSections from '../../enums/WebitelApplications/SupervisorSections.enum';
|
|
@@ -58,6 +63,26 @@ export default {
|
|
|
58
63
|
},
|
|
59
64
|
},
|
|
60
65
|
},
|
|
66
|
+
channel: {
|
|
67
|
+
state: {
|
|
68
|
+
[ChannelState.Waiting]: 'Очікування',
|
|
69
|
+
[ChannelState.Distribute]: 'Зарезервований',
|
|
70
|
+
[ChannelState.Offering]: 'Розподіл',
|
|
71
|
+
[ChannelState.Answered]: 'Прийнятий',
|
|
72
|
+
[ChannelState.Active]: 'Активний',
|
|
73
|
+
[ChannelState.Bridged]: 'З\'єднаний',
|
|
74
|
+
[ChannelState.Hold]: 'Утримання',
|
|
75
|
+
[ChannelState.Missed]: 'Пропущений',
|
|
76
|
+
[snakeToCamel(ChannelState.WrapTime)]: 'Постобробка',
|
|
77
|
+
[ChannelState.Processing]: 'Обробка',
|
|
78
|
+
[ChannelState.Transfer]: 'Перевід',
|
|
79
|
+
},
|
|
80
|
+
type: {
|
|
81
|
+
[ChannelType.Call]: 'Дзвінок',
|
|
82
|
+
[ChannelType.Email]: 'Пошта',
|
|
83
|
+
[ChannelType.Chat]: 'Чат',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
61
86
|
calls: {
|
|
62
87
|
direction: {
|
|
63
88
|
[CallDirection.Inbound]: 'Вхідний | Вхідні',
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { listResponseHandler } from '../defaults';
|
|
2
|
+
|
|
3
|
+
describe('filter api Defaults', () => {
|
|
4
|
+
it('listResponseHandler returns only lookups from response', () => {
|
|
5
|
+
const response = {
|
|
6
|
+
items: [
|
|
7
|
+
{ name: 'jest1', id: 1, myField: '1' },
|
|
8
|
+
{ name: 'jest2', id: 2, obj: [] },
|
|
9
|
+
],
|
|
10
|
+
next: true,
|
|
11
|
+
};
|
|
12
|
+
const expectedResult = [
|
|
13
|
+
{ name: 'jest1', id: 1 },
|
|
14
|
+
{ name: 'jest2', id: 2 },
|
|
15
|
+
];
|
|
16
|
+
expect(listResponseHandler(response)).toEqual(expectedResult);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const PAGE = 1;
|
|
2
|
+
const SIZE = 20;
|
|
3
|
+
const FIELDS = ['id', 'name'];
|
|
4
|
+
|
|
5
|
+
export const defaultParams = {
|
|
6
|
+
page: PAGE,
|
|
7
|
+
size: SIZE,
|
|
8
|
+
fields: FIELDS,
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const listResponseHandler = (response) => (
|
|
12
|
+
response.items.map((item) => ({
|
|
13
|
+
name: item.name,
|
|
14
|
+
id: item.id,
|
|
15
|
+
}))
|
|
16
|
+
);
|
|
@@ -20,9 +20,6 @@ describe('Abstract Enum Filter', () => {
|
|
|
20
20
|
state: {
|
|
21
21
|
[filterQuery]: filterSchema,
|
|
22
22
|
},
|
|
23
|
-
getters: {
|
|
24
|
-
GET_VALUE_FROM_QUERY: () => {},
|
|
25
|
-
},
|
|
26
23
|
},
|
|
27
24
|
},
|
|
28
25
|
});
|
|
@@ -37,10 +34,6 @@ describe('Abstract Enum Filter', () => {
|
|
|
37
34
|
},
|
|
38
35
|
};
|
|
39
36
|
it('renders a component', () => {
|
|
40
|
-
console.info(store.getters);
|
|
41
|
-
console.info(Object.keys(store.getters)[0]);
|
|
42
|
-
console.info(store.getters);
|
|
43
|
-
console.info(store.getters[Object.keys(store.getters)[0]]);
|
|
44
37
|
const wrapper = shallowMount(AbstractEnumFilter, mountOptions);
|
|
45
38
|
expect(wrapper.exists()).toBe(true);
|
|
46
39
|
});
|
|
@@ -1,44 +1,49 @@
|
|
|
1
|
-
import { shallowMount } from '@vue/test-utils';
|
|
1
|
+
import { shallowMount, createLocalVue } from '@vue/test-utils';
|
|
2
|
+
import Vuex from 'vuex';
|
|
3
|
+
import VueRouter from 'vue-router';
|
|
2
4
|
import SearchFilter from '../filter-search.vue';
|
|
3
5
|
import BaseFilterSchema from '../../classes/BaseFilterSchema';
|
|
4
6
|
import baseFilterMixin from '../../mixins/baseFilterMixin/baseFilterMixin';
|
|
5
7
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
8
|
+
const localVue = createLocalVue();
|
|
9
|
+
localVue.use(Vuex);
|
|
10
|
+
localVue.use(VueRouter);
|
|
11
|
+
const router = new VueRouter();
|
|
10
12
|
|
|
11
13
|
describe('Search Filter', () => {
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
14
|
+
const namespace = 'jest';
|
|
15
|
+
const filterQuery = 'jest';
|
|
16
|
+
const filterSchema = new BaseFilterSchema();
|
|
17
|
+
const store = new Vuex.Store({
|
|
18
|
+
modules: {
|
|
19
|
+
[namespace]: {
|
|
20
|
+
namespaced: true,
|
|
21
|
+
state: {
|
|
22
|
+
[filterQuery]: filterSchema,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
15
27
|
|
|
16
28
|
const mountOptions = {
|
|
29
|
+
localVue,
|
|
30
|
+
store,
|
|
31
|
+
router,
|
|
17
32
|
propsData: {
|
|
18
33
|
namespace,
|
|
19
34
|
filterQuery,
|
|
20
35
|
},
|
|
21
|
-
computed: {
|
|
22
|
-
filterSchema() { return filterSchema; },
|
|
23
|
-
},
|
|
24
36
|
};
|
|
25
|
-
|
|
26
|
-
jest.spyOn(baseFilterMixin.methods, 'setValue').mockImplementation(setValue);
|
|
27
|
-
jest.spyOn(baseFilterMixin.methods, 'setValueToQuery').mockImplementation(setValueToQuery);
|
|
28
|
-
jest.spyOn(baseFilterMixin.methods, 'getValueFromQuery').mockImplementation(getValueFromQuery);
|
|
29
|
-
|
|
30
|
-
beforeEach(() => {
|
|
31
|
-
setValue.mockClear();
|
|
32
|
-
setValueToQuery.mockClear();
|
|
33
|
-
getValueFromQuery.mockClear();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
37
|
it('renders a component', () => {
|
|
37
38
|
const wrapper = shallowMount(SearchFilter, mountOptions);
|
|
38
39
|
expect(wrapper.exists()).toBe(true);
|
|
39
40
|
});
|
|
40
41
|
it('initial restoreValue() triggers setValue() method', async () => {
|
|
42
|
+
const search = 'jest';
|
|
43
|
+
await router.replace({ query: { [filterQuery]: search } });
|
|
44
|
+
const setValueMock = jest.fn();
|
|
45
|
+
jest.spyOn(baseFilterMixin.methods, 'setValue').mockImplementationOnce(setValueMock);
|
|
41
46
|
shallowMount(SearchFilter, mountOptions);
|
|
42
|
-
expect(
|
|
47
|
+
expect(setValueMock).toHaveBeenCalledWith({ filter: filterQuery, value: search });
|
|
43
48
|
});
|
|
44
49
|
});
|
|
@@ -1,48 +1,47 @@
|
|
|
1
|
-
import { shallowMount } from '@vue/test-utils';
|
|
1
|
+
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
|
2
|
+
import VueRouter from 'vue-router';
|
|
2
3
|
import ApiFilterSchema from '../../classes/ApiFilterSchema';
|
|
3
4
|
import apiFilterMixin from '../apiFilterMixin';
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
+
const localVue = createLocalVue();
|
|
7
|
+
localVue.use(VueRouter);
|
|
8
|
+
const router = new VueRouter();
|
|
6
9
|
const team = ['1', '2'];
|
|
7
10
|
const filterSchema = new ApiFilterSchema();
|
|
8
11
|
|
|
9
12
|
describe('API filter mixin', () => {
|
|
10
13
|
const setValue = jest.fn();
|
|
11
|
-
const setValueToQuery = jest.fn();
|
|
12
|
-
const getValueFromQuery = jest.fn(() => team);
|
|
13
|
-
|
|
14
14
|
const Component = {
|
|
15
15
|
render() {},
|
|
16
16
|
mixins: [apiFilterMixin],
|
|
17
17
|
data: () => ({
|
|
18
|
-
filterQuery,
|
|
18
|
+
filterQuery: 'team',
|
|
19
19
|
}),
|
|
20
20
|
computed: {
|
|
21
21
|
filterSchema() { return filterSchema; },
|
|
22
22
|
},
|
|
23
|
-
methods: {
|
|
24
|
-
setValue,
|
|
25
|
-
setValueToQuery,
|
|
26
|
-
getValueFromQuery,
|
|
27
|
-
},
|
|
23
|
+
methods: { setValue },
|
|
28
24
|
};
|
|
29
25
|
|
|
30
26
|
beforeEach(() => {
|
|
31
27
|
setValue.mockClear();
|
|
32
|
-
|
|
33
|
-
getValueFromQuery.mockClear();
|
|
28
|
+
if (Object.keys(router.currentRoute.query).length) router.replace({ query: null });
|
|
34
29
|
});
|
|
35
30
|
|
|
36
31
|
it('Correctly sets value from $route query', async () => {
|
|
32
|
+
await router.replace({ query: { team } });
|
|
37
33
|
const wrapper = shallowMount(Component, {
|
|
34
|
+
localVue,
|
|
35
|
+
router,
|
|
38
36
|
});
|
|
39
37
|
expect(setValue).toHaveBeenCalledWith({ filter: 'team', value: [{ id: team[0] }, { id: team[1] }] });
|
|
40
38
|
});
|
|
41
39
|
|
|
42
40
|
it('Sets empty array value if $route query is empty', async () => {
|
|
43
|
-
getValueFromQuery.mockImplementationOnce(() => []);
|
|
44
41
|
const wrapper = shallowMount(Component, {
|
|
45
|
-
|
|
42
|
+
localVue,
|
|
43
|
+
router,
|
|
44
|
+
data: () => ({ filterQuery: 'queue' }),
|
|
46
45
|
});
|
|
47
46
|
expect(setValue).not.toHaveBeenCalled();
|
|
48
47
|
});
|
|
@@ -1,84 +1,69 @@
|
|
|
1
|
-
import { shallowMount } from '@vue/test-utils';
|
|
2
|
-
import
|
|
1
|
+
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
|
2
|
+
import VueRouter from 'vue-router';
|
|
3
3
|
import enumFilterMixin from '../enumFilterMixin';
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const options = [
|
|
7
|
-
{
|
|
5
|
+
const options = [{
|
|
8
6
|
name: 'Inbound',
|
|
9
7
|
value: 'inbound',
|
|
10
|
-
},
|
|
8
|
+
},
|
|
9
|
+
{
|
|
11
10
|
name: 'Outbound',
|
|
12
11
|
value: 'outbound',
|
|
13
|
-
}
|
|
14
|
-
];
|
|
12
|
+
}];
|
|
15
13
|
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
options,
|
|
20
|
-
storedProp: 'value',
|
|
21
|
-
});
|
|
14
|
+
const localVue = createLocalVue();
|
|
15
|
+
localVue.use(VueRouter);
|
|
16
|
+
const router = new VueRouter();
|
|
22
17
|
|
|
23
18
|
describe('Enum filter mixin', () => {
|
|
24
19
|
const setValue = jest.fn();
|
|
25
|
-
const setValueToQuery = jest.fn();
|
|
26
|
-
const getValueFromQuery = jest.fn(() => queryValue);
|
|
27
|
-
|
|
28
20
|
const Component = {
|
|
29
21
|
render() {
|
|
30
22
|
},
|
|
31
23
|
mixins: [enumFilterMixin],
|
|
32
24
|
data: () => ({
|
|
33
|
-
filterQuery,
|
|
25
|
+
filterQuery: 'direction',
|
|
26
|
+
storedProp: 'value',
|
|
27
|
+
options,
|
|
34
28
|
}),
|
|
35
|
-
|
|
36
|
-
filterSchema() { return filterSchema; },
|
|
37
|
-
},
|
|
38
|
-
methods: {
|
|
39
|
-
setValue,
|
|
40
|
-
setValueToQuery,
|
|
41
|
-
getValueFromQuery,
|
|
42
|
-
},
|
|
29
|
+
methods: { setValue },
|
|
43
30
|
};
|
|
44
31
|
|
|
45
32
|
beforeEach(() => {
|
|
46
33
|
setValue.mockClear();
|
|
47
|
-
|
|
48
|
-
getValueFromQuery.mockClear();
|
|
34
|
+
if (Object.keys(router.currentRoute.query).length) router.replace({ query: null });
|
|
49
35
|
});
|
|
50
36
|
|
|
51
37
|
it('Correctly sets value from $route query', async () => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
38
|
+
await router.replace({ query: { direction: options[0].value } });
|
|
39
|
+
const wrapper = shallowMount(Component, {
|
|
40
|
+
localVue,
|
|
41
|
+
router,
|
|
42
|
+
});
|
|
43
|
+
await wrapper.vm.$nextTick();
|
|
44
|
+
expect(setValue).toHaveBeenCalledWith({ filter: 'direction', value: options[0] });
|
|
55
45
|
});
|
|
56
46
|
|
|
57
47
|
it('Sets empty array value if $route query is empty', async () => {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
48
|
+
shallowMount(Component, {
|
|
49
|
+
localVue,
|
|
50
|
+
router,
|
|
51
|
+
});
|
|
61
52
|
expect(setValue).not.toHaveBeenCalled();
|
|
62
53
|
});
|
|
63
54
|
|
|
64
55
|
it('Attaches locales to options, if they have "locale" key', async () => {
|
|
65
|
-
const options = [
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
locale: options[0].locale,
|
|
73
|
-
name: options[0].locale,
|
|
74
|
-
},
|
|
75
|
-
];
|
|
56
|
+
const options = [{
|
|
57
|
+
locale: 'jest.locale',
|
|
58
|
+
}];
|
|
59
|
+
const expectedOptions = [{
|
|
60
|
+
locale: options[0].locale,
|
|
61
|
+
name: options[0].locale,
|
|
62
|
+
}];
|
|
76
63
|
const wrapper = shallowMount(Component, {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
},
|
|
81
|
-
},
|
|
64
|
+
localVue,
|
|
65
|
+
router,
|
|
66
|
+
data: () => ({ options }),
|
|
82
67
|
});
|
|
83
68
|
expect(wrapper.vm.localizedOptions).toEqual(expectedOptions);
|
|
84
69
|
});
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { createLocalVue, shallowMount } from '@vue/test-utils';
|
|
2
|
+
import VueRouter from 'vue-router';
|
|
3
|
+
import paginationFilterMixin from '../paginationFilterMixin';
|
|
4
|
+
|
|
5
|
+
const localVue = createLocalVue();
|
|
6
|
+
localVue.use(VueRouter);
|
|
7
|
+
const router = new VueRouter();
|
|
8
|
+
const page = 2;
|
|
9
|
+
const size = 20;
|
|
10
|
+
|
|
11
|
+
describe('Pagination filter mixin', () => {
|
|
12
|
+
const setPage = jest.fn();
|
|
13
|
+
const setSize = jest.fn();
|
|
14
|
+
let wrapper;
|
|
15
|
+
const Component = {
|
|
16
|
+
render() {},
|
|
17
|
+
mixins: [paginationFilterMixin],
|
|
18
|
+
data: () => ({ page, size }),
|
|
19
|
+
methods: { setPage, setSize },
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
setPage.mockClear();
|
|
24
|
+
setSize.mockClear();
|
|
25
|
+
if (Object.keys(router.currentRoute.query).length) router.replace({ query: null });
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('Correctly sets value from $route query', async () => {
|
|
29
|
+
await router.replace({ query: { page, size } });
|
|
30
|
+
wrapper = shallowMount(Component, {
|
|
31
|
+
localVue,
|
|
32
|
+
router,
|
|
33
|
+
});
|
|
34
|
+
expect(setPage).toHaveBeenCalledWith(page);
|
|
35
|
+
expect(setSize).toHaveBeenCalledWith(size);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('At "prev" page, changes query and emits event', async () => {
|
|
39
|
+
await router.replace({ query: { page, size } });
|
|
40
|
+
wrapper = shallowMount(Component, {
|
|
41
|
+
localVue,
|
|
42
|
+
router,
|
|
43
|
+
});
|
|
44
|
+
wrapper._emitted.input = []; // reset emitted events
|
|
45
|
+
wrapper.vm.prev();
|
|
46
|
+
expect(wrapper.emitted().input).toBeTruthy();
|
|
47
|
+
expect(wrapper.vm.$route.query.page).toBe(`${page - 1}`);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('At "next" page, changes query and emits event', async () => {
|
|
51
|
+
await router.replace({ query: { page, size } });
|
|
52
|
+
wrapper = shallowMount(Component, {
|
|
53
|
+
localVue,
|
|
54
|
+
router,
|
|
55
|
+
});
|
|
56
|
+
wrapper._emitted.input = []; // reset emitted events
|
|
57
|
+
wrapper.vm.next();
|
|
58
|
+
expect(wrapper.emitted().input).toBeTruthy();
|
|
59
|
+
expect(wrapper.vm.$route.query.page).toBe(`${page + 1}`);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('At "restPage" method, changes query and emits event', async () => {
|
|
63
|
+
await router.replace({ query: { page: 100, size } });
|
|
64
|
+
wrapper = shallowMount(Component, {
|
|
65
|
+
localVue,
|
|
66
|
+
router,
|
|
67
|
+
});
|
|
68
|
+
wrapper._emitted.input = []; // reset emitted events
|
|
69
|
+
wrapper.vm.resetPage();
|
|
70
|
+
expect(wrapper.emitted().input).toBeTruthy();
|
|
71
|
+
expect(wrapper.vm.$route.query.page).toBe('1');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('At "sizeChange", changes query and emits event', async () => {
|
|
75
|
+
const newSize = 40;
|
|
76
|
+
await router.replace({ query: { page, size } });
|
|
77
|
+
wrapper = shallowMount(Component, {
|
|
78
|
+
localVue,
|
|
79
|
+
router,
|
|
80
|
+
});
|
|
81
|
+
wrapper._emitted.input = []; // reset emitted events
|
|
82
|
+
wrapper.vm.sizeChange(newSize);
|
|
83
|
+
expect(wrapper.emitted().input).toBeTruthy();
|
|
84
|
+
expect(wrapper.vm.$route.query.size).toBe(`${newSize}`);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { shallowMount } from '@vue/test-utils';
|
|
1
|
+
import { shallowMount, createLocalVue } from '@vue/test-utils';
|
|
2
|
+
import VueRouter from 'vue-router';
|
|
2
3
|
import sortFilterMixin from '../sortFilterMixin';
|
|
3
4
|
|
|
5
|
+
const localVue = createLocalVue();
|
|
6
|
+
localVue.use(VueRouter);
|
|
7
|
+
const router = new VueRouter();
|
|
8
|
+
|
|
4
9
|
const headers = [{
|
|
5
10
|
value: 'queue',
|
|
6
11
|
show: true,
|
|
@@ -25,37 +30,27 @@ const sortedHeaders = [{
|
|
|
25
30
|
field: 'online',
|
|
26
31
|
}];
|
|
27
32
|
|
|
28
|
-
const queryValue = '+queue';
|
|
29
|
-
|
|
30
33
|
describe('Sort filter mixin', () => {
|
|
31
34
|
const setHeaders = jest.fn();
|
|
32
|
-
const setValueToQuery = jest.fn();
|
|
33
|
-
const getValueFromQuery = jest.fn(() => queryValue);
|
|
34
|
-
|
|
35
35
|
const Component = {
|
|
36
36
|
render() {},
|
|
37
37
|
mixins: [sortFilterMixin],
|
|
38
38
|
data: () => ({ headers }),
|
|
39
|
-
methods: {
|
|
40
|
-
setHeaders,
|
|
41
|
-
setValueToQuery,
|
|
42
|
-
getValueFromQuery,
|
|
43
|
-
},
|
|
39
|
+
methods: { setHeaders },
|
|
44
40
|
};
|
|
45
41
|
|
|
46
42
|
beforeEach(() => {
|
|
47
|
-
|
|
48
|
-
setValueToQuery.mockClear();
|
|
49
|
-
getValueFromQuery.mockClear();
|
|
43
|
+
router.replace('/');
|
|
50
44
|
});
|
|
51
45
|
|
|
52
46
|
it('Correctly sets value from $route query', async () => {
|
|
53
|
-
|
|
47
|
+
await router.replace({ path: '/', query: { sort: '+queue' } });
|
|
48
|
+
const wrapper = shallowMount(Component, { localVue, router });
|
|
54
49
|
expect(setHeaders).toHaveBeenCalledWith(sortedHeaders);
|
|
55
50
|
});
|
|
56
51
|
|
|
57
52
|
it('After "sort" trigger, header column sort value changes properly', () => {
|
|
58
|
-
const wrapper = shallowMount(Component);
|
|
53
|
+
const wrapper = shallowMount(Component, { localVue, router });
|
|
59
54
|
const queue = wrapper.vm.headers.find((header) => header.value === 'queue');
|
|
60
55
|
wrapper.vm.sort(queue);
|
|
61
56
|
expect(setHeaders).toHaveBeenCalledWith(sortedHeaders);
|