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

@@ -76,21 +76,21 @@ define(
mockAction = jasmine.createSpyObj('action', ['getActions']);
mockCompose = jasmine.createSpyObj('compose', ['perform']);
mockDomainObject.getId.andReturn(TEST_ID);
mockDomainObject.getModel.andReturn(testModel);
mockDomainObject.getCapability.andCallFake(function (c) {
mockDomainObject.getId.and.returnValue(TEST_ID);
mockDomainObject.getModel.and.returnValue(testModel);
mockDomainObject.getCapability.and.callFake(function (c) {
return {
persistence: mockPersistence,
action: mockAction
}[c];
});
mockDomainObject.useCapability.andReturn(true);
mockEvent.dataTransfer.getData.andReturn(DROP_ID);
mockDomainObject.useCapability.and.returnValue(true);
mockEvent.dataTransfer.getData.and.returnValue(DROP_ID);
mockElement[0] = mockUnwrappedElement;
mockElement.scope.andReturn(mockScope);
mockUnwrappedElement.getBoundingClientRect.andReturn(testRect);
mockDndService.getData.andReturn(mockDraggedObject);
mockAction.getActions.andReturn([mockCompose]);
mockElement.scope.and.returnValue(mockScope);
mockUnwrappedElement.getBoundingClientRect.and.returnValue(testRect);
mockDndService.getData.and.returnValue(mockDraggedObject);
mockAction.getActions.and.returnValue([mockCompose]);
gesture = new DropGesture(
mockDndService,
@@ -101,7 +101,7 @@ define(
// Get a reference to all callbacks registered during constructor
callbacks = {};
mockElement.on.calls.forEach(function (call) {
mockElement.on.calls.all().forEach(function (call) {
callbacks[call.args[0]] = call.args[1];
});
});
@@ -132,7 +132,7 @@ define(
it("invokes compose on drop in edit mode", function () {
// Set the mockDomainObject to have the editor capability
mockDomainObject.hasCapability.andReturn(true);
mockDomainObject.hasCapability.and.returnValue(true);
callbacks.dragover(mockEvent);
expect(mockAction.getActions).toHaveBeenCalledWith({
@@ -145,9 +145,9 @@ define(
it("invokes compose on drop in browse mode for folders", function () {
// Set the mockDomainObject to not have the editor capability
mockDomainObject.hasCapability.andReturn(false);
mockDomainObject.hasCapability.and.returnValue(false);
// Set the mockDomainObject to have a type of folder
mockDomainObject.getModel.andReturn({type: 'folder'});
mockDomainObject.getModel.and.returnValue({type: 'folder'});
callbacks.dragover(mockEvent);
expect(mockAction.getActions).toHaveBeenCalledWith({
@@ -160,7 +160,7 @@ define(
it("broadcasts drop position (in edit mode)", function () {
// Set the mockDomainObject to have the editor capability
mockDomainObject.hasCapability.andReturn(true);
mockDomainObject.hasCapability.and.returnValue(true);
testRect.left = 42;
testRect.top = 36;