Update test specs to use Jasmine 3 (#2089)

* Updated Karma and Jasmine versions

* Added DOMObserver class. Supports promise-based testing of DOM changes

Update asynchronous test specs to use promises or done() instead of waitsFor/runs

* Modified ActionCapability to duplicate context object properties as own properties for better object equality comparisons

* Global find + replace to fix syntax issues

* Fixed various issues caused by non-deterministic runtime order of tests in Jasmine 3. Fixed issues caused by changes to determination of object equality

* Addressed review comments

* Resolved merge conflicts with master

* Fixed style errors

* Use spy.calls.count() instead of manually tracking
This commit is contained in:
Andrew Henry
2018-06-29 17:32:59 -07:00
committed by Pete Richards
parent 013eba744d
commit 433dee0314
305 changed files with 2866 additions and 3324 deletions

View File

@ -61,17 +61,17 @@ define(
mockLocation = jasmine.createSpyObj('$location',
["search"]
);
mockLocation.search.andReturn({"view": "fixed"});
mockLocation.search.and.returnValue({"view": "fixed"});
mockNavigationService = jasmine.createSpyObj('navigationService',
["checkBeforeNavigation"]
);
removeCheck = jasmine.createSpy('removeCheck');
mockNavigationService.checkBeforeNavigation.andReturn(removeCheck);
mockNavigationService.checkBeforeNavigation.and.returnValue(removeCheck);
mockObject.getId.andReturn("test");
mockObject.getModel.andReturn({ name: "Test object" });
mockObject.getCapability.andCallFake(function (key) {
mockObject.getId.and.returnValue("test");
mockObject.getModel.and.returnValue({ name: "Test object" });
mockObject.getCapability.and.callFake(function (key) {
return mockCapabilities[key];
});
@ -81,10 +81,10 @@ define(
{ key: 'xyz' }
];
mockObject.useCapability.andCallFake(function (c) {
mockObject.useCapability.and.callFake(function (c) {
return (c === 'view') && testViews;
});
mockLocation.search.andReturn({ view: 'def' });
mockLocation.search.and.returnValue({ view: 'def' });
mockScope.domainObject = mockObject;
@ -99,17 +99,17 @@ define(
expect(mockNavigationService.checkBeforeNavigation)
.toHaveBeenCalledWith(jasmine.any(Function));
var checkFn = mockNavigationService.checkBeforeNavigation.mostRecentCall.args[0];
var checkFn = mockNavigationService.checkBeforeNavigation.calls.mostRecent().args[0];
mockEditorCapability.isEditContextRoot.andReturn(false);
mockEditorCapability.dirty.andReturn(false);
mockEditorCapability.isEditContextRoot.and.returnValue(false);
mockEditorCapability.dirty.and.returnValue(false);
expect(checkFn()).toBe("Continuing will cause the loss of any unsaved changes.");
mockEditorCapability.isEditContextRoot.andReturn(true);
mockEditorCapability.isEditContextRoot.and.returnValue(true);
expect(checkFn()).toBe("Continuing will cause the loss of any unsaved changes.");
mockEditorCapability.dirty.andReturn(true);
mockEditorCapability.dirty.and.returnValue(true);
expect(checkFn())
.toBe("Continuing will cause the loss of any unsaved changes.");
@ -119,7 +119,7 @@ define(
expect(mockScope.$on)
.toHaveBeenCalledWith("$destroy", jasmine.any(Function));
mockScope.$on.mostRecentCall.args[1]();
mockScope.$on.calls.mostRecent().args[1]();
expect(mockEditorCapability.finish).toHaveBeenCalled();
expect(removeCheck).toHaveBeenCalled();