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:
committed by
Pete Richards
parent
013eba744d
commit
433dee0314
@@ -39,7 +39,7 @@ define(
|
||||
gesture;
|
||||
|
||||
function fireEvent(evt, value) {
|
||||
mockElement.on.calls.forEach(function (call) {
|
||||
mockElement.on.calls.all().forEach(function (call) {
|
||||
if (call.args[0] === evt) {
|
||||
call.args[1](value);
|
||||
}
|
||||
@@ -68,14 +68,14 @@ define(
|
||||
mockPromise = jasmine.createSpyObj('promise', ['then']);
|
||||
mockHide = jasmine.createSpy('hide');
|
||||
|
||||
mockDomainObject.getModel.andReturn({ name: "Test Object" });
|
||||
mockDomainObject.useCapability.andCallFake(function (c) {
|
||||
mockDomainObject.getModel.and.returnValue({ name: "Test Object" });
|
||||
mockDomainObject.useCapability.and.callFake(function (c) {
|
||||
return (c === 'metadata') ? testMetadata : undefined;
|
||||
});
|
||||
mockElement.scope.andReturn(mockScope);
|
||||
mockScope.$on.andReturn(mockOff);
|
||||
mockTimeout.andReturn(mockPromise);
|
||||
mockInfoService.display.andReturn(mockHide);
|
||||
mockElement.scope.and.returnValue(mockScope);
|
||||
mockScope.$on.and.returnValue(mockOff);
|
||||
mockTimeout.and.returnValue(mockPromise);
|
||||
mockInfoService.display.and.returnValue(mockHide);
|
||||
|
||||
gesture = new InfoGesture(
|
||||
mockTimeout,
|
||||
@@ -96,7 +96,7 @@ define(
|
||||
fireEvent("mouseenter", { clientX: 1977, clientY: 42 });
|
||||
expect(mockTimeout)
|
||||
.toHaveBeenCalledWith(jasmine.any(Function), testDelay);
|
||||
mockTimeout.mostRecentCall.args[0]();
|
||||
mockTimeout.calls.mostRecent().args[0]();
|
||||
expect(mockInfoService.display).toHaveBeenCalledWith(
|
||||
jasmine.any(String),
|
||||
"Test Object",
|
||||
@@ -114,7 +114,7 @@ define(
|
||||
|
||||
it("hides a shown bubble when mouse leaves", function () {
|
||||
fireEvent("mouseenter", { clientX: 1977, clientY: 42 });
|
||||
mockTimeout.mostRecentCall.args[0]();
|
||||
mockTimeout.calls.mostRecent().args[0]();
|
||||
expect(mockHide).not.toHaveBeenCalled(); // verify precondition
|
||||
fireEvent("mouseleave", {});
|
||||
expect(mockHide).toHaveBeenCalled();
|
||||
@@ -124,7 +124,7 @@ define(
|
||||
fireEvent("mouseenter", { clientX: 1977, clientY: 42 });
|
||||
fireEvent("mousemove", { clientX: 1999, clientY: 11 });
|
||||
fireEvent("mousemove", { clientX: 1984, clientY: 11 });
|
||||
mockTimeout.mostRecentCall.args[0]();
|
||||
mockTimeout.calls.mostRecent().args[0]();
|
||||
// Should have displayed at the latest observed mouse position
|
||||
expect(mockInfoService.display).toHaveBeenCalledWith(
|
||||
jasmine.any(String),
|
||||
@@ -136,7 +136,7 @@ define(
|
||||
|
||||
it("hides shown bubbles when destroyed", function () {
|
||||
fireEvent("mouseenter", { clientX: 1977, clientY: 42 });
|
||||
mockTimeout.mostRecentCall.args[0]();
|
||||
mockTimeout.calls.mostRecent().args[0]();
|
||||
expect(mockHide).not.toHaveBeenCalled(); // verify precondition
|
||||
gesture.destroy();
|
||||
expect(mockHide).toHaveBeenCalled();
|
||||
@@ -145,7 +145,7 @@ define(
|
||||
it("detaches listeners when destroyed", function () {
|
||||
fireEvent("mouseenter", { clientX: 1977, clientY: 42 });
|
||||
gesture.destroy();
|
||||
mockElement.on.calls.forEach(function (call) {
|
||||
mockElement.on.calls.all().forEach(function (call) {
|
||||
expect(mockElement.off).toHaveBeenCalledWith(
|
||||
call.args[0],
|
||||
call.args[1]
|
||||
|
||||
Reference in New Issue
Block a user