@farm-investimentos/front-mfe-components 3.1.0 → 3.3.0

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.
@@ -0,0 +1,130 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import SelectModalOptions from '../SelectModalOptions';
3
+
4
+ describe('SelectModalOptions component', () => {
5
+ let wrapper;
6
+ let component;
7
+
8
+ beforeEach(() => {
9
+ wrapper = shallowMount(SelectModalOptions, {
10
+ propsData: {
11
+ value: 1,
12
+ inputId: 'some-id',
13
+ label: '',
14
+ pagination: {
15
+ page: 1,
16
+ itemsPerPage: 10,
17
+ pages: 0,
18
+ },
19
+ },
20
+ });
21
+ component = wrapper.vm;
22
+ });
23
+
24
+ test('SelectModalOptions created', () => {
25
+ expect(wrapper).toBeDefined();
26
+ });
27
+
28
+ describe('Methods', () => {
29
+ it('Should open modal', () => {
30
+ component.openModal();
31
+ expect(component.showModal).toBeTruthy();
32
+ });
33
+
34
+ it('Should close close', () => {
35
+ component.closeModal();
36
+ expect(component.showModal).toBeFalsy();
37
+ });
38
+
39
+ it('Should get item value', async () => {
40
+ expect(component.getItemLabel({ name: 'a' })).toEqual('a');
41
+
42
+ await wrapper.setProps({ itemLabelFormatter: item => item.name + ' ' + item.id });
43
+ expect(component.getItemLabel({ name: 'a', id: 'b' })).toEqual('a b');
44
+ });
45
+
46
+ it('Should handle click', () => {
47
+ component.handleClick({ name: 'a', id: 1 });
48
+ expect(component.inputVal).toEqual(1);
49
+ expect(component.selectedItem.id).toEqual(1);
50
+ });
51
+ });
52
+
53
+ describe('Computed properties', () => {
54
+ it('Should check if is loading', () => {
55
+ expect(component.isLoading).toBeFalsy();
56
+ });
57
+
58
+ it('Should return 0 when items are empty', () => {
59
+ expect(component.totalPages).toBe(0);
60
+ });
61
+
62
+ it('Should return 0 when items are empty', async () => {
63
+ await wrapper.setProps({
64
+ items: new Array(30).fill(0),
65
+ });
66
+ expect(component.totalPages).toBe(3);
67
+ });
68
+
69
+ it('Should return 0 when items are empty', async () => {
70
+ await wrapper.setProps({
71
+ items: new Array(30).fill(0),
72
+ });
73
+ expect(component.totalPages).toBe(3);
74
+ });
75
+ });
76
+
77
+ describe('Watch methods', () => {
78
+ it('Should reset selectedItem', () => {
79
+ component.$options.watch.value.call(component, undefined);
80
+ expect(component.selectedItem).toEqual(null);
81
+ });
82
+ it('Should reset selectedItem', () => {
83
+ component.$options.watch.items.call(component, new Array(50));
84
+
85
+ expect(component.pagination.pages).toBe(5);
86
+ });
87
+ it('Should change pagination', () => {
88
+ expect(component.pagination).toEqual({
89
+ page: 1,
90
+ itemsPerPage: 10,
91
+ pages: 0,
92
+ });
93
+ component.handlePagination({
94
+ page: 1,
95
+ itemsLength: 1,
96
+ });
97
+ expect(component.pagination).toEqual({
98
+ page: 1,
99
+ itemsPerPage: 10,
100
+ pages: 1,
101
+ });
102
+ });
103
+ it('Should not change pagination', () => {
104
+ expect(component.pagination).toEqual({
105
+ page: 1,
106
+ itemsPerPage: 10,
107
+ pages: 0,
108
+ });
109
+ component.handlePagination({
110
+ page: 2,
111
+ itemsLength: 30,
112
+ });
113
+ expect(component.pagination).toEqual({
114
+ page: 1,
115
+ itemsPerPage: 10,
116
+ pages: 0,
117
+ });
118
+ });
119
+
120
+ it('Should change page', () => {
121
+ component.onChangePage(2);
122
+ expect(component.pagination.page).toBe(2);
123
+ });
124
+
125
+ it('Should do customFilter', () => {
126
+ expect(component.customFilter({}, 'key', { name: '21321' })).toBeFalsy();
127
+ expect(component.customFilter({}, 'key', { name: 'aS KEY SDSA' })).toBeTruthy();
128
+ });
129
+ });
130
+ });
@@ -0,0 +1,4 @@
1
+ import SelectModalOptions from './SelectModalOptions';
2
+
3
+ export { SelectModalOptions };
4
+ export default SelectModalOptions;
package/src/main.js CHANGED
@@ -51,7 +51,9 @@ export * from './components/Buttons/ExportButton/';
51
51
  export * from './components/Buttons/ImportButton/';
52
52
  export * from './components/Buttons/ToggleButton/';
53
53
  export * from './components/Buttons/RemoveButton/';
54
+ export * from './components/Buttons/MultiImportButton/';
54
55
  export * from './components/Logos/ProductLogo/';
55
56
  export * from './components/Logos/OriginatorLogo/';
56
57
  export * from './components/ResetTableRowSelection/';
57
58
  export * from './components/MultipleSelectShortener/';
59
+ export * from './components/SelectModalOptions/';