Skip to content

Commit 3d9f4ba

Browse files
prx-lmomportuga
authored andcommitted
[hotfix/4446]
- added unit tests
1 parent a4e8f73 commit 3d9f4ba

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

packages/exporter/test/exporter.spec.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,19 @@ describe('ui.grid.exporter', function() {
738738
callback();
739739
}
740740
});
741+
spyOn(uiGridExporterService, 'exporterCsvFilename');
742+
grid.options.exporterCsvFilename = function(grid, rowTypes, colTypes) {
743+
if (!grid) {
744+
throw Error("got erroneous Parameter: no grid");
745+
}
746+
if (rowTypes != uiGridExporterConstants.VISIBLE) {
747+
throw Error("got erroneous Parameter: rowTypes != uiGridExporterConstants.VISIBLE");
748+
}
749+
if (colTypes != uiGridExporterConstants.VISIBLE) {
750+
throw Error("got erroneous Parameter: colTypes != uiGridExporterConstants.VISIBLE");
751+
}
752+
return "test";
753+
}
741754
uiGridExporterService.csvExport(grid, uiGridExporterConstants.VISIBLE, uiGridExporterConstants.VISIBLE);
742755
});
743756
afterEach(function() {
@@ -750,6 +763,9 @@ describe('ui.grid.exporter', function() {
750763
it('calls downloadFile', function() {
751764
expect(uiGridExporterService.downloadFile).toHaveBeenCalled();
752765
});
766+
it('calls exporterCsvFilename', function() {
767+
expect(uiGridExporterService.exporterCsvFilename).toHaveBeenCalled();
768+
});
753769
});
754770

755771
describe('loadAllDataIfNeeded', function() {
@@ -1043,6 +1059,26 @@ describe('ui.grid.exporter', function() {
10431059
uiGridExporterService.pdfExport(grid, uiGridExporterConstants.ALL);
10441060
expect(uiGridExporterService.loadAllDataIfNeeded).toHaveBeenCalled();
10451061
});
1062+
1063+
it('calls exporterPdfFilename', function() {
1064+
spyOn(uiGridExporterService, 'exporterPdfFilename');
1065+
grid.options.exporterCsvFilename = function(grid, rowTypes, colTypes) {
1066+
if (!grid) {
1067+
throw Error("got erroneous Parameter: no grid");
1068+
}
1069+
if (rowTypes != uiGridExporterConstants.VISIBLE) {
1070+
throw Error("got erroneous Parameter: rowTypes != uiGridExporterConstants.VISIBLE");
1071+
}
1072+
if (colTypes != uiGridExporterConstants.VISIBLE) {
1073+
throw Error("got erroneous Parameter: colTypes != uiGridExporterConstants.VISIBLE");
1074+
}
1075+
return "test";
1076+
}
1077+
1078+
uiGridExporterService.pdfExport(grid, uiGridExporterConstants.ALL);
1079+
expect(uiGridExporterService.exporterCsvFilename).toHaveBeenCalled();
1080+
});
1081+
10461082
});
10471083

10481084
describe('prepareAsPdf', function() {
@@ -1324,6 +1360,44 @@ describe('ui.grid.exporter', function() {
13241360
uiGridExporterService.excelExport(grid, uiGridExporterConstants.ALL);
13251361
expect(uiGridExporterService.loadAllDataIfNeeded).toHaveBeenCalled();
13261362
});
1363+
1364+
it('calls exporterExcelFilename', function() {
1365+
spyOn(uiGridExporterService, 'exporterExcelFilename');
1366+
grid.options.exporterExcelFilename = function(grid, rowTypes, colTypes) {
1367+
if (!grid) {
1368+
throw Error("got erroneous Parameter: no grid");
1369+
}
1370+
if (rowTypes != uiGridExporterConstants.VISIBLE) {
1371+
throw Error("got erroneous Parameter: rowTypes != uiGridExporterConstants.VISIBLE");
1372+
}
1373+
if (colTypes != uiGridExporterConstants.VISIBLE) {
1374+
throw Error("got erroneous Parameter: colTypes != uiGridExporterConstants.VISIBLE");
1375+
}
1376+
return "test";
1377+
}
1378+
1379+
uiGridExporterService.excelExport(grid, uiGridExporterConstants.ALL);
1380+
expect(uiGridExporterService.exporterExcelFilename).toHaveBeenCalled();
1381+
});
1382+
1383+
it('calls exporterExcelSheetName', function() {
1384+
spyOn(uiGridExporterService, 'exporterExcelSheetName');
1385+
grid.options.exporterExcelSheetName = function(grid, rowTypes, colTypes) {
1386+
if (!grid) {
1387+
throw Error("got erroneous Parameter: no grid");
1388+
}
1389+
if (rowTypes != uiGridExporterConstants.VISIBLE) {
1390+
throw Error("got erroneous Parameter: rowTypes != uiGridExporterConstants.VISIBLE");
1391+
}
1392+
if (colTypes != uiGridExporterConstants.VISIBLE) {
1393+
throw Error("got erroneous Parameter: colTypes != uiGridExporterConstants.VISIBLE");
1394+
}
1395+
return "test";
1396+
}
1397+
1398+
uiGridExporterService.excelExport(grid, uiGridExporterConstants.ALL);
1399+
expect(uiGridExporterService.exporterExcelSheetName).toHaveBeenCalled();
1400+
});
13271401
});
13281402
});
13291403

0 commit comments

Comments
 (0)