@webitel/ui-sdk 2.0.2 → 2.0.3
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
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { shallowMount, createLocalVue } from '@vue/test-utils';
|
|
2
|
+
import Vuex from 'vuex';
|
|
3
|
+
import VueRouter from 'vue-router';
|
|
4
|
+
import DatetimeFilter from '../filter-datetime.vue';
|
|
5
|
+
import BaseFilterSchema from '../../classes/BaseFilterSchema';
|
|
6
|
+
import baseFilterMixin from '../../mixins/baseFilterMixin/baseFilterMixin';
|
|
7
|
+
|
|
8
|
+
const localVue = createLocalVue();
|
|
9
|
+
localVue.use(Vuex);
|
|
10
|
+
localVue.use(VueRouter);
|
|
11
|
+
const router = new VueRouter();
|
|
12
|
+
|
|
13
|
+
describe('DatetimeFilter Filter', () => {
|
|
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
|
+
});
|
|
27
|
+
|
|
28
|
+
const mountOptions = {
|
|
29
|
+
localVue,
|
|
30
|
+
store,
|
|
31
|
+
router,
|
|
32
|
+
propsData: {
|
|
33
|
+
namespace,
|
|
34
|
+
filterQuery,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
it('renders a component', () => {
|
|
38
|
+
const wrapper = shallowMount(DatetimeFilter, mountOptions);
|
|
39
|
+
expect(wrapper.exists()).toBe(true);
|
|
40
|
+
});
|
|
41
|
+
it('initial restoreValue() triggers setValue() method', async () => {
|
|
42
|
+
const value = Date.now();
|
|
43
|
+
await router.replace({ query: { [filterQuery]: value } });
|
|
44
|
+
const setValueMock = jest.fn();
|
|
45
|
+
jest.spyOn(baseFilterMixin.methods, 'setValue').mockImplementationOnce(setValueMock);
|
|
46
|
+
shallowMount(DatetimeFilter, mountOptions);
|
|
47
|
+
expect(setValueMock).toHaveBeenCalledWith({ filter: filterQuery, value });
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<wt-datetimepicker
|
|
3
|
+
:value="filterSchema.value"
|
|
4
|
+
:label="label"
|
|
5
|
+
@change="handleChange"
|
|
6
|
+
></wt-datetimepicker>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
import baseFilterMixin from '../mixins/baseFilterMixin/baseFilterMixin';
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
name: 'filter-from',
|
|
14
|
+
mixins: [baseFilterMixin],
|
|
15
|
+
props: {
|
|
16
|
+
filterQuery: {
|
|
17
|
+
type: String,
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
label: {
|
|
21
|
+
type: String,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
methods: {
|
|
26
|
+
handleChange(value) {
|
|
27
|
+
this.setValue({ filter: this.filterQuery, value });
|
|
28
|
+
this.setValueToQuery({ filterQuery: this.filterQuery, value });
|
|
29
|
+
},
|
|
30
|
+
restoreValue(value) {
|
|
31
|
+
this.setValue({ filter: this.filterQuery, value: +value });
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<style scoped>
|
|
38
|
+
|
|
39
|
+
</style>
|