@zeedhi/teknisa-components-common 1.48.0 → 1.53.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.
- package/coverage/clover.xml +437 -308
- package/coverage/coverage-final.json +38 -31
- package/coverage/lcov-report/index.html +39 -9
- package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +100 -0
- package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +166 -0
- package/coverage/lcov-report/tests/__helpers__/index.html +161 -0
- package/coverage/lcov-report/tests/__helpers__/index.ts.html +94 -0
- package/coverage/lcov-report/tests/__helpers__/mock-created-helper.ts.html +121 -0
- package/coverage/lcov.info +688 -406
- package/dist/tek-components-common.esm.js +1 -0
- package/dist/tek-components-common.umd.js +1 -0
- package/package.json +2 -2
- package/tests/__helpers__/component-event-helper.ts +5 -0
- package/tests/__helpers__/get-child-helper.ts +27 -0
- package/tests/__helpers__/index.ts +3 -0
- package/tests/__helpers__/mock-created-helper.ts +5 -3
- package/tests/unit/components/tek-grid/grid.spec.ts +514 -531
- package/tests/unit/components/tek-user-info/tek-user-info-list.spec.ts +2 -1
- package/tests/unit/components/tek-user-info/tek-user-info.spec.ts +2 -1
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
/* eslint-disable no-underscore-dangle */
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
Button, Date, Dropdown, Form, IButton, IForm, IModal, Modal, ModalService, Search,
|
|
4
|
+
Button, Date, Dropdown, Form, IButton, IForm, IModal, Modal, ModalService, Search, TextInput, Text,
|
|
5
5
|
} from '@zeedhi/common';
|
|
6
6
|
import {
|
|
7
|
-
KeyMap, Http, Metadata,
|
|
7
|
+
KeyMap, Http, Metadata, DateHelper, IDictionary,
|
|
8
8
|
} from '@zeedhi/core';
|
|
9
9
|
import {
|
|
10
10
|
IFilterPropsComponent,
|
|
11
11
|
ITekGrid,
|
|
12
12
|
TekGrid, TekGridColumn, TekRestDatasource,
|
|
13
13
|
} from '../../../../src';
|
|
14
|
+
import { setClick, getChild } from '../../../__helpers__';
|
|
15
|
+
|
|
16
|
+
jest.mock('lodash.debounce', () => jest.fn((fn) => fn));
|
|
17
|
+
|
|
18
|
+
jest.useFakeTimers();
|
|
19
|
+
|
|
20
|
+
const clickOnFilterButton = (grid: TekGrid, event?: any) => {
|
|
21
|
+
const buttonProps = getChild<IButton>(grid.toolbarSlot, `${grid.name}_filterButton`);
|
|
22
|
+
const button = new Button(buttonProps);
|
|
23
|
+
setClick(button, event);
|
|
24
|
+
|
|
25
|
+
return button;
|
|
26
|
+
};
|
|
14
27
|
|
|
15
28
|
describe('TekGrid', () => {
|
|
16
29
|
beforeEach(() => {
|
|
@@ -19,6 +32,8 @@ describe('TekGrid', () => {
|
|
|
19
32
|
Object.keys(instances).forEach((key) => {
|
|
20
33
|
Metadata.clearInstance(key, instances[key].componentId);
|
|
21
34
|
});
|
|
35
|
+
|
|
36
|
+
jest.clearAllTimers();
|
|
22
37
|
});
|
|
23
38
|
|
|
24
39
|
describe('constructor()', () => {
|
|
@@ -191,7 +206,7 @@ describe('TekGrid', () => {
|
|
|
191
206
|
});
|
|
192
207
|
|
|
193
208
|
afterEach(() => {
|
|
194
|
-
httpReportSpy.
|
|
209
|
+
httpReportSpy.mockReset();
|
|
195
210
|
});
|
|
196
211
|
|
|
197
212
|
it('should call getReport on export button click', () => {
|
|
@@ -212,7 +227,7 @@ describe('TekGrid', () => {
|
|
|
212
227
|
button.click(event, {} as HTMLElement);
|
|
213
228
|
|
|
214
229
|
expect(spy).toBeCalledTimes(1);
|
|
215
|
-
spy.
|
|
230
|
+
spy.mockReset();
|
|
216
231
|
|
|
217
232
|
(window as any).open.mockClear();
|
|
218
233
|
});
|
|
@@ -262,8 +277,8 @@ describe('TekGrid', () => {
|
|
|
262
277
|
expect(spy).toHaveBeenCalledTimes(1);
|
|
263
278
|
|
|
264
279
|
(window as any).open.mockClear();
|
|
265
|
-
spy.
|
|
266
|
-
httpSpy.
|
|
280
|
+
spy.mockReset();
|
|
281
|
+
httpSpy.mockReset();
|
|
267
282
|
});
|
|
268
283
|
});
|
|
269
284
|
|
|
@@ -281,7 +296,7 @@ describe('TekGrid', () => {
|
|
|
281
296
|
button.click(event, {} as HTMLElement);
|
|
282
297
|
expect(spy).toBeCalled();
|
|
283
298
|
expect(button.isVisible).toBeFalsy();
|
|
284
|
-
spy.
|
|
299
|
+
spy.mockReset();
|
|
285
300
|
});
|
|
286
301
|
|
|
287
302
|
it('should call events', () => {
|
|
@@ -323,7 +338,7 @@ describe('TekGrid', () => {
|
|
|
323
338
|
expect(beforeSaveCalled).toBeTruthy();
|
|
324
339
|
expect(afterSaveCalled).toBeFalsy();
|
|
325
340
|
expect(spy).not.toBeCalled();
|
|
326
|
-
spy.
|
|
341
|
+
spy.mockReset();
|
|
327
342
|
});
|
|
328
343
|
});
|
|
329
344
|
|
|
@@ -341,7 +356,7 @@ describe('TekGrid', () => {
|
|
|
341
356
|
button.click(event, {} as HTMLElement);
|
|
342
357
|
expect(spy).toBeCalled();
|
|
343
358
|
expect(button.isVisible).toBeFalsy();
|
|
344
|
-
spy.
|
|
359
|
+
spy.mockReset();
|
|
345
360
|
});
|
|
346
361
|
|
|
347
362
|
it('should call events', () => {
|
|
@@ -383,7 +398,7 @@ describe('TekGrid', () => {
|
|
|
383
398
|
expect(beforeCancelCalled).toBeTruthy();
|
|
384
399
|
expect(afterCancelCalled).toBeFalsy();
|
|
385
400
|
expect(spy).not.toBeCalled();
|
|
386
|
-
spy.
|
|
401
|
+
spy.mockReset();
|
|
387
402
|
});
|
|
388
403
|
});
|
|
389
404
|
|
|
@@ -440,7 +455,7 @@ describe('TekGrid', () => {
|
|
|
440
455
|
expect(button.disabled).toBeTruthy();
|
|
441
456
|
}
|
|
442
457
|
}
|
|
443
|
-
spy.
|
|
458
|
+
spy.mockReset();
|
|
444
459
|
});
|
|
445
460
|
|
|
446
461
|
it('should call events', () => {
|
|
@@ -496,7 +511,7 @@ describe('TekGrid', () => {
|
|
|
496
511
|
expect(spy).not.toBeCalled();
|
|
497
512
|
}
|
|
498
513
|
}
|
|
499
|
-
spy.
|
|
514
|
+
spy.mockReset();
|
|
500
515
|
});
|
|
501
516
|
});
|
|
502
517
|
|
|
@@ -509,6 +524,16 @@ describe('TekGrid', () => {
|
|
|
509
524
|
};
|
|
510
525
|
|
|
511
526
|
it('should navigate through grid lines using keys', async () => {
|
|
527
|
+
const httpSpy = jest.spyOn(Http, 'get').mockImplementation(() => Promise.resolve({
|
|
528
|
+
data: {
|
|
529
|
+
data: [],
|
|
530
|
+
pagination: {
|
|
531
|
+
page: 1,
|
|
532
|
+
total: 0,
|
|
533
|
+
limit: 10,
|
|
534
|
+
},
|
|
535
|
+
},
|
|
536
|
+
}));
|
|
512
537
|
const flushPromises = () => new Promise(setImmediate);
|
|
513
538
|
const instance = new TekGrid({
|
|
514
539
|
name: 'grid_navigation_1',
|
|
@@ -560,9 +585,21 @@ describe('TekGrid', () => {
|
|
|
560
585
|
|
|
561
586
|
dispatchEvent(37, {}); // arrow left
|
|
562
587
|
expect(instance.datasource.currentRow).toEqual(instance.datasource.data[0]);
|
|
588
|
+
|
|
589
|
+
httpSpy.mockReset();
|
|
563
590
|
});
|
|
564
591
|
|
|
565
|
-
it('should navigate through grid lines using keys when grouped', async (
|
|
592
|
+
it('should navigate through grid lines using keys when grouped', async () => {
|
|
593
|
+
const httpSpy = jest.spyOn(Http, 'get').mockImplementation(() => Promise.resolve({
|
|
594
|
+
data: {
|
|
595
|
+
data: [],
|
|
596
|
+
pagination: {
|
|
597
|
+
page: 1,
|
|
598
|
+
total: 0,
|
|
599
|
+
limit: 10,
|
|
600
|
+
},
|
|
601
|
+
},
|
|
602
|
+
}));
|
|
566
603
|
const flushPromises = () => new Promise(setImmediate);
|
|
567
604
|
const instance = new TekGrid({
|
|
568
605
|
name: 'grid_navigation_2',
|
|
@@ -597,68 +634,66 @@ describe('TekGrid', () => {
|
|
|
597
634
|
|
|
598
635
|
await flushPromises();
|
|
599
636
|
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
instance.onMounted(elem);
|
|
637
|
+
const elem = document.createElement('DIV');
|
|
638
|
+
(KeyMap as any).isElementActive = () => true;
|
|
639
|
+
instance.onCreated();
|
|
640
|
+
instance.onMounted(elem);
|
|
605
641
|
|
|
606
|
-
|
|
607
|
-
|
|
642
|
+
dispatchEvent(40, {}); // arrow down
|
|
643
|
+
expect(instance.datasource.currentRow).toEqual(instance.groupedData[0]);
|
|
608
644
|
|
|
609
|
-
|
|
610
|
-
|
|
645
|
+
dispatchEvent(40, {}); // arrow down
|
|
646
|
+
expect(instance.datasource.currentRow).toEqual(instance.groupedData[4]);
|
|
611
647
|
|
|
612
|
-
|
|
613
|
-
|
|
648
|
+
dispatchEvent(40, {}); // arrow down
|
|
649
|
+
expect(instance.datasource.currentRow).toEqual(instance.groupedData[4]);
|
|
614
650
|
|
|
615
|
-
|
|
616
|
-
|
|
651
|
+
dispatchEvent(38, {}); // arrow up
|
|
652
|
+
expect(instance.datasource.currentRow).toEqual(instance.groupedData[0]);
|
|
617
653
|
|
|
618
|
-
|
|
619
|
-
|
|
654
|
+
dispatchEvent(38, {}); // arrow up
|
|
655
|
+
expect(instance.datasource.currentRow).toEqual(instance.groupedData[0]);
|
|
620
656
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
657
|
+
instance.datasource.currentRow = {};
|
|
658
|
+
dispatchEvent(38, {}); // arrow up
|
|
659
|
+
expect(instance.datasource.currentRow).toEqual(instance.groupedData[4]);
|
|
624
660
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
661
|
+
[instance.datasource.currentRow] = instance.groupedData;
|
|
662
|
+
expect(instance.datasource.currentRow.groupOpened).toBeFalsy();
|
|
663
|
+
dispatchEvent(39, {}); // arrow right
|
|
664
|
+
expect(instance.datasource.currentRow.groupOpened).toBeTruthy();
|
|
629
665
|
|
|
630
|
-
|
|
631
|
-
|
|
666
|
+
dispatchEvent(40, {}); // arrow down
|
|
667
|
+
expect(instance.datasource.currentRow).toEqual(instance.groupedData[1]);
|
|
632
668
|
|
|
633
|
-
|
|
634
|
-
|
|
669
|
+
dispatchEvent(40, {}); // arrow down
|
|
670
|
+
expect(instance.datasource.currentRow).toEqual(instance.groupedData[2]);
|
|
635
671
|
|
|
636
|
-
|
|
637
|
-
|
|
672
|
+
dispatchEvent(38, {}); // arrow up
|
|
673
|
+
expect(instance.datasource.currentRow).toEqual(instance.groupedData[1]);
|
|
638
674
|
|
|
639
|
-
|
|
640
|
-
|
|
675
|
+
dispatchEvent(37, {}); // arrow left
|
|
676
|
+
expect(instance.datasource.currentRow).toEqual(instance.groupedData[0]);
|
|
641
677
|
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
678
|
+
expect(instance.datasource.currentRow.groupOpened).toBeTruthy();
|
|
679
|
+
dispatchEvent(37, {}); // arrow left
|
|
680
|
+
expect(instance.datasource.currentRow.groupOpened).toBeFalsy();
|
|
645
681
|
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
682
|
+
[, , , , instance.datasource.currentRow] = instance.groupedData;
|
|
683
|
+
expect(instance.datasource.currentRow.groupOpened).toBeFalsy();
|
|
684
|
+
dispatchEvent(39, {}); // arrow right
|
|
685
|
+
expect(instance.datasource.currentRow.groupOpened).toBeTruthy();
|
|
650
686
|
|
|
651
|
-
|
|
652
|
-
|
|
687
|
+
dispatchEvent(40, {}); // arrow down
|
|
688
|
+
expect(instance.datasource.currentRow).toEqual(instance.groupedData[5]);
|
|
653
689
|
|
|
654
|
-
|
|
655
|
-
|
|
690
|
+
dispatchEvent(40, {}); // arrow down
|
|
691
|
+
expect(instance.datasource.currentRow).toEqual(instance.groupedData[6]);
|
|
656
692
|
|
|
657
|
-
|
|
658
|
-
|
|
693
|
+
dispatchEvent(40, {}); // arrow down
|
|
694
|
+
expect(instance.datasource.currentRow).toEqual(instance.groupedData[6]);
|
|
659
695
|
|
|
660
|
-
|
|
661
|
-
}, 1000);
|
|
696
|
+
httpSpy.mockReset();
|
|
662
697
|
});
|
|
663
698
|
|
|
664
699
|
it('should open filter modal input with keymap', async () => {
|
|
@@ -693,7 +728,7 @@ describe('TekGrid', () => {
|
|
|
693
728
|
|
|
694
729
|
expect(method).toHaveBeenCalled();
|
|
695
730
|
(KeyMap as any).isElementActive = () => false;
|
|
696
|
-
spyMetadata.
|
|
731
|
+
spyMetadata.mockReset();
|
|
697
732
|
});
|
|
698
733
|
|
|
699
734
|
it('should open action dropdown with keymap', async () => {
|
|
@@ -731,8 +766,8 @@ describe('TekGrid', () => {
|
|
|
731
766
|
await flushPromises();
|
|
732
767
|
|
|
733
768
|
(KeyMap as any).isElementActive = () => false;
|
|
734
|
-
spyMetadata.
|
|
735
|
-
instanceDropDownSpy.
|
|
769
|
+
spyMetadata.mockReset();
|
|
770
|
+
instanceDropDownSpy.mockReset();
|
|
736
771
|
});
|
|
737
772
|
|
|
738
773
|
it('should focus in searchInput with keymap', async () => {
|
|
@@ -765,8 +800,8 @@ describe('TekGrid', () => {
|
|
|
765
800
|
await flushPromises();
|
|
766
801
|
|
|
767
802
|
(KeyMap as any).isElementActive = () => false;
|
|
768
|
-
spySetFocus.
|
|
769
|
-
spyMetadata.
|
|
803
|
+
spySetFocus.mockReset();
|
|
804
|
+
spyMetadata.mockReset();
|
|
770
805
|
});
|
|
771
806
|
});
|
|
772
807
|
|
|
@@ -790,12 +825,12 @@ describe('TekGrid', () => {
|
|
|
790
825
|
expect(spy).toBeCalled();
|
|
791
826
|
}
|
|
792
827
|
}
|
|
793
|
-
spy.
|
|
828
|
+
spy.mockReset();
|
|
794
829
|
});
|
|
795
830
|
});
|
|
796
831
|
|
|
797
832
|
describe('grouping', () => {
|
|
798
|
-
it('should group data', async (
|
|
833
|
+
it('should group data based on columns that have grouped property', async () => {
|
|
799
834
|
const flushPromises = () => new Promise(setImmediate);
|
|
800
835
|
const instance = new TekGrid({
|
|
801
836
|
name: 'grid_grouping_1',
|
|
@@ -830,23 +865,19 @@ describe('TekGrid', () => {
|
|
|
830
865
|
|
|
831
866
|
await flushPromises();
|
|
832
867
|
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
expect(instance.groupedData[1].name).toBe('employee 1');
|
|
843
|
-
|
|
844
|
-
done();
|
|
845
|
-
}, 1000);
|
|
868
|
+
instance.getCellWithAppliedConditions(instance.columns, instance.datasource.data[0]);
|
|
869
|
+
expect(instance.datasource.data.length).toBe(5);
|
|
870
|
+
expect(instance.datasource.order).toEqual(['department.asc', 'name.asc']);
|
|
871
|
+
expect(instance.groupedData.length).toBe(7);
|
|
872
|
+
expect(instance.groupedData[0].group).toBeTruthy();
|
|
873
|
+
expect(instance.groupedData[0].groupLabel).toBe('department');
|
|
874
|
+
expect(instance.groupedData[0].groupValue).toBe(1);
|
|
875
|
+
expect(instance.groupedData[1].groupHeaders.length).toBe(1);
|
|
876
|
+
expect(instance.groupedData[1].name).toBe('employee 1');
|
|
846
877
|
});
|
|
847
878
|
|
|
848
|
-
it('should call debounced updateGroupData',
|
|
849
|
-
const
|
|
879
|
+
it('should call debounced updateGroupData', () => {
|
|
880
|
+
const spy = jest.spyOn(TekGrid.prototype, 'updateGroupedData');
|
|
850
881
|
const instance = new TekGrid({
|
|
851
882
|
name: 'grid_grouping_1',
|
|
852
883
|
component: 'TekGrid',
|
|
@@ -877,18 +908,16 @@ describe('TekGrid', () => {
|
|
|
877
908
|
},
|
|
878
909
|
});
|
|
879
910
|
|
|
880
|
-
|
|
911
|
+
jest.runAllTimers();
|
|
881
912
|
|
|
882
|
-
instance.updateGroupedData = jest.fn();
|
|
883
913
|
instance.columns[2].grouped = true;
|
|
884
914
|
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
}, 1000);
|
|
915
|
+
expect(spy).toHaveBeenCalled();
|
|
916
|
+
|
|
917
|
+
spy.mockClear();
|
|
889
918
|
});
|
|
890
919
|
|
|
891
|
-
it('should group data with aggregations', async (
|
|
920
|
+
it('should group data with aggregations', async () => {
|
|
892
921
|
const flushPromises = () => new Promise(setImmediate);
|
|
893
922
|
const instance = new TekGrid({
|
|
894
923
|
name: 'grid_aggregate_1',
|
|
@@ -924,26 +953,22 @@ describe('TekGrid', () => {
|
|
|
924
953
|
|
|
925
954
|
await flushPromises();
|
|
926
955
|
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
}, 1000);
|
|
944
|
-
});
|
|
945
|
-
|
|
946
|
-
it('should group data with multiple groups', async (done) => {
|
|
956
|
+
instance.getCellWithAppliedConditions(instance.columns, instance.datasource.data[0]);
|
|
957
|
+
expect(instance.datasource.data.length).toBe(5);
|
|
958
|
+
expect(instance.datasource.order).toEqual(['department.asc', 'name.asc']);
|
|
959
|
+
expect(instance.groupedData.length).toBe(10);
|
|
960
|
+
expect(instance.groupedData[0].group).toBeTruthy();
|
|
961
|
+
expect(instance.groupedData[0].groupLabel).toBe('department');
|
|
962
|
+
expect(instance.groupedData[0].groupValue).toBe(1);
|
|
963
|
+
expect(instance.groupedData[1].groupHeaders.length).toBe(1);
|
|
964
|
+
expect(instance.groupedData[1].name).toBe('employee 1');
|
|
965
|
+
expect(instance.groupedData[4].groupFooter).toBeTruthy();
|
|
966
|
+
expect(instance.groupedData[4].id).toBe(3);
|
|
967
|
+
expect(instance.groupedData[9].groupSummary).toBeTruthy();
|
|
968
|
+
expect(instance.groupedData[9].id).toBe(5);
|
|
969
|
+
});
|
|
970
|
+
|
|
971
|
+
it('should group data with multiple groups', async () => {
|
|
947
972
|
const flushPromises = () => new Promise(setImmediate);
|
|
948
973
|
let viewUpdateScrollDataCalled = false;
|
|
949
974
|
|
|
@@ -993,38 +1018,34 @@ describe('TekGrid', () => {
|
|
|
993
1018
|
|
|
994
1019
|
await flushPromises();
|
|
995
1020
|
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
}, 1000);
|
|
1025
|
-
});
|
|
1026
|
-
|
|
1027
|
-
it('should group data with multiple groups and aggregation', async (done) => {
|
|
1021
|
+
expect(instance.datasource.data.length).toBe(5);
|
|
1022
|
+
expect(instance.datasource.data[0].groupHeaders).toBeUndefined();
|
|
1023
|
+
expect(instance.datasource.order).toEqual(['department.asc', 'boss.asc', 'name.asc']);
|
|
1024
|
+
expect(instance.groupedData.length).toBe(11);
|
|
1025
|
+
expect(instance.groupedData[0].group).toBeTruthy();
|
|
1026
|
+
expect(instance.groupedData[0].groupLabel).toBe('department');
|
|
1027
|
+
expect(instance.groupedData[0].groupValue).toBe(1);
|
|
1028
|
+
expect(instance.groupedData[1].group).toBeTruthy();
|
|
1029
|
+
expect(instance.groupedData[1].groupLabel).toBe('boss');
|
|
1030
|
+
expect(instance.groupedData[1].groupValue).toBe('boss');
|
|
1031
|
+
expect(instance.groupedData[2].groupHeaders.length).toBe(2);
|
|
1032
|
+
expect(instance.groupedData[2].name).toBe('employee 1');
|
|
1033
|
+
expect(instance.groupedData[3].group).toBeTruthy();
|
|
1034
|
+
expect(instance.groupedData[3].groupLabel).toBe('boss');
|
|
1035
|
+
expect(instance.groupedData[3].groupValue).toBe(1);
|
|
1036
|
+
|
|
1037
|
+
expect(instance.isItemVisible(instance.groupedData[2])).toBeFalsy();
|
|
1038
|
+
instance.openGroup(instance.groupedData[0]);
|
|
1039
|
+
expect(instance.isItemVisible(instance.groupedData[2])).toBeFalsy();
|
|
1040
|
+
expect(viewUpdateScrollDataCalled).toBeFalsy();
|
|
1041
|
+
|
|
1042
|
+
instance.viewUpdateScrollData = () => { viewUpdateScrollDataCalled = true; };
|
|
1043
|
+
instance.openGroup(instance.groupedData[1]);
|
|
1044
|
+
expect(instance.isItemVisible(instance.groupedData[2])).toBeTruthy();
|
|
1045
|
+
expect(viewUpdateScrollDataCalled).toBeTruthy();
|
|
1046
|
+
});
|
|
1047
|
+
|
|
1048
|
+
it('should group data with multiple groups and aggregation', async () => {
|
|
1028
1049
|
const flushPromises = () => new Promise(setImmediate);
|
|
1029
1050
|
const instance = new TekGrid({
|
|
1030
1051
|
name: 'grid_aggredate_2',
|
|
@@ -1082,37 +1103,33 @@ describe('TekGrid', () => {
|
|
|
1082
1103
|
|
|
1083
1104
|
await flushPromises();
|
|
1084
1105
|
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
}, 1000);
|
|
1113
|
-
});
|
|
1114
|
-
|
|
1115
|
-
it('should aggregate even without groups', async (done) => {
|
|
1106
|
+
expect(instance.datasource.data.length).toBe(5);
|
|
1107
|
+
expect(instance.datasource.data[0].groupHeaders).toBeUndefined();
|
|
1108
|
+
expect(instance.datasource.order).toEqual(['department.asc', 'boss.asc', 'name.asc']);
|
|
1109
|
+
expect(instance.groupedData.length).toBe(17);
|
|
1110
|
+
expect(instance.groupedData[0].group).toBeTruthy();
|
|
1111
|
+
expect(instance.groupedData[0].groupLabel).toBe('department');
|
|
1112
|
+
expect(instance.groupedData[0].groupValue).toBe(1);
|
|
1113
|
+
expect(instance.groupedData[1].group).toBeTruthy();
|
|
1114
|
+
expect(instance.groupedData[1].groupLabel).toBe('boss');
|
|
1115
|
+
expect(instance.groupedData[1].groupValue).toBe('boss');
|
|
1116
|
+
expect(instance.groupedData[2].groupHeaders.length).toBe(2);
|
|
1117
|
+
expect(instance.groupedData[2].name).toBe('employee 1');
|
|
1118
|
+
expect(instance.groupedData[3].groupFooter).toBeTruthy();
|
|
1119
|
+
expect(instance.groupedData[3].id).toBe(1);
|
|
1120
|
+
expect(instance.groupedData[3].salary).toBe(10);
|
|
1121
|
+
expect(instance.groupedData[4].group).toBeTruthy();
|
|
1122
|
+
expect(instance.groupedData[4].groupLabel).toBe('boss');
|
|
1123
|
+
expect(instance.groupedData[4].groupValue).toBe(1);
|
|
1124
|
+
expect(instance.groupedData[7].groupFooter).toBeTruthy();
|
|
1125
|
+
expect(instance.groupedData[7].id).toBe(2);
|
|
1126
|
+
expect(instance.groupedData[7].salary).toBe(20);
|
|
1127
|
+
expect(instance.groupedData[8].groupFooter).toBeTruthy();
|
|
1128
|
+
expect(instance.groupedData[8].id).toBe(3);
|
|
1129
|
+
expect(instance.groupedData[8].salary).toBe(30);
|
|
1130
|
+
});
|
|
1131
|
+
|
|
1132
|
+
it('should aggregate even without groups', async () => {
|
|
1116
1133
|
const flushPromises = () => new Promise(setImmediate);
|
|
1117
1134
|
const instance = new TekGrid({
|
|
1118
1135
|
name: 'grid_aggredate_3',
|
|
@@ -1168,17 +1185,13 @@ describe('TekGrid', () => {
|
|
|
1168
1185
|
|
|
1169
1186
|
await flushPromises();
|
|
1170
1187
|
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
expect(instance.groupedData[5].salary).toBe(50);
|
|
1176
|
-
|
|
1177
|
-
done();
|
|
1178
|
-
}, 1000);
|
|
1188
|
+
expect(instance.datasource.data.length).toBe(5);
|
|
1189
|
+
expect(instance.groupedData.length).toBe(6);
|
|
1190
|
+
expect(instance.groupedData[5].groupSummary).toBeTruthy();
|
|
1191
|
+
expect(instance.groupedData[5].salary).toBe(50);
|
|
1179
1192
|
});
|
|
1180
1193
|
|
|
1181
|
-
it('should aggregation with different functions', async (
|
|
1194
|
+
it('should aggregation with different functions', async () => {
|
|
1182
1195
|
const flushPromises = () => new Promise(setImmediate);
|
|
1183
1196
|
const instance = new TekGrid({
|
|
1184
1197
|
name: 'grid_aggregate_4',
|
|
@@ -1241,21 +1254,17 @@ describe('TekGrid', () => {
|
|
|
1241
1254
|
|
|
1242
1255
|
await flushPromises();
|
|
1243
1256
|
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
expect(instance.groupedData[6].column_count).toBe(3);
|
|
1253
|
-
|
|
1254
|
-
done();
|
|
1255
|
-
}, 1000);
|
|
1257
|
+
expect(instance.datasource.data.length).toBe(4);
|
|
1258
|
+
expect(instance.groupedData.length).toBe(7);
|
|
1259
|
+
expect(instance.groupedData[6].groupSummary).toBeTruthy();
|
|
1260
|
+
expect(instance.groupedData[6].column_sum).toBe(130);
|
|
1261
|
+
expect(instance.groupedData[6].column_min).toBe(5);
|
|
1262
|
+
expect(instance.groupedData[6].column_max).toBe('5');
|
|
1263
|
+
expect(instance.groupedData[6].column_avg).toBe(33.75);
|
|
1264
|
+
expect(instance.groupedData[6].column_count).toBe(3);
|
|
1256
1265
|
});
|
|
1257
1266
|
|
|
1258
|
-
it('should group data on rest datasource with lazyLoad', async (
|
|
1267
|
+
it('should group data on rest datasource with lazyLoad', async () => {
|
|
1259
1268
|
const flushPromises = () => new Promise(setImmediate);
|
|
1260
1269
|
const httpSpy = jest.spyOn(Http, 'get').mockImplementation(() => Promise.resolve({
|
|
1261
1270
|
data: {
|
|
@@ -1306,14 +1315,11 @@ describe('TekGrid', () => {
|
|
|
1306
1315
|
expect(instance.datasource.data.length).toBe(0);
|
|
1307
1316
|
|
|
1308
1317
|
await instance.datasource.get();
|
|
1309
|
-
setTimeout(() => {
|
|
1310
|
-
expect(instance.datasource.data.length).toBe(5);
|
|
1311
|
-
expect(instance.groupedData.length).toBe(7);
|
|
1312
1318
|
|
|
1313
|
-
|
|
1319
|
+
expect(instance.datasource.data.length).toBe(5);
|
|
1320
|
+
expect(instance.groupedData.length).toBe(7);
|
|
1314
1321
|
|
|
1315
|
-
|
|
1316
|
-
}, 1000);
|
|
1322
|
+
httpSpy.mockReset();
|
|
1317
1323
|
});
|
|
1318
1324
|
|
|
1319
1325
|
it('editedRows should return cleaned rows', async () => {
|
|
@@ -1392,7 +1398,7 @@ describe('TekGrid', () => {
|
|
|
1392
1398
|
expect(instance.groupedData.length).toBe(0);
|
|
1393
1399
|
});
|
|
1394
1400
|
|
|
1395
|
-
it('should call view update methods', async (
|
|
1401
|
+
it('should call view update methods', async () => {
|
|
1396
1402
|
const flushPromises = () => new Promise(setImmediate);
|
|
1397
1403
|
let viewUpdateScrollDataCalled = false;
|
|
1398
1404
|
let viewUpdateFixedColumnsCalled = false;
|
|
@@ -1433,16 +1439,12 @@ describe('TekGrid', () => {
|
|
|
1433
1439
|
|
|
1434
1440
|
await flushPromises();
|
|
1435
1441
|
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
expect(viewUpdateFixedColumnsCalled).toBeTruthy();
|
|
1439
|
-
|
|
1440
|
-
done();
|
|
1441
|
-
}, 1000);
|
|
1442
|
+
expect(viewUpdateScrollDataCalled).toBeTruthy();
|
|
1443
|
+
expect(viewUpdateFixedColumnsCalled).toBeTruthy();
|
|
1442
1444
|
});
|
|
1443
1445
|
|
|
1444
|
-
it('should call debounced updateGroupData',
|
|
1445
|
-
const
|
|
1446
|
+
it('should call debounced updateGroupData', () => {
|
|
1447
|
+
const spy = jest.spyOn(TekGrid.prototype, 'updateGroupedData');
|
|
1446
1448
|
const instance = new TekGrid({
|
|
1447
1449
|
name: 'grid_grouping_1',
|
|
1448
1450
|
component: 'TekGrid',
|
|
@@ -1474,15 +1476,13 @@ describe('TekGrid', () => {
|
|
|
1474
1476
|
},
|
|
1475
1477
|
});
|
|
1476
1478
|
|
|
1477
|
-
|
|
1479
|
+
jest.runAllTimers();
|
|
1478
1480
|
|
|
1479
|
-
instance.updateGroupedData = jest.fn();
|
|
1480
1481
|
instance.columns[2].groupOpened = true;
|
|
1481
1482
|
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
}, 1000);
|
|
1483
|
+
expect(spy).toHaveBeenCalled();
|
|
1484
|
+
|
|
1485
|
+
spy.mockClear();
|
|
1486
1486
|
});
|
|
1487
1487
|
});
|
|
1488
1488
|
|
|
@@ -1495,18 +1495,14 @@ describe('TekGrid', () => {
|
|
|
1495
1495
|
|
|
1496
1496
|
const spy = jest.spyOn(ModalService, 'create');
|
|
1497
1497
|
instance.onCreated();
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
expect(button.isVisible).toBeFalsy();
|
|
1507
|
-
(instance as any).gridBase.hideFilterModal();
|
|
1508
|
-
}
|
|
1509
|
-
spy.mockClear();
|
|
1498
|
+
|
|
1499
|
+
const button = clickOnFilterButton(instance);
|
|
1500
|
+
expect(spy).toBeCalledTimes(1);
|
|
1501
|
+
clickOnFilterButton(instance);
|
|
1502
|
+
expect(spy).toBeCalledTimes(1);
|
|
1503
|
+
expect(button.isVisible).toBeFalsy();
|
|
1504
|
+
(instance as any).gridBase.hideFilterModal();
|
|
1505
|
+
spy.mockReset();
|
|
1510
1506
|
});
|
|
1511
1507
|
|
|
1512
1508
|
it('should call events', () => {
|
|
@@ -1519,14 +1515,14 @@ describe('TekGrid', () => {
|
|
|
1519
1515
|
},
|
|
1520
1516
|
});
|
|
1521
1517
|
|
|
1518
|
+
const spy = jest.spyOn(ModalService, 'create').mockImplementation((modal) => new Modal(modal));
|
|
1519
|
+
|
|
1522
1520
|
instance.onCreated();
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
expect(filterClickCalled).toBeTruthy();
|
|
1529
|
-
}
|
|
1521
|
+
clickOnFilterButton(instance);
|
|
1522
|
+
|
|
1523
|
+
expect(filterClickCalled).toBeTruthy();
|
|
1524
|
+
|
|
1525
|
+
spy.mockReset();
|
|
1530
1526
|
});
|
|
1531
1527
|
|
|
1532
1528
|
it('should not call saveEditedRows if filterClick call preventDefault', () => {
|
|
@@ -1540,16 +1536,14 @@ describe('TekGrid', () => {
|
|
|
1540
1536
|
});
|
|
1541
1537
|
|
|
1542
1538
|
const spy = jest.spyOn(ModalService, 'create');
|
|
1543
|
-
|
|
1539
|
+
|
|
1544
1540
|
instance.onCreated();
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
}
|
|
1552
|
-
spy.mockClear();
|
|
1541
|
+
clickOnFilterButton(instance, { defaultPrevented: true });
|
|
1542
|
+
|
|
1543
|
+
expect(filterClickCalled).toBeTruthy();
|
|
1544
|
+
expect(spy).not.toBeCalled();
|
|
1545
|
+
|
|
1546
|
+
spy.mockReset();
|
|
1553
1547
|
});
|
|
1554
1548
|
|
|
1555
1549
|
it('should create modal with no form elements', () => {
|
|
@@ -1564,22 +1558,16 @@ describe('TekGrid', () => {
|
|
|
1564
1558
|
|
|
1565
1559
|
let formElements: any = [];
|
|
1566
1560
|
const spy = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => {
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
formElements = form.children;
|
|
1570
|
-
}
|
|
1561
|
+
const form = getChild<IForm>(modal.children || [], `${instance.name}-filter-form`);
|
|
1562
|
+
formElements = form.children;
|
|
1571
1563
|
|
|
1572
1564
|
return new Modal(modal);
|
|
1573
1565
|
});
|
|
1574
1566
|
instance.onCreated();
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
button.click(event, {} as HTMLElement);
|
|
1580
|
-
expect(formElements).toEqual([]);
|
|
1581
|
-
}
|
|
1582
|
-
spy.mockClear();
|
|
1567
|
+
clickOnFilterButton(instance);
|
|
1568
|
+
|
|
1569
|
+
expect(formElements).toEqual([]);
|
|
1570
|
+
spy.mockReset();
|
|
1583
1571
|
});
|
|
1584
1572
|
|
|
1585
1573
|
it('should create modal with filterable form elements', () => {
|
|
@@ -1594,22 +1582,17 @@ describe('TekGrid', () => {
|
|
|
1594
1582
|
|
|
1595
1583
|
let formElements: any = [];
|
|
1596
1584
|
const spy = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => {
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
formElements = form.children;
|
|
1600
|
-
}
|
|
1585
|
+
const form = getChild<IForm>(modal.children || [], `${instance.name}-filter-form`);
|
|
1586
|
+
formElements = form.children;
|
|
1601
1587
|
|
|
1602
1588
|
return new Modal(modal);
|
|
1603
1589
|
});
|
|
1604
1590
|
instance.onCreated();
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
expect(formElements[0].name).toBe('grid_filterClick5-filter-AND-CONTAINS-name-0');
|
|
1611
|
-
}
|
|
1612
|
-
spy.mockClear();
|
|
1591
|
+
clickOnFilterButton(instance);
|
|
1592
|
+
|
|
1593
|
+
expect(formElements[0].name).toBe('grid_filterClick5-filter-AND-CONTAINS-name-0');
|
|
1594
|
+
|
|
1595
|
+
spy.mockReset();
|
|
1613
1596
|
});
|
|
1614
1597
|
|
|
1615
1598
|
it('should create modal with filterable and ordered form elements', () => {
|
|
@@ -1640,24 +1623,20 @@ describe('TekGrid', () => {
|
|
|
1640
1623
|
|
|
1641
1624
|
let formElements: any = [];
|
|
1642
1625
|
const spy = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => {
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
formElements = form.children;
|
|
1646
|
-
}
|
|
1626
|
+
const form = getChild<IForm>(modal.children || [], `${instance.name}-filter-form`);
|
|
1627
|
+
formElements = form.children;
|
|
1647
1628
|
|
|
1648
1629
|
return new Modal(modal);
|
|
1649
1630
|
});
|
|
1650
1631
|
instance.onCreated();
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
}
|
|
1660
|
-
spy.mockClear();
|
|
1632
|
+
|
|
1633
|
+
clickOnFilterButton(instance);
|
|
1634
|
+
|
|
1635
|
+
expect(formElements[0].name).toBe('grid-filter-order-filter-AND-CONTAINS-dob-0');
|
|
1636
|
+
expect(formElements[1].name).toBe('grid-filter-order-filter-AND-CONTAINS-last_name-0');
|
|
1637
|
+
expect(formElements[2].name).toBe('grid-filter-order-filter-AND-CONTAINS-first_name-0');
|
|
1638
|
+
|
|
1639
|
+
spy.mockReset();
|
|
1661
1640
|
});
|
|
1662
1641
|
|
|
1663
1642
|
it('should create modal with filterable form elements and TekRestDatasource', () => {
|
|
@@ -1666,6 +1645,7 @@ describe('TekGrid', () => {
|
|
|
1666
1645
|
component: 'TekGrid',
|
|
1667
1646
|
datasource: {
|
|
1668
1647
|
type: 'tek-rest',
|
|
1648
|
+
lazyLoad: true,
|
|
1669
1649
|
},
|
|
1670
1650
|
columns: [
|
|
1671
1651
|
{
|
|
@@ -1685,24 +1665,20 @@ describe('TekGrid', () => {
|
|
|
1685
1665
|
let formElements: any = [];
|
|
1686
1666
|
let form: IForm;
|
|
1687
1667
|
const spy = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => {
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
formElements = form.children;
|
|
1691
|
-
}
|
|
1668
|
+
form = getChild<IForm>(modal.children || [], `${instance.name}-filter-form`);
|
|
1669
|
+
formElements = form.children;
|
|
1692
1670
|
|
|
1693
1671
|
return new Modal(modal);
|
|
1694
1672
|
});
|
|
1695
1673
|
instance.onCreated();
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
}
|
|
1705
|
-
spy.mockClear();
|
|
1674
|
+
|
|
1675
|
+
clickOnFilterButton(instance);
|
|
1676
|
+
|
|
1677
|
+
expect(formElements[0].name).toBe('grid_filterClick6-filter-AND-CONTAINS-id-0');
|
|
1678
|
+
expect(formElements[1].name).toBe('grid_filterClick6-filter-OR-NOT_EQUALS-name-0');
|
|
1679
|
+
expect(formElements[1].component).toBe('ZdSelect');
|
|
1680
|
+
|
|
1681
|
+
spy.mockReset();
|
|
1706
1682
|
});
|
|
1707
1683
|
|
|
1708
1684
|
it('should create modal with helper component', () => {
|
|
@@ -1711,6 +1687,7 @@ describe('TekGrid', () => {
|
|
|
1711
1687
|
component: 'TekGrid',
|
|
1712
1688
|
datasource: {
|
|
1713
1689
|
type: 'tek-rest',
|
|
1690
|
+
lazyLoad: true,
|
|
1714
1691
|
},
|
|
1715
1692
|
columns: [
|
|
1716
1693
|
{
|
|
@@ -1750,27 +1727,22 @@ describe('TekGrid', () => {
|
|
|
1750
1727
|
let formElements: any = [];
|
|
1751
1728
|
let form: IForm;
|
|
1752
1729
|
const spy = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => {
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
formElements = form.children;
|
|
1756
|
-
}
|
|
1730
|
+
form = getChild<IForm>(modal.children || [], `${instance.name}-filter-form`);
|
|
1731
|
+
formElements = form.children;
|
|
1757
1732
|
|
|
1758
1733
|
return new Modal(modal);
|
|
1759
1734
|
});
|
|
1760
1735
|
const dateHelperSpy = jest.spyOn(DateHelper, 'getLabel').mockImplementation((name: string) => name);
|
|
1761
1736
|
|
|
1762
1737
|
instance.onCreated();
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
}
|
|
1772
|
-
spy.mockClear();
|
|
1773
|
-
dateHelperSpy.mockClear();
|
|
1738
|
+
clickOnFilterButton(instance);
|
|
1739
|
+
|
|
1740
|
+
expect(formElements[0].name).toBe('grid_filterClick7-filter-AND-CONTAINS-id-0');
|
|
1741
|
+
expect(formElements[1].name).toBe('grid_filterClick7-filter-OR-NOT_EQUALS-date-0');
|
|
1742
|
+
expect(formElements[2].name).toBe('grid_filterClick7-filter-OR-NOT_EQUALS-date-1');
|
|
1743
|
+
|
|
1744
|
+
spy.mockReset();
|
|
1745
|
+
dateHelperSpy.mockReset();
|
|
1774
1746
|
});
|
|
1775
1747
|
|
|
1776
1748
|
it('should apply helper value', () => {
|
|
@@ -1779,6 +1751,7 @@ describe('TekGrid', () => {
|
|
|
1779
1751
|
component: 'TekGrid',
|
|
1780
1752
|
datasource: {
|
|
1781
1753
|
type: 'tek-rest',
|
|
1754
|
+
lazyLoad: true,
|
|
1782
1755
|
},
|
|
1783
1756
|
columns: [
|
|
1784
1757
|
{
|
|
@@ -1825,35 +1798,30 @@ describe('TekGrid', () => {
|
|
|
1825
1798
|
let formElements: any = [];
|
|
1826
1799
|
let form: IForm;
|
|
1827
1800
|
const spy = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => {
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
formElements = form.children;
|
|
1831
|
-
}
|
|
1801
|
+
form = getChild<IForm>(modal.children || [], `${instance.name}-filter-form`);
|
|
1802
|
+
formElements = form.children;
|
|
1832
1803
|
|
|
1833
1804
|
return new Modal(modal);
|
|
1834
1805
|
});
|
|
1835
1806
|
instance.onCreated();
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
expect((instance.columns[1].filterProps as IFilterPropsComponent[])[1].helperValue).toBe('TODAY');
|
|
1855
|
-
}
|
|
1856
|
-
spy.mockClear();
|
|
1807
|
+
clickOnFilterButton(instance);
|
|
1808
|
+
|
|
1809
|
+
const dateComp = new Date(formElements[0]);
|
|
1810
|
+
dateComp.helperValue = 'TODAY';
|
|
1811
|
+
dateComp.change({} as Event, {} as HTMLElement);
|
|
1812
|
+
expect((instance.columns[0].filterProps as IFilterPropsComponent).helperValue).toBe('TODAY');
|
|
1813
|
+
|
|
1814
|
+
const dateComp21 = new Date(formElements[1]);
|
|
1815
|
+
dateComp21.helperValue = 'TODAY';
|
|
1816
|
+
dateComp21.change({} as Event, {} as HTMLElement);
|
|
1817
|
+
expect((instance.columns[1].filterProps as IFilterPropsComponent[])[0].helperValue).toBe('TODAY');
|
|
1818
|
+
|
|
1819
|
+
const dateComp22 = new Date(formElements[2]);
|
|
1820
|
+
dateComp22.helperValue = 'TODAY';
|
|
1821
|
+
dateComp22.change({} as Event, {} as HTMLElement);
|
|
1822
|
+
expect((instance.columns[1].filterProps as IFilterPropsComponent[])[1].helperValue).toBe('TODAY');
|
|
1823
|
+
|
|
1824
|
+
spy.mockReset();
|
|
1857
1825
|
});
|
|
1858
1826
|
|
|
1859
1827
|
it('should load form values from tekdatasource', () => {
|
|
@@ -1862,6 +1830,7 @@ describe('TekGrid', () => {
|
|
|
1862
1830
|
component: 'TekGrid',
|
|
1863
1831
|
datasource: {
|
|
1864
1832
|
type: 'tek-rest',
|
|
1833
|
+
lazyLoad: true,
|
|
1865
1834
|
dynamicFilter: {
|
|
1866
1835
|
id: [],
|
|
1867
1836
|
name: [
|
|
@@ -1909,35 +1878,30 @@ describe('TekGrid', () => {
|
|
|
1909
1878
|
});
|
|
1910
1879
|
|
|
1911
1880
|
let form: IForm = { name: 'form', component: 'ZdForm' };
|
|
1881
|
+
const dateHelperSpy = jest.spyOn(DateHelper, 'getLabel').mockImplementation((name: string) => name);
|
|
1912
1882
|
const spy = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => {
|
|
1913
|
-
|
|
1914
|
-
form = modal.children[1] as IForm;
|
|
1915
|
-
}
|
|
1883
|
+
form = getChild<IForm>(modal.children || [], `${instance.name}-filter-form`);
|
|
1916
1884
|
|
|
1917
1885
|
return new Modal(modal);
|
|
1918
1886
|
});
|
|
1919
1887
|
instance.onCreated();
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
spyMetadata.mockClear();
|
|
1938
|
-
}
|
|
1939
|
-
}
|
|
1940
|
-
spy.mockClear();
|
|
1888
|
+
|
|
1889
|
+
clickOnFilterButton(instance);
|
|
1890
|
+
|
|
1891
|
+
expect(form.name).toBe('grid_filterClick9-filter-form');
|
|
1892
|
+
const formObject = new Form(form);
|
|
1893
|
+
const dateObject = new Date({ name: 'date', component: 'ZdDate' });
|
|
1894
|
+
const spyMetadata = jest.spyOn(Metadata, 'getInstances').mockImplementation(() => [dateObject]);
|
|
1895
|
+
formObject.onMounted({} as HTMLElement);
|
|
1896
|
+
expect(formObject.value).toEqual({
|
|
1897
|
+
'grid_filterClick9-filter-OR-NOT_EQUALS-name-0': 'teste',
|
|
1898
|
+
'grid_filterClick9-filter-AND-CONTAINS-phone-0': '9',
|
|
1899
|
+
'grid_filterClick9-filter-OR-IN-date-0': ['2021-11-12', '2021-12-12'],
|
|
1900
|
+
});
|
|
1901
|
+
expect(dateObject.hint).toBe('TODAY');
|
|
1902
|
+
spyMetadata.mockReset();
|
|
1903
|
+
dateHelperSpy.mockReset();
|
|
1904
|
+
spy.mockReset();
|
|
1941
1905
|
});
|
|
1942
1906
|
|
|
1943
1907
|
it('should load form values from datasource', () => {
|
|
@@ -1964,31 +1928,42 @@ describe('TekGrid', () => {
|
|
|
1964
1928
|
],
|
|
1965
1929
|
});
|
|
1966
1930
|
|
|
1967
|
-
let
|
|
1931
|
+
let formProps: IForm = {} as IForm;
|
|
1968
1932
|
const spy = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => {
|
|
1969
|
-
|
|
1970
|
-
form = modal.children[1] as IForm;
|
|
1971
|
-
}
|
|
1933
|
+
formProps = getChild<IForm>(modal.children || [], `${instance.name}-filter-form`);
|
|
1972
1934
|
|
|
1973
1935
|
return new Modal(modal);
|
|
1974
1936
|
});
|
|
1975
1937
|
instance.onCreated();
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
});
|
|
1987
|
-
}
|
|
1988
|
-
spy.mockClear();
|
|
1938
|
+
clickOnFilterButton(instance);
|
|
1939
|
+
|
|
1940
|
+
const formObject = new Form(formProps);
|
|
1941
|
+
formObject.onMounted({} as HTMLElement);
|
|
1942
|
+
|
|
1943
|
+
expect(formObject.value).toEqual({
|
|
1944
|
+
'grid_filterClick10-filter-AND-CONTAINS-name-0': 'teste',
|
|
1945
|
+
'grid_filterClick10-filter-AND-CONTAINS-phone-0': '9',
|
|
1946
|
+
});
|
|
1947
|
+
spy.mockReset();
|
|
1989
1948
|
});
|
|
1990
1949
|
|
|
1991
1950
|
it('should apply filter from form to tekdatasource', () => {
|
|
1951
|
+
const httpSpy = jest.spyOn(Http, 'get').mockImplementation(() => Promise.resolve({
|
|
1952
|
+
data: {
|
|
1953
|
+
data: [
|
|
1954
|
+
{ id: 1, name: 'employee 1', department: 1 },
|
|
1955
|
+
{ id: 2, name: 'employee 2', department: 1 },
|
|
1956
|
+
{ id: 3, name: 'employee 3', department: 1 },
|
|
1957
|
+
{ id: 4, name: 'employee 4', department: 2 },
|
|
1958
|
+
{ id: 5, name: 'employee 5', department: 2 },
|
|
1959
|
+
],
|
|
1960
|
+
pagination: {
|
|
1961
|
+
page: 1,
|
|
1962
|
+
total: 5,
|
|
1963
|
+
limit: 15,
|
|
1964
|
+
},
|
|
1965
|
+
},
|
|
1966
|
+
}));
|
|
1992
1967
|
const instance = new TekGrid({
|
|
1993
1968
|
name: 'grid_filterClick11',
|
|
1994
1969
|
component: 'TekGrid',
|
|
@@ -2024,78 +1999,90 @@ describe('TekGrid', () => {
|
|
|
2024
1999
|
let form: IForm = { name: 'form', component: 'ZdForm' };
|
|
2025
2000
|
let applyButton: IButton = { name: 'apply', component: 'ZdButton' };
|
|
2026
2001
|
const spyModalService = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => {
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
applyButton = modalFooter.rightSlot[1] as IButton;
|
|
2032
|
-
}
|
|
2033
|
-
}
|
|
2002
|
+
form = getChild(modal.children || [], `${instance.name}-filter-form`);
|
|
2003
|
+
|
|
2004
|
+
const modalFooter = getChild(modal.children || [], `${instance.name}-filter-footer`);
|
|
2005
|
+
applyButton = getChild(modalFooter.rightSlot, `${instance.name}-filter-okButton`);
|
|
2034
2006
|
|
|
2035
2007
|
return new Modal(modal);
|
|
2036
2008
|
});
|
|
2037
2009
|
|
|
2038
2010
|
instance.onCreated();
|
|
2039
2011
|
|
|
2040
|
-
const
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
spyModalService.mockClear();
|
|
2012
|
+
const buttonProps = getChild<IButton>(instance.toolbarSlot, `${instance.name}_filterButton`);
|
|
2013
|
+
const button = new Button(buttonProps);
|
|
2014
|
+
setClick(button);
|
|
2015
|
+
|
|
2016
|
+
const formObject = new Form(form);
|
|
2017
|
+
const spyMetadata = jest.spyOn(Metadata, 'getInstance').mockImplementation(() => formObject);
|
|
2018
|
+
const spyDatasourceGet = jest.spyOn(instance.datasource, 'get');
|
|
2019
|
+
formObject.value = {
|
|
2020
|
+
'grid_filterClick11-filter-AND-IN-id-0': ['1', '2', '3'],
|
|
2021
|
+
'grid_filterClick11-filter-OR-NOT_EQUALS-name-0': 'teste',
|
|
2022
|
+
'grid_filterClick11-filter-AND-CONTAINS-phone-0': '',
|
|
2023
|
+
'grid_filterClick11-filter-AND-GREATER_THAN_EQUALS-salary-0': '1000',
|
|
2024
|
+
'grid_filterClick11-filter-AND-LESS_THAN_EQUALS-salary-0': '2000',
|
|
2025
|
+
};
|
|
2026
|
+
const applyButtonObject = new Button(applyButton);
|
|
2027
|
+
formObject.validate = () => false;
|
|
2028
|
+
setClick(applyButtonObject);
|
|
2029
|
+
expect((instance.datasource as TekRestDatasource).dynamicFilter).toEqual({});
|
|
2030
|
+
|
|
2031
|
+
formObject.validate = () => true;
|
|
2032
|
+
setClick(applyButtonObject);
|
|
2033
|
+
expect((instance.datasource as TekRestDatasource).dynamicFilter).toEqual({
|
|
2034
|
+
id: [
|
|
2035
|
+
{
|
|
2036
|
+
operation: 'IN',
|
|
2037
|
+
relation: 'AND',
|
|
2038
|
+
value: ['1', '2', '3'],
|
|
2039
|
+
},
|
|
2040
|
+
],
|
|
2041
|
+
name: [
|
|
2042
|
+
{
|
|
2043
|
+
operation: 'NOT_EQUALS',
|
|
2044
|
+
relation: 'OR',
|
|
2045
|
+
value: 'teste',
|
|
2046
|
+
},
|
|
2047
|
+
],
|
|
2048
|
+
salary: [
|
|
2049
|
+
{
|
|
2050
|
+
operation: 'GREATER_THAN_EQUALS',
|
|
2051
|
+
relation: 'AND',
|
|
2052
|
+
value: '1000',
|
|
2053
|
+
},
|
|
2054
|
+
{
|
|
2055
|
+
operation: 'LESS_THAN_EQUALS',
|
|
2056
|
+
relation: 'AND',
|
|
2057
|
+
value: '2000',
|
|
2058
|
+
},
|
|
2059
|
+
],
|
|
2060
|
+
});
|
|
2061
|
+
expect(instance.columnHasFilterData({ name: 'name' } as TekGridColumn)).toBeTruthy();
|
|
2062
|
+
expect(spyDatasourceGet).toBeCalled();
|
|
2063
|
+
spyMetadata.mockReset();
|
|
2064
|
+
spyDatasourceGet.mockReset();
|
|
2065
|
+
spyModalService.mockReset();
|
|
2066
|
+
httpSpy.mockReset();
|
|
2096
2067
|
});
|
|
2097
2068
|
|
|
2098
2069
|
it('should clear data from form', () => {
|
|
2070
|
+
const httpSpy = jest.spyOn(Http, 'get').mockImplementation(() => Promise.resolve({
|
|
2071
|
+
data: {
|
|
2072
|
+
data: [
|
|
2073
|
+
{ id: 1, name: 'employee 1', department: 1 },
|
|
2074
|
+
{ id: 2, name: 'employee 2', department: 1 },
|
|
2075
|
+
{ id: 3, name: 'employee 3', department: 1 },
|
|
2076
|
+
{ id: 4, name: 'employee 4', department: 2 },
|
|
2077
|
+
{ id: 5, name: 'employee 5', department: 2 },
|
|
2078
|
+
],
|
|
2079
|
+
pagination: {
|
|
2080
|
+
page: 1,
|
|
2081
|
+
total: 5,
|
|
2082
|
+
limit: 15,
|
|
2083
|
+
},
|
|
2084
|
+
},
|
|
2085
|
+
}));
|
|
2099
2086
|
const instance = new TekGrid({
|
|
2100
2087
|
name: 'grid_filterClick12',
|
|
2101
2088
|
component: 'TekGrid',
|
|
@@ -2131,47 +2118,43 @@ describe('TekGrid', () => {
|
|
|
2131
2118
|
let form: IForm = { name: 'form', component: 'ZdForm' };
|
|
2132
2119
|
let clearButton: IButton = { name: 'clear', component: 'ZdButton' };
|
|
2133
2120
|
const spyModalService = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => {
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
clearButton = modalFooter.leftSlot[0] as IButton;
|
|
2139
|
-
}
|
|
2140
|
-
}
|
|
2121
|
+
form = getChild(modal.children || [], `${instance.name}-filter-form`);
|
|
2122
|
+
|
|
2123
|
+
const modalFooter = getChild(modal.children || [], `${instance.name}-filter-footer`);
|
|
2124
|
+
clearButton = getChild(modalFooter.leftSlot, `${instance.name}-filter-clearButton`);
|
|
2141
2125
|
|
|
2142
2126
|
return new Modal(modal);
|
|
2143
2127
|
});
|
|
2144
2128
|
|
|
2145
2129
|
instance.onCreated();
|
|
2146
2130
|
|
|
2147
|
-
const
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
spyModalService.mockClear();
|
|
2131
|
+
const buttonProps = getChild<IButton>(instance.toolbarSlot, `${instance.name}_filterButton`);
|
|
2132
|
+
const button = new Button(buttonProps);
|
|
2133
|
+
setClick(button);
|
|
2134
|
+
|
|
2135
|
+
const formObject = new Form(form);
|
|
2136
|
+
const spyMetadata = jest.spyOn(Metadata, 'getInstance').mockImplementation(() => formObject);
|
|
2137
|
+
const spyDatasourceGet = jest.spyOn(instance.datasource, 'get');
|
|
2138
|
+
formObject.value = {
|
|
2139
|
+
'grid_filterClick12-filter-AND-IN-id-0': ['1', '2', '3'],
|
|
2140
|
+
'grid_filterClick12-filter-OR-NOT_EQUALS-name-0': 'teste',
|
|
2141
|
+
'grid_filterClick12-filter-AND-CONTAINS-phone-0': '',
|
|
2142
|
+
'grid_filterClick12-filter-AND-GREATER_THAN_EQUALS-salary-0': '1000',
|
|
2143
|
+
'grid_filterClick12-filter-AND-LESS_THAN_EQUALS-salary-0': '2000',
|
|
2144
|
+
};
|
|
2145
|
+
const clearButtonObject = new Button(clearButton);
|
|
2146
|
+
setClick(clearButtonObject);
|
|
2147
|
+
expect(formObject.value).toEqual({
|
|
2148
|
+
'grid_filterClick12-filter-AND-IN-id-0': null,
|
|
2149
|
+
'grid_filterClick12-filter-OR-NOT_EQUALS-name-0': null,
|
|
2150
|
+
'grid_filterClick12-filter-AND-CONTAINS-phone-0': null,
|
|
2151
|
+
'grid_filterClick12-filter-AND-GREATER_THAN_EQUALS-salary-0': null,
|
|
2152
|
+
'grid_filterClick12-filter-AND-LESS_THAN_EQUALS-salary-0': null,
|
|
2153
|
+
});
|
|
2154
|
+
spyMetadata.mockReset();
|
|
2155
|
+
spyDatasourceGet.mockReset();
|
|
2156
|
+
spyModalService.mockReset();
|
|
2157
|
+
httpSpy.mockReset();
|
|
2175
2158
|
});
|
|
2176
2159
|
|
|
2177
2160
|
it('should apply filter from form to datasource', () => {
|
|
@@ -2203,48 +2186,41 @@ describe('TekGrid', () => {
|
|
|
2203
2186
|
let form: IForm = { name: 'form', component: 'ZdForm' };
|
|
2204
2187
|
let applyButton: IButton = { name: 'apply', component: 'ZdButton' };
|
|
2205
2188
|
const spyModalService = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => {
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
applyButton = modalFooter.rightSlot[1] as IButton;
|
|
2211
|
-
}
|
|
2212
|
-
}
|
|
2189
|
+
form = getChild(modal.children || [], `${instance.name}-filter-form`);
|
|
2190
|
+
|
|
2191
|
+
const modalFooter = getChild(modal.children || [], `${instance.name}-filter-footer`);
|
|
2192
|
+
applyButton = getChild(modalFooter.rightSlot, `${instance.name}-filter-okButton`);
|
|
2213
2193
|
|
|
2214
2194
|
return new Modal(modal);
|
|
2215
2195
|
});
|
|
2216
2196
|
|
|
2217
2197
|
instance.onCreated();
|
|
2218
2198
|
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
spyMetadata.mockClear();
|
|
2245
|
-
spyDatasourceGet.mockClear();
|
|
2246
|
-
}
|
|
2247
|
-
spyModalService.mockClear();
|
|
2199
|
+
clickOnFilterButton(instance);
|
|
2200
|
+
|
|
2201
|
+
const formObject = new Form(form);
|
|
2202
|
+
const spyMetadata = jest.spyOn(Metadata, 'getInstance').mockImplementation(() => formObject);
|
|
2203
|
+
const spyDatasourceGet = jest.spyOn(instance.datasource, 'get');
|
|
2204
|
+
formObject.value = {
|
|
2205
|
+
'grid_filterClick13-filter-AND-CONTAINS-id-0': '1;2;3',
|
|
2206
|
+
'grid_filterClick13-filter-AND-CONTAINS-name-0': 'teste',
|
|
2207
|
+
'grid_filterClick13-filter-AND-CONTAINS-phone-0': '',
|
|
2208
|
+
'grid_filterClick13-filter-AND-CONTAINS-salary-0': '1000',
|
|
2209
|
+
};
|
|
2210
|
+
const applyButtonObject = new Button(applyButton);
|
|
2211
|
+
setClick(applyButtonObject, { defaultPrevented: true });
|
|
2212
|
+
expect((instance.datasource as TekRestDatasource).filter).toEqual({
|
|
2213
|
+
id: '1;2;3',
|
|
2214
|
+
name: 'teste',
|
|
2215
|
+
salary: '1000',
|
|
2216
|
+
});
|
|
2217
|
+
expect(beforeApplyFilterCalled).toBeTruthy();
|
|
2218
|
+
expect(changeLayoutCalled).toBeTruthy();
|
|
2219
|
+
expect(instance.columnHasFilterData({ name: 'name' } as TekGridColumn)).toBeTruthy();
|
|
2220
|
+
expect(spyDatasourceGet).not.toBeCalled();
|
|
2221
|
+
spyMetadata.mockReset();
|
|
2222
|
+
spyDatasourceGet.mockReset();
|
|
2223
|
+
spyModalService.mockReset();
|
|
2248
2224
|
});
|
|
2249
2225
|
});
|
|
2250
2226
|
|
|
@@ -2336,22 +2312,23 @@ describe('TekGrid', () => {
|
|
|
2336
2312
|
],
|
|
2337
2313
|
datasource: {
|
|
2338
2314
|
type: 'tek-rest',
|
|
2339
|
-
lazyLoad:
|
|
2315
|
+
lazyLoad: true,
|
|
2340
2316
|
route: '/grid',
|
|
2341
2317
|
},
|
|
2342
2318
|
};
|
|
2343
|
-
|
|
2344
|
-
httpSpy.mockClear();
|
|
2345
2319
|
});
|
|
2346
2320
|
|
|
2347
|
-
|
|
2348
|
-
httpSpy.
|
|
2321
|
+
afterEach(() => {
|
|
2322
|
+
httpSpy.mockReset();
|
|
2349
2323
|
});
|
|
2350
2324
|
|
|
2351
2325
|
it('should set datasource search_join based on columns that have datasource', async () => {
|
|
2326
|
+
const flushPromises = () => new Promise(setImmediate);
|
|
2352
2327
|
const instance = new TekGrid(baseProps);
|
|
2353
2328
|
|
|
2354
|
-
|
|
2329
|
+
instance.setSearch('1');
|
|
2330
|
+
await flushPromises();
|
|
2331
|
+
|
|
2355
2332
|
expect(instance.datasource).toBeInstanceOf(TekRestDatasource);
|
|
2356
2333
|
expect((instance.datasource as TekRestDatasource).searchJoin).toEqual({ employee_id: [1, 15] });
|
|
2357
2334
|
expect(httpSpy).toHaveBeenCalledTimes(2);
|
|
@@ -2403,7 +2380,7 @@ describe('TekGrid', () => {
|
|
|
2403
2380
|
],
|
|
2404
2381
|
datasource: {
|
|
2405
2382
|
type: 'tek-rest',
|
|
2406
|
-
lazyLoad:
|
|
2383
|
+
lazyLoad: true,
|
|
2407
2384
|
route: '/grid',
|
|
2408
2385
|
},
|
|
2409
2386
|
});
|
|
@@ -2422,6 +2399,17 @@ describe('TekGrid', () => {
|
|
|
2422
2399
|
expect(instance.datasource).not.toBeInstanceOf(TekRestDatasource);
|
|
2423
2400
|
expect(httpSpy).toHaveBeenCalledTimes(1);
|
|
2424
2401
|
});
|
|
2402
|
+
|
|
2403
|
+
it('when called, should change datasource page to 1 before searching', async () => {
|
|
2404
|
+
const instance = new TekGrid({
|
|
2405
|
+
name: 'iterable',
|
|
2406
|
+
component: 'Iterable',
|
|
2407
|
+
});
|
|
2408
|
+
instance.datasource.page = 5;
|
|
2409
|
+
await instance.setSearch('search value');
|
|
2410
|
+
|
|
2411
|
+
expect(instance.datasource.page).toBe(1);
|
|
2412
|
+
});
|
|
2425
2413
|
});
|
|
2426
2414
|
|
|
2427
2415
|
describe('rowClick', () => {
|
|
@@ -2629,7 +2617,7 @@ describe('TekGrid', () => {
|
|
|
2629
2617
|
const layoutOptionsComp = { name: 'grid_layout_options' };
|
|
2630
2618
|
const spyMetadata = jest.spyOn(Metadata, 'getInstance').mockImplementation(() => layoutOptionsComp);
|
|
2631
2619
|
expect(grid.layoutOptions).toEqual(layoutOptionsComp);
|
|
2632
|
-
spyMetadata.
|
|
2620
|
+
spyMetadata.mockReset();
|
|
2633
2621
|
});
|
|
2634
2622
|
});
|
|
2635
2623
|
|
|
@@ -2648,7 +2636,7 @@ describe('TekGrid', () => {
|
|
|
2648
2636
|
const gridAtom = instance.getAtomInstance<Text>('TITLE');
|
|
2649
2637
|
|
|
2650
2638
|
expect(gridAtom).toEqual(atom);
|
|
2651
|
-
spyMetadata.
|
|
2639
|
+
spyMetadata.mockReset();
|
|
2652
2640
|
});
|
|
2653
2641
|
});
|
|
2654
2642
|
|
|
@@ -2673,6 +2661,7 @@ describe('TekGrid', () => {
|
|
|
2673
2661
|
};
|
|
2674
2662
|
|
|
2675
2663
|
it('when called with null parameter, should return all the filter inputs', () => {
|
|
2664
|
+
const spyModalService = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => (new Modal(modal)));
|
|
2676
2665
|
const instance = new TekGrid({
|
|
2677
2666
|
name: 'grid',
|
|
2678
2667
|
component: 'TekGrid',
|
|
@@ -2708,21 +2697,18 @@ describe('TekGrid', () => {
|
|
|
2708
2697
|
|
|
2709
2698
|
const spy = mockMetadata(instance);
|
|
2710
2699
|
instance.onCreated();
|
|
2711
|
-
|
|
2712
|
-
if (filterTooltip && filterTooltip.children && filterTooltip.children.length > 0) {
|
|
2713
|
-
const button = new Button(filterTooltip.children[0]);
|
|
2714
|
-
const event = new Event('click');
|
|
2715
|
-
button.click(event, {} as HTMLElement);
|
|
2716
|
-
}
|
|
2700
|
+
clickOnFilterButton(instance);
|
|
2717
2701
|
|
|
2718
2702
|
const inputs = instance.getFilterInputs();
|
|
2719
2703
|
expect(inputs[0].name).toBe('grid-filter-AND-CONTAINS-name-0');
|
|
2720
2704
|
expect(inputs[1].name).toBe('grid-filter-AND-GREATER_THAN_EQUALS-salary-0');
|
|
2721
2705
|
expect(inputs[2].name).toBe('grid-filter-AND-LESS_THAN_EQUALS-salary-1');
|
|
2722
|
-
spy.
|
|
2706
|
+
spy.mockReset();
|
|
2707
|
+
spyModalService.mockReset();
|
|
2723
2708
|
});
|
|
2724
2709
|
|
|
2725
2710
|
it('when called, should return the instances of filters with multiple inputs', () => {
|
|
2711
|
+
const spyModalService = jest.spyOn(ModalService, 'create').mockImplementation((modal: IModal) => (new Modal(modal)));
|
|
2726
2712
|
const instance = new TekGrid({
|
|
2727
2713
|
name: 'grid',
|
|
2728
2714
|
component: 'TekGrid',
|
|
@@ -2758,17 +2744,14 @@ describe('TekGrid', () => {
|
|
|
2758
2744
|
|
|
2759
2745
|
const spy = mockMetadata(instance);
|
|
2760
2746
|
instance.onCreated();
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
const button = new Button(filterTooltip.children[0]);
|
|
2764
|
-
const event = new Event('click');
|
|
2765
|
-
button.click(event, {} as HTMLElement);
|
|
2766
|
-
}
|
|
2747
|
+
|
|
2748
|
+
clickOnFilterButton(instance);
|
|
2767
2749
|
|
|
2768
2750
|
const inputs = instance.getFilterInputs('salary');
|
|
2769
2751
|
expect(inputs[0].name).toBe('grid-filter-AND-GREATER_THAN_EQUALS-salary-0');
|
|
2770
2752
|
expect(inputs[1].name).toBe('grid-filter-AND-LESS_THAN_EQUALS-salary-1');
|
|
2771
|
-
spy.
|
|
2753
|
+
spy.mockReset();
|
|
2754
|
+
spyModalService.mockReset();
|
|
2772
2755
|
});
|
|
2773
2756
|
});
|
|
2774
2757
|
});
|