[Timeline] Update spec to include logging

This commit is contained in:
Victor Woeltjen 2016-05-25 12:25:02 -07:00
parent a3bcaea7f9
commit d7f566088f

View File

@ -24,7 +24,8 @@ define(
['../../src/actions/ExportTimelineAsCSVAction'], ['../../src/actions/ExportTimelineAsCSVAction'],
function (ExportTimelineAsCSVAction) { function (ExportTimelineAsCSVAction) {
describe("ExportTimelineAsCSVAction", function () { describe("ExportTimelineAsCSVAction", function () {
var mockExportService, var mockLog,
mockExportService,
mockNotificationService, mockNotificationService,
mockNotification, mockNotification,
mockDomainObject, mockDomainObject,
@ -39,6 +40,13 @@ define(
['getId', 'getModel', 'getCapability', 'hasCapability'] ['getId', 'getModel', 'getCapability', 'hasCapability']
); );
mockType = jasmine.createSpyObj('type', ['instanceOf']); mockType = jasmine.createSpyObj('type', ['instanceOf']);
mockLog = jasmine.createSpyObj('$log', [
'warn',
'error',
'info',
'debug'
]);
mockExportService = jasmine.createSpyObj( mockExportService = jasmine.createSpyObj(
'exportService', 'exportService',
['exportCSV'] ['exportCSV']
@ -63,8 +71,10 @@ define(
testContext = { domainObject: mockDomainObject }; testContext = { domainObject: mockDomainObject };
action = new ExportTimelineAsCSVAction( action = new ExportTimelineAsCSVAction(
mockLog,
mockExportService, mockExportService,
mockNotificationService, mockNotificationService,
[],
testContext testContext
); );
}); });
@ -129,8 +139,11 @@ define(
}); });
describe("and an error occurs", function () { describe("and an error occurs", function () {
var testError;
beforeEach(function () { beforeEach(function () {
testPromise.reject(); testError = { someProperty: "some value" };
testPromise.reject(testError);
waitsFor(function () { waitsFor(function () {
return mockCallback.calls.length > 0; return mockCallback.calls.length > 0;
}); });
@ -145,6 +158,10 @@ define(
expect(mockNotificationService.error) expect(mockNotificationService.error)
.toHaveBeenCalledWith(jasmine.any(String)); .toHaveBeenCalledWith(jasmine.any(String));
}); });
it("logs the root cause", function () {
expect(mockLog.warn).toHaveBeenCalledWith(testError);
});
}); });
}); });
}); });