Skip to content

Commit 88371c6

Browse files
committed
test(exporter): awaiting async methods #6224
(cherry picked from commit ed17b00)
1 parent 8728b55 commit 88371c6

File tree

2 files changed

+39
-39
lines changed

2 files changed

+39
-39
lines changed

projects/igniteui-angular/src/lib/services/excel/excel-exporter-grid.spec.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ describe('Excel Exporter', () => {
7676
fix.detectChanges();
7777

7878
let wrapper = await getExportedData(grid, options);
79-
wrapper.verifyDataFilesContent(actualData.simpleGridDataRecord5, 'One row only should have been exported!');
79+
await wrapper.verifyDataFilesContent(actualData.simpleGridDataRecord5, 'One row only should have been exported!');
8080

8181
options.ignoreFiltering = true;
8282
fix.detectChanges();
8383
wrapper = await getExportedData(grid, options);
84-
wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All 10 rows should have been exported!');
84+
await wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All 10 rows should have been exported!');
8585
});
8686

8787
it('should honor filter criteria changes.', async () => {
@@ -92,14 +92,14 @@ describe('Excel Exporter', () => {
9292
options.ignoreFiltering = false;
9393

9494
let wrapper = await getExportedData(grid, options);
95-
wrapper.verifyDataFilesContent(actualData.simpleGridDataRecord5, 'One row should have been exported!');
95+
await wrapper.verifyDataFilesContent(actualData.simpleGridDataRecord5, 'One row should have been exported!');
9696

9797
grid.filter('JobTitle', 'Director', IgxStringFilteringOperand.instance().condition('equals'), true);
9898
fix.detectChanges();
9999

100100
expect(grid.rowList.length).toEqual(2, 'Invalid number of rows after filtering!');
101101
wrapper = await getExportedData(grid, options);
102-
wrapper.verifyDataFilesContent(actualData.simpleGridDataDirectors, 'Two rows should have been exported!');
102+
await wrapper.verifyDataFilesContent(actualData.simpleGridDataDirectors, 'Two rows should have been exported!');
103103
});
104104

105105
it('should honor \'ignoreColumnsVisibility\' option.', async () => {
@@ -115,12 +115,12 @@ describe('Excel Exporter', () => {
115115

116116
expect(grid.visibleColumns.length).toEqual(2, 'Invalid number of visible columns!');
117117
let wrapper = await getExportedData(grid, options);
118-
wrapper.verifyDataFilesContent(actualData.simpleGridNameJobTitle, 'Two columns should have been exported!');
118+
await wrapper.verifyDataFilesContent(actualData.simpleGridNameJobTitle, 'Two columns should have been exported!');
119119

120120
options.ignoreColumnsVisibility = true;
121121
fix.detectChanges();
122122
wrapper = await getExportedData(grid, options);
123-
wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All three columns should have been exported!');
123+
await wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All three columns should have been exported!');
124124
});
125125

126126
it('should honor columns visibility changes.', async () => {
@@ -134,28 +134,28 @@ describe('Excel Exporter', () => {
134134

135135
expect(grid.visibleColumns.length).toEqual(3, 'Invalid number of visible columns!');
136136
let wrapper = await getExportedData(grid, options);
137-
wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All columns should have been exported!');
137+
await wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All columns should have been exported!');
138138

139139
grid.columns[0].hidden = true;
140140
fix.detectChanges();
141141

142142
expect(grid.visibleColumns.length).toEqual(2, 'Invalid number of visible columns!');
143143
wrapper = await getExportedData(grid, options);
144-
wrapper.verifyDataFilesContent(actualData.simpleGridNameJobTitle, 'Two columns should have been exported!');
144+
await wrapper.verifyDataFilesContent(actualData.simpleGridNameJobTitle, 'Two columns should have been exported!');
145145

146146
grid.columns[0].hidden = false;
147147
fix.detectChanges();
148148

149149
expect(grid.visibleColumns.length).toEqual(3, 'Invalid number of visible columns!');
150150
wrapper = await getExportedData(grid, options);
151-
wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All columns should have been exported!');
151+
await wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All columns should have been exported!');
152152

153153
grid.columns[0].hidden = undefined;
154154
fix.detectChanges();
155155

156156
expect(grid.visibleColumns.length).toEqual(3, 'Invalid number of visible columns!');
157157
wrapper = await getExportedData(grid, options);
158-
wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All columns should have been exported!');
158+
await wrapper.verifyDataFilesContent(actualData.simpleGridData, 'All columns should have been exported!');
159159
});
160160

161161
it('should honor columns declaration order.', async () => {
@@ -166,7 +166,7 @@ describe('Excel Exporter', () => {
166166
const grid = fix.componentInstance.grid;
167167

168168
const wrapper = await getExportedData(grid, options);
169-
wrapper.verifyDataFilesContent(actualData.simpleGridNameJobTitleID);
169+
await wrapper.verifyDataFilesContent(actualData.simpleGridNameJobTitleID);
170170
});
171171

172172
it('should honor \'ignorePinning\' option.', async () => {
@@ -179,13 +179,13 @@ describe('Excel Exporter', () => {
179179

180180
let wrapper = await getExportedData(grid, options);
181181
wrapper.verifyStructure();
182-
// wrapper.verifyTemplateFilesContent();
183-
wrapper.verifyDataFilesContent(actualData.gridNameFrozen, 'One frozen column should have been exported!');
182+
// await wrapper.verifyTemplateFilesContent();
183+
await wrapper.verifyDataFilesContent(actualData.gridNameFrozen, 'One frozen column should have been exported!');
184184

185185
options.ignorePinning = true;
186186
fix.detectChanges();
187187
wrapper = await getExportedData(grid, options);
188-
wrapper.verifyDataFilesContent(actualData.gridNameIDJobTitle, 'No frozen columns should have been exported!');
188+
await wrapper.verifyDataFilesContent(actualData.gridNameIDJobTitle, 'No frozen columns should have been exported!');
189189
});
190190

191191
it('should honor pinned state changes.', async () => {
@@ -194,12 +194,12 @@ describe('Excel Exporter', () => {
194194
const grid = result.grid;
195195

196196
let wrapper = await getExportedData(grid, options);
197-
wrapper.verifyDataFilesContent(actualData.gridNameFrozen, 'One frozen column should have been exported!');
197+
await wrapper.verifyDataFilesContent(actualData.gridNameFrozen, 'One frozen column should have been exported!');
198198

199199
grid.columns[1].pinned = false;
200200
fix.detectChanges();
201201
wrapper = await getExportedData(grid, options);
202-
wrapper.verifyDataFilesContent(actualData.simpleGridData, 'No frozen columns should have been exported!');
202+
await wrapper.verifyDataFilesContent(actualData.simpleGridData, 'No frozen columns should have been exported!');
203203
});
204204

205205
it('should honor all pinned columns.', async() => {
@@ -225,7 +225,7 @@ describe('Excel Exporter', () => {
225225
fix.detectChanges();
226226

227227
const wrapper = await getExportedData(grid, options);
228-
wrapper.verifyDataFilesContent(actualData.simpleGridSortByName);
228+
await wrapper.verifyDataFilesContent(actualData.simpleGridSortByName);
229229

230230
// XXX : ???? What's the point of this?
231231
// grid.clearSort();
@@ -242,20 +242,20 @@ describe('Excel Exporter', () => {
242242
fix.detectChanges();
243243

244244
let wrapper = await getExportedData(grid, options);
245-
wrapper.verifyDataFilesContent(actualData.simpleGridSortByName, 'Ascending sorted data should have been exported.');
245+
await wrapper.verifyDataFilesContent(actualData.simpleGridSortByName, 'Ascending sorted data should have been exported.');
246246

247247
grid.sort({fieldName: 'Name', dir: SortingDirection.Desc, ignoreCase: true, strategy: DefaultSortingStrategy.instance()});
248248
fix.detectChanges();
249249

250250
wrapper = await getExportedData(grid, options);
251-
wrapper.verifyDataFilesContent(actualData.simpleGridSortByNameDesc(true), 'Descending sorted data should have been exported.');
251+
await wrapper.verifyDataFilesContent(actualData.simpleGridSortByNameDesc(true), 'Descending sorted data should have been exported.');
252252

253253
grid.clearSort();
254254
grid.sort({fieldName: 'ID', dir: SortingDirection.Asc, ignoreCase: true, strategy: DefaultSortingStrategy.instance()});
255255
fix.detectChanges();
256256

257257
// wrapper = await getExportedData(grid, options);
258-
// wrapper.verifyDataFilesContent(actualData.simpleGridSortByNameDesc(false), 'Unsorted data should have been exported.');
258+
// await wrapper.verifyDataFilesContent(actualData.simpleGridSortByNameDesc(false), 'Unsorted data should have been exported.');
259259
});
260260

261261
it('should export all columns with the width specified in options.', async () => {
@@ -336,7 +336,7 @@ describe('Excel Exporter', () => {
336336
expect(cols[0].index).toBe(0);
337337
expect(cols[1].header).toBe('JobTitle');
338338
expect(cols[1].index).toBe(1);
339-
wrapper.verifyDataFilesContent(actualData.simpleGridNameJobTitle);
339+
await wrapper.verifyDataFilesContent(actualData.simpleGridNameJobTitle);
340340
});
341341

342342
it('should not export columns when \'onColumnExport\' is canceled.', async () => {
@@ -353,7 +353,7 @@ describe('Excel Exporter', () => {
353353
const wrapper = await getExportedData(grid, options);
354354
expect(wrapper.hasValues).toBe(false);
355355
wrapper.verifyStructure();
356-
wrapper.verifyTemplateFilesContent();
356+
await wrapper.verifyTemplateFilesContent();
357357
});
358358

359359
it('should fire \'onRowExport\' for each grid row.', async () => {
@@ -391,7 +391,7 @@ describe('Excel Exporter', () => {
391391
const wrapper = await getExportedData(grid, options);
392392
expect(wrapper.hasValues).toBe(false);
393393
wrapper.verifyStructure();
394-
wrapper.verifyTemplateFilesContent();
394+
await wrapper.verifyTemplateFilesContent();
395395
});
396396

397397
it('shouldn\'t affect grid sort expressions', async () => {

projects/igniteui-angular/src/lib/services/excel/excel-exporter.spec.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,76 +28,76 @@ describe('Excel Exporter', () => {
2828
const wrapper = await getExportedData([], options);
2929

3030
wrapper.verifyStructure();
31-
wrapper.verifyTemplateFilesContent();
31+
await wrapper.verifyTemplateFilesContent();
3232
});
3333

3434
it('should export empty objects successfully.', async () => {
3535
const wrapper = await getExportedData(SampleTestData.emptyObjectData(), options);
3636

3737
wrapper.verifyStructure();
38-
wrapper.verifyTemplateFilesContent();
38+
await wrapper.verifyTemplateFilesContent();
3939
});
4040

4141
it('should export string data without headers successfully.', async () => {
4242
options.columnWidth = 50;
4343
const wrapper = await getExportedData(SampleTestData.stringArray(), options);
4444

4545
wrapper.verifyStructure();
46-
wrapper.verifyTemplateFilesContent();
47-
wrapper.verifyDataFilesContent(actualData.noHeadersStringDataContent);
46+
await wrapper.verifyTemplateFilesContent();
47+
await wrapper.verifyDataFilesContent(actualData.noHeadersStringDataContent);
4848
});
4949

5050
it('should export date time data without headers successfully.', async () => {
5151
options.columnWidth = 50;
5252
const wrapper = await getExportedData(SampleTestData.dateArray(), options);
5353

5454
wrapper.verifyStructure();
55-
wrapper.verifyTemplateFilesContent();
56-
wrapper.verifyDataFilesContent(actualData.noHeadersDateTimeContent);
55+
await wrapper.verifyTemplateFilesContent();
56+
await wrapper.verifyDataFilesContent(actualData.noHeadersDateTimeContent);
5757
});
5858

5959
it('should export number data without headers successfully.', async () => {
6060
options.columnWidth = 50;
6161
const wrapper = await getExportedData(SampleTestData.numbersArray(), options);
6262

6363
wrapper.verifyStructure();
64-
// wrapper.verifyTemplateFilesContent();
65-
wrapper.verifyDataFilesContent(actualData.noHeadersNumberDataContent);
64+
// await wrapper.verifyTemplateFilesContent();
65+
await wrapper.verifyDataFilesContent(actualData.noHeadersNumberDataContent);
6666
});
6767

6868
it('should export object data without headers successfully.', async () => {
6969
const wrapper = await getExportedData(SampleTestData.noHeadersObjectArray(), options);
7070

7171
wrapper.verifyStructure();
72-
wrapper.verifyTemplateFilesContent();
73-
wrapper.verifyDataFilesContent(actualData.noHeadersObjectDataContent);
72+
await wrapper.verifyTemplateFilesContent();
73+
await wrapper.verifyDataFilesContent(actualData.noHeadersObjectDataContent);
7474
});
7575

7676
it('should export regular data successfully.', async () => {
7777
options.columnWidth = 50;
7878
const wrapper = await getExportedData(SampleTestData.contactsData(), options);
7979

8080
wrapper.verifyStructure();
81-
wrapper.verifyTemplateFilesContent();
82-
wrapper.verifyDataFilesContent(actualData.contactsDataContent);
81+
await wrapper.verifyTemplateFilesContent();
82+
await wrapper.verifyDataFilesContent(actualData.contactsDataContent);
8383
});
8484

8585
it('should export data with missing values successfully.', async () => {
8686
options.columnWidth = 50;
8787
const wrapper = await getExportedData(SampleTestData.contactsDataPartial(), options);
8888

8989
wrapper.verifyStructure();
90-
wrapper.verifyTemplateFilesContent();
91-
wrapper.verifyDataFilesContent(actualData.contactsPartialDataContent);
90+
await wrapper.verifyTemplateFilesContent();
91+
await wrapper.verifyDataFilesContent(actualData.contactsPartialDataContent);
9292
});
9393

9494
it('should export data with special characters successully.', async () => {
9595
options.columnWidth = 50;
9696
const wrapper = await getExportedData(SampleTestData.contactsFunkyData(), options);
9797

9898
wrapper.verifyStructure();
99-
wrapper.verifyTemplateFilesContent();
100-
wrapper.verifyDataFilesContent(actualData.contactsFunkyDataContent);
99+
await wrapper.verifyTemplateFilesContent();
100+
await wrapper.verifyDataFilesContent(actualData.contactsFunkyDataContent);
101101
});
102102

103103
it('should throw an exception when setting negative width and height.', () => {

0 commit comments

Comments
 (0)