diff --git a/karma.conf.js b/karma.conf.js index 085d3b3a00..660acf3ac5 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -65,7 +65,7 @@ module.exports = function(config) { // Test results reporter to use // Possible values: 'dots', 'progress' // Available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['progress', 'coverage', 'html', 'junit'], + reporters: ['progress', 'coverage', 'html'], // Web server port. port: 9876, @@ -81,7 +81,7 @@ module.exports = function(config) { // Specify browsers to run tests in. // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher browsers: [ - 'Chrome' + 'ChromeHeadless' ], // Code coverage reporting. @@ -104,10 +104,6 @@ module.exports = function(config) { foldAll: false }, - junitReporter: { - outputDir: process.env.CIRCLE_TEST_REPORTS || 'dist/reports/junit' - }, - // Continuous Integration mode. // If true, Karma captures browsers, runs the tests and exits. singleRun: true diff --git a/package.json b/package.json index 6742214a47..d6256351d8 100644 --- a/package.json +++ b/package.json @@ -32,18 +32,17 @@ "gulp-sass": "^3.1.0", "gulp-sourcemaps": "^1.6.0", "html2canvas": "^1.0.0-alpha.12", - "jasmine-core": "^2.3.0", + "jasmine-core": "^3.1.0", "jscs-html-reporter": "^0.1.0", "jsdoc": "^3.3.2", "jshint": "^2.7.0", - "karma": "^0.13.3", - "karma-chrome-launcher": "^0.1.12", - "karma-cli": "0.0.4", - "karma-coverage": "^0.5.3", + "karma": "^2.0.3", + "karma-chrome-launcher": "^2.2.0", + "karma-cli": "^1.0.1", + "karma-coverage": "^1.1.2", "karma-html-reporter": "^0.2.7", - "karma-jasmine": "^0.1.5", - "karma-junit-reporter": "^0.3.8", - "karma-requirejs": "^0.2.2", + "karma-jasmine": "^1.1.2", + "karma-requirejs": "^1.1.0", "lodash": "^3.10.1", "markdown-toc": "^0.11.7", "marked": "^0.3.5", diff --git a/platform/commonUI/browse/test/BrowseControllerSpec.js b/platform/commonUI/browse/test/BrowseControllerSpec.js index d979d14d1a..20b20805a6 100644 --- a/platform/commonUI/browse/test/BrowseControllerSpec.js +++ b/platform/commonUI/browse/test/BrowseControllerSpec.js @@ -19,6 +19,7 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ +/*global console*/ /** * MCTRepresentationSpec. Created by vwoeltje on 11/6/14. @@ -48,9 +49,19 @@ define( controller; function waitsForNavigation() { - var calls = mockNavigationService.setNavigation.calls.length; - waitsFor(function () { - return mockNavigationService.setNavigation.calls.length > calls; + return new Promise(function (resolve) { + mockNavigationService.setNavigation.and.callFake(function (obj) { + var returnValue; + try { + returnValue = NavigationService.prototype.setNavigation.call(mockNavigationService, obj); + } catch (err) { + console.error(err); + //Not rejecting because 'setNavigation' has been called, which is what's being tested here. + //Rejecting will fail tests. + } + resolve(); + return returnValue; + }); }); } @@ -78,7 +89,7 @@ define( "urlService", ["urlForLocation"] ); - mockUrlService.urlForLocation.andCallFake(function (mode, object) { + mockUrlService.urlForLocation.and.callFake(function (mode, object) { if (object === mockDefaultRootObject) { return [mode, testDefaultRoot].join('/'); } @@ -106,7 +117,7 @@ define( "removeListener" ].forEach(function (method) { spyOn(mockNavigationService, method) - .andCallThrough(); + .and.callThrough(); }); mockRootObject = jasmine.createSpyObj( "rootObjectContainer", @@ -124,60 +135,58 @@ define( "nestedDomainObject", ["getId", "getCapability", "getModel", "useCapability", "hasCapability"] ); - mockObjectService.getObjects.andReturn(Promise.resolve({ + mockObjectService.getObjects.and.returnValue(Promise.resolve({ ROOT: mockRootObject })); - mockRootObject.useCapability.andReturn(Promise.resolve([ + mockRootObject.useCapability.and.returnValue(Promise.resolve([ mockOtherDomainObject, mockDefaultRootObject ])); - mockRootObject.hasCapability.andReturn(true); - mockDefaultRootObject.useCapability.andReturn(Promise.resolve([ + mockRootObject.hasCapability.and.returnValue(true); + mockDefaultRootObject.useCapability.and.returnValue(Promise.resolve([ mockNextObject ])); - mockDefaultRootObject.hasCapability.andReturn(true); - mockOtherDomainObject.hasCapability.andReturn(false); - mockNextObject.useCapability.andReturn(undefined); - mockNextObject.hasCapability.andReturn(false); - mockNextObject.getId.andReturn("next"); - mockDefaultRootObject.getId.andReturn(testDefaultRoot); + mockDefaultRootObject.hasCapability.and.returnValue(true); + mockOtherDomainObject.hasCapability.and.returnValue(false); + mockNextObject.useCapability.and.returnValue(undefined); + mockNextObject.hasCapability.and.returnValue(false); + mockNextObject.getId.and.returnValue("next"); + mockDefaultRootObject.getId.and.returnValue(testDefaultRoot); instantiateController(); - waitsForNavigation(); + return waitsForNavigation(); }); it("uses composition to set the navigated object, if there is none", function () { instantiateController(); - waitsForNavigation(); - runs(function () { + return waitsForNavigation().then(function () { expect(mockNavigationService.setNavigation) - .toHaveBeenCalledWith(mockDefaultRootObject); + .toHaveBeenCalledWith(mockDefaultRootObject); }); }); it("navigates to a root-level object, even when default path is not found", function () { mockDefaultRootObject.getId - .andReturn("something-other-than-the-" + testDefaultRoot); + .and.returnValue("something-other-than-the-" + testDefaultRoot); instantiateController(); - waitsForNavigation(); - runs(function () { + return waitsForNavigation().then(function () { expect(mockNavigationService.setNavigation) - .toHaveBeenCalledWith(mockDefaultRootObject); + .toHaveBeenCalledWith(mockDefaultRootObject); }); + }); - }); - // it("does not try to override navigation", function () { - mockNavigationService.getNavigation.andReturn(mockDefaultRootObject); + mockNavigationService.getNavigation.and.returnValue(mockDefaultRootObject); instantiateController(); - waitsForNavigation(); - expect(mockScope.navigatedObject).toBe(mockDefaultRootObject); + return waitsForNavigation().then(function () { + expect(mockScope.navigatedObject).toBe(mockDefaultRootObject); + }); }); - // + it("updates scope when navigated object changes", function () { // Should have registered a listener - call it - mockNavigationService.addListener.mostRecentCall.args[0]( + mockNavigationService.addListener.calls.mostRecent().args[0]( mockOtherDomainObject ); expect(mockScope.navigatedObject).toEqual(mockOtherDomainObject); @@ -189,19 +198,18 @@ define( "$destroy", jasmine.any(Function) ); - mockScope.$on.mostRecentCall.args[1](); + mockScope.$on.calls.mostRecent().args[1](); // Should remove the listener it added earlier expect(mockNavigationService.removeListener).toHaveBeenCalledWith( - mockNavigationService.addListener.mostRecentCall.args[0] + mockNavigationService.addListener.calls.mostRecent().args[0] ); }); it("uses route parameters to choose initially-navigated object", function () { mockRoute.current.params.ids = testDefaultRoot + "/next"; instantiateController(); - waitsForNavigation(); - runs(function () { + return waitsForNavigation().then(function () { expect(mockScope.navigatedObject).toBe(mockNextObject); expect(mockNavigationService.setNavigation) .toHaveBeenCalledWith(mockNextObject); @@ -214,12 +222,10 @@ define( // it hits an invalid ID. mockRoute.current.params.ids = testDefaultRoot + "/junk"; instantiateController(); - waitsForNavigation(); - runs(function () { + return waitsForNavigation().then(function () { expect(mockScope.navigatedObject).toBe(mockDefaultRootObject); expect(mockNavigationService.setNavigation) .toHaveBeenCalledWith(mockDefaultRootObject); - }); }); @@ -229,8 +235,7 @@ define( // should stop at it since remaining IDs cannot be loaded. mockRoute.current.params.ids = testDefaultRoot + "/next/junk"; instantiateController(); - waitsForNavigation(); - runs(function () { + return waitsForNavigation().then(function () { expect(mockScope.navigatedObject).toBe(mockNextObject); expect(mockNavigationService.setNavigation) .toHaveBeenCalledWith(mockNextObject); @@ -244,11 +249,11 @@ define( expect(mockRoute.current.pathParams.ids) .not .toBe(testDefaultRoot + '/next'); - mockLocation.path.andCallFake(function () { + mockLocation.path.and.callFake(function () { expect(mockRoute.current.pathParams.ids) .toBe(testDefaultRoot + '/next'); }); - mockNavigationService.addListener.mostRecentCall.args[0]( + mockNavigationService.addListener.calls.mostRecent().args[0]( mockNextObject ); expect(mockLocation.path).toHaveBeenCalledWith( diff --git a/platform/commonUI/browse/test/BrowseObjectControllerSpec.js b/platform/commonUI/browse/test/BrowseObjectControllerSpec.js index b55c0a12b0..5a5db6f4fb 100644 --- a/platform/commonUI/browse/test/BrowseObjectControllerSpec.js +++ b/platform/commonUI/browse/test/BrowseObjectControllerSpec.js @@ -20,7 +20,6 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ - define( ["../src/BrowseObjectController"], function (BrowseObjectController) { @@ -33,7 +32,7 @@ define( // Utility function; look for a $watch on scope and fire it function fireWatch(expr, value) { - mockScope.$watch.calls.forEach(function (call) { + mockScope.$watch.calls.all().forEach(function (call) { if (call.args[0] === expr) { call.args[1](value); } @@ -50,7 +49,7 @@ define( "$location", ["path", "search"] ); - mockLocation.search.andReturn({}); + mockLocation.search.and.returnValue({}); controller = new BrowseObjectController( mockScope, @@ -65,7 +64,7 @@ define( // Allows the path index to be checked // prior to setting $route.current - mockLocation.path.andReturn("/browse/"); + mockLocation.path.and.returnValue("/browse/"); }); it("sets the active view from query parameters", function () { @@ -79,10 +78,10 @@ define( { key: 'xyz' } ]; - mockDomainObject.useCapability.andCallFake(function (c) { + mockDomainObject.useCapability.and.callFake(function (c) { return (c === 'view') && testViews; }); - mockLocation.search.andReturn({ view: 'def' }); + mockLocation.search.and.returnValue({ view: 'def' }); fireWatch('domainObject', mockDomainObject); expect(mockScope.representation.selected) diff --git a/platform/commonUI/browse/test/InspectorPaneControllerSpec.js b/platform/commonUI/browse/test/InspectorPaneControllerSpec.js index 016e88ecf5..ca2947a882 100644 --- a/platform/commonUI/browse/test/InspectorPaneControllerSpec.js +++ b/platform/commonUI/browse/test/InspectorPaneControllerSpec.js @@ -50,14 +50,14 @@ define( "navigationService", ["getNavigation", "addListener"] ); - mockNavigationService.addListener.andReturn(mockNavigationUnlistener); + mockNavigationService.addListener.and.returnValue(mockNavigationUnlistener); mockStatusUnlistener = jasmine.createSpy("statusUnlistener"); mockStatusCapability = jasmine.createSpyObj( "statusCapability", ["listen"] ); - mockStatusCapability.listen.andReturn(mockStatusUnlistener); + mockStatusCapability.listen.and.returnValue(mockStatusUnlistener); mockDomainObject = jasmine.createSpyObj( 'domainObject', @@ -68,13 +68,13 @@ define( 'hasCapability' ] ); - mockDomainObject.getId.andReturn("domainObject"); - mockDomainObject.getModel.andReturn({}); - mockDomainObject.hasCapability.andReturn(true); - mockDomainObject.getCapability.andReturn(mockStatusCapability); + mockDomainObject.getId.and.returnValue("domainObject"); + mockDomainObject.getModel.and.returnValue({}); + mockDomainObject.hasCapability.and.returnValue(true); + mockDomainObject.getCapability.and.returnValue(mockStatusCapability); mockLocation = jasmine.createSpyObj('location', ['search']); - mockLocation.search.andReturn({}); + mockLocation.search.and.returnValue({}); mockAttrs = {}; @@ -84,7 +84,7 @@ define( it("listens for changes to navigation and attaches a status" + " listener", function () { expect(mockNavigationService.addListener).toHaveBeenCalledWith(jasmine.any(Function)); - mockNavigationService.addListener.mostRecentCall.args[0](mockDomainObject); + mockNavigationService.addListener.calls.mostRecent().args[0](mockDomainObject); expect(mockStatusCapability.listen).toHaveBeenCalledWith(jasmine.any(Function)); }); @@ -93,8 +93,8 @@ define( controller.toggle(); // test pre-condition that inspector is hidden expect(controller.visible()).toBe(false); - mockNavigationService.addListener.mostRecentCall.args[0](mockDomainObject); - mockStatusCapability.listen.mostRecentCall.args[0](["editing"]); + mockNavigationService.addListener.calls.mostRecent().args[0](mockDomainObject); + mockStatusCapability.listen.calls.mostRecent().args[0](["editing"]); expect(controller.visible()).toBe(true); }); diff --git a/platform/commonUI/browse/test/MenuArrowControllerSpec.js b/platform/commonUI/browse/test/MenuArrowControllerSpec.js index 5d3bca7839..6a58645f63 100644 --- a/platform/commonUI/browse/test/MenuArrowControllerSpec.js +++ b/platform/commonUI/browse/test/MenuArrowControllerSpec.js @@ -60,8 +60,8 @@ define( mockActionContext.domainObject = mockDomainObject; mockActionContext.event = mockEvent; mockScope.domainObject = mockDomainObject; - mockDomainObject.getCapability.andReturn(mockContextMenuAction); - mockContextMenuAction.perform.andReturn(jasmine.any(Function)); + mockDomainObject.getCapability.and.returnValue(mockContextMenuAction); + mockContextMenuAction.perform.and.returnValue(jasmine.any(Function)); controller = new MenuArrowController(mockScope); }); diff --git a/platform/commonUI/browse/test/ObjectHeaderControllerSpec.js b/platform/commonUI/browse/test/ObjectHeaderControllerSpec.js index 172b693890..37281b2bec 100644 --- a/platform/commonUI/browse/test/ObjectHeaderControllerSpec.js +++ b/platform/commonUI/browse/test/ObjectHeaderControllerSpec.js @@ -39,7 +39,7 @@ define( mockMutationCapability = jasmine.createSpyObj("mutation", ["mutate"]); mockTypeCapability = jasmine.createSpyObj("type", ["typeDef", "hasFeature"]); mockTypeCapability.typeDef = { name: ""}; - mockTypeCapability.hasFeature.andCallFake(function (feature) { + mockTypeCapability.hasFeature.and.callFake(function (feature) { return feature === 'creation'; }); @@ -52,8 +52,8 @@ define( name: "Test name" }; mockDomainObject = jasmine.createSpyObj("domainObject", ["getCapability", "getModel"]); - mockDomainObject.getModel.andReturn(model); - mockDomainObject.getCapability.andCallFake(function (key) { + mockDomainObject.getModel.and.returnValue(model); + mockDomainObject.getCapability.and.callFake(function (key) { return mockCapabilities[key]; }); @@ -62,7 +62,7 @@ define( }; mockCurrentTarget = jasmine.createSpyObj("currentTarget", ["blur", "textContent"]); - mockCurrentTarget.blur.andReturn(mockCurrentTarget); + mockCurrentTarget.blur.and.returnValue(mockCurrentTarget); mockEvent = { which: {}, @@ -109,7 +109,7 @@ define( expect(mockMutationCapability.mutate).toHaveBeenCalledWith(jasmine.any(Function)); - mockMutationCapability.mutate.mostRecentCall.args[0](model); + mockMutationCapability.mutate.calls.mostRecent().args[0](model); expect(mockDomainObject.getModel().name).toBe("New name"); }); @@ -127,7 +127,7 @@ define( }); it("disallows editting name when object is non-creatable", function () { - mockTypeCapability.hasFeature.andReturn(false); + mockTypeCapability.hasFeature.and.returnValue(false); expect(controller.allowEdit()).toBe(false); diff --git a/platform/commonUI/browse/test/PaneControllerSpec.js b/platform/commonUI/browse/test/PaneControllerSpec.js index e68eb84406..94ec29c417 100644 --- a/platform/commonUI/browse/test/PaneControllerSpec.js +++ b/platform/commonUI/browse/test/PaneControllerSpec.js @@ -53,8 +53,8 @@ define( ['getId', 'getModel', 'getCapability'] ); - mockDomainObject.getId.andReturn(id); - mockDomainObject.getModel.andReturn({}); + mockDomainObject.getId.and.returnValue(id); + mockDomainObject.getModel.and.returnValue({}); return mockDomainObject; }); @@ -65,7 +65,7 @@ define( mockWindow = jasmine.createSpyObj("$window", ["open"]); mockLocation = jasmine.createSpyObj('location', ['search']); - mockLocation.search.andReturn({}); + mockLocation.search.and.returnValue({}); mockAttrs = {}; }); @@ -83,9 +83,9 @@ define( }); it("collapses on navigation changes on portrait-oriented phones", function () { - mockAgentService.isMobile.andReturn(true); - mockAgentService.isPhone.andReturn(true); - mockAgentService.isPortrait.andReturn(true); + mockAgentService.isMobile.and.returnValue(true); + mockAgentService.isPhone.and.returnValue(true); + mockAgentService.isPortrait.and.returnValue(true); controller = instantiateController(); expect(controller.visible()).toBeTruthy(); @@ -102,13 +102,13 @@ define( }); it("sets pane state to false when in location.search", function () { - mockLocation.search.andReturn({'hideTree': true}); + mockLocation.search.and.returnValue({'hideTree': true}); expect(instantiateController().visible()).toBe(false); expect(mockLocation.search).toHaveBeenCalledWith('hideTree', undefined); }); it("sets state to true when not found in location.search", function () { - mockLocation.search.andReturn({}); + mockLocation.search.and.returnValue({}); expect(instantiateController().visible()).toBe(true); expect(mockLocation.search).not.toHaveBeenCalledWith('hideTree', undefined); }); diff --git a/platform/commonUI/browse/test/navigation/NavigateActionSpec.js b/platform/commonUI/browse/test/navigation/NavigateActionSpec.js index 0091006057..7505d8da10 100644 --- a/platform/commonUI/browse/test/navigation/NavigateActionSpec.js +++ b/platform/commonUI/browse/test/navigation/NavigateActionSpec.js @@ -34,17 +34,6 @@ define([ mockDomainObject, action; - - function waitForCall() { - var called = false; - waitsFor(function () { - return called; - }); - return function () { - called = true; - }; - } - beforeEach(function () { mockNavigationService = jasmine.createSpyObj( "navigationService", @@ -63,26 +52,24 @@ define([ }); it("sets navigation if it is allowed", function () { - mockNavigationService.shouldNavigate.andReturn(true); - action.perform() - .then(waitForCall()); - runs(function () { - expect(mockNavigationService.setNavigation) + mockNavigationService.shouldNavigate.and.returnValue(true); + return action.perform() + .then(function () { + expect(mockNavigationService.setNavigation) .toHaveBeenCalledWith(mockDomainObject, true); - }); + }); }); it("does not set navigation if it is not allowed", function () { - mockNavigationService.shouldNavigate.andReturn(false); + mockNavigationService.shouldNavigate.and.returnValue(false); var onSuccess = jasmine.createSpy('onSuccess'); - action.perform() - .then(onSuccess, waitForCall()); - runs(function () { - expect(onSuccess).not.toHaveBeenCalled(); - expect(mockNavigationService.setNavigation) - .not - .toHaveBeenCalledWith(mockDomainObject); - }); + return action.perform() + .then(onSuccess, function () { + expect(onSuccess).not.toHaveBeenCalled(); + expect(mockNavigationService.setNavigation) + .not + .toHaveBeenCalledWith(mockDomainObject); + }); }); it("is only applicable when a domain object is in context", function () { diff --git a/platform/commonUI/browse/test/navigation/NavigationServiceSpec.js b/platform/commonUI/browse/test/navigation/NavigationServiceSpec.js index 3e9f2182d7..418660ca00 100644 --- a/platform/commonUI/browse/test/navigation/NavigationServiceSpec.js +++ b/platform/commonUI/browse/test/navigation/NavigationServiceSpec.js @@ -69,7 +69,7 @@ define( navigationService.addListener(callback); navigationService.setNavigation(testObject); navigationService.setNavigation(testObject); - expect(callback.calls.length).toEqual(1); + expect(callback.calls.count()).toEqual(1); }); it("stops notifying listeners after removal", function () { diff --git a/platform/commonUI/browse/test/navigation/OrphanNavigationHandlerSpec.js b/platform/commonUI/browse/test/navigation/OrphanNavigationHandlerSpec.js index ce796a74c0..f29a32e0a5 100644 --- a/platform/commonUI/browse/test/navigation/OrphanNavigationHandlerSpec.js +++ b/platform/commonUI/browse/test/navigation/OrphanNavigationHandlerSpec.js @@ -65,34 +65,35 @@ define([ mockActionCapability = jasmine.createSpyObj('action', ['perform']); mockEditor = jasmine.createSpyObj('editor', ['isEditContextRoot']); - mockThrottle.andCallFake(function (fn) { + mockThrottle.and.callFake(function (fn) { var mockThrottledFn = jasmine.createSpy('throttled-' + mockThrottledFns.length); - mockThrottledFn.andCallFake(fn); + mockThrottledFn.and.callFake(fn); mockThrottledFns.push(mockThrottledFn); return mockThrottledFn; }); - mockTopic.andReturn(mockMutationTopic); - mockDomainObject.getId.andReturn(testId); - mockDomainObject.getCapability.andCallFake(function (c) { + mockTopic.and.returnValue(mockMutationTopic); + mockDomainObject.getId.and.returnValue(testId); + mockDomainObject.getCapability.and.callFake(function (c) { return { context: mockContext, editor: mockEditor }[c]; }); - mockDomainObject.hasCapability.andCallFake(function (c) { + mockDomainObject.hasCapability.and.callFake(function (c) { return !!mockDomainObject.getCapability(c); }); - mockParentObject.getCapability.andCallFake(function (c) { + mockParentObject.getCapability.and.callFake(function (c) { return { action: mockActionCapability }[c]; }); testParentComposition = []; - mockParentObject.useCapability.andReturn(Promise.resolve(testParentComposition)); - mockContext.getParent.andReturn(mockParentObject); - mockNavigationService.getNavigation.andReturn(mockDomainObject); - mockEditor.isEditContextRoot.andReturn(false); + mockParentObject.useCapability.and.returnValue(Promise.resolve(testParentComposition)); + + mockContext.getParent.and.returnValue(mockParentObject); + mockNavigationService.getNavigation.and.returnValue(mockDomainObject); + mockEditor.isEditContextRoot.and.returnValue(false); return new OrphanNavigationHandler( mockThrottle, @@ -106,7 +107,7 @@ define([ expect(mockMutationTopic.listen) .toHaveBeenCalledWith(jasmine.any(Function)); expect(mockThrottledFns.indexOf( - mockMutationTopic.listen.mostRecentCall.args[0] + mockMutationTopic.listen.calls.mostRecent().args[0] )).not.toEqual(-1); }); @@ -114,7 +115,7 @@ define([ expect(mockNavigationService.addListener) .toHaveBeenCalledWith(jasmine.any(Function)); expect(mockThrottledFns.indexOf( - mockNavigationService.addListener.mostRecentCall.args[0] + mockNavigationService.addListener.calls.mostRecent().args[0] )).not.toEqual(-1); }); @@ -134,28 +135,14 @@ define([ function itNavigatesAsExpected() { if (isOrphan && !isEditRoot) { it("navigates to the parent", function () { - var done = false; - waitsFor(function () { - return done; - }); - setTimeout(function () { - done = true; - }, 5); - runs(function () { + return Promise.resolve().then(function () { expect(mockActionCapability.perform) .toHaveBeenCalledWith('navigate'); }); }); } else { it("does nothing", function () { - var done = false; - waitsFor(function () { - return done; - }); - setTimeout(function () { - done = true; - }, 5); - runs(function () { + return Promise.resolve().then(function () { expect(mockActionCapability.perform) .not.toHaveBeenCalled(); }); @@ -165,12 +152,12 @@ define([ describe(caseName, function () { beforeEach(function () { - mockEditor.isEditContextRoot.andReturn(isEditRoot); + mockEditor.isEditContextRoot.and.returnValue(isEditRoot); }); describe("when navigation changes", function () { beforeEach(function () { - mockNavigationService.addListener.mostRecentCall + mockNavigationService.addListener.calls.mostRecent() .args[0](mockDomainObject); }); itNavigatesAsExpected(); @@ -178,7 +165,7 @@ define([ describe("when mutation occurs", function () { beforeEach(function () { - mockMutationTopic.listen.mostRecentCall + mockMutationTopic.listen.calls.mostRecent() .args[0](mockParentObject); }); diff --git a/platform/commonUI/browse/test/windowing/WindowTitlerSpec.js b/platform/commonUI/browse/test/windowing/WindowTitlerSpec.js index 436b09b8da..ec1f6920c6 100644 --- a/platform/commonUI/browse/test/windowing/WindowTitlerSpec.js +++ b/platform/commonUI/browse/test/windowing/WindowTitlerSpec.js @@ -49,8 +49,8 @@ define( ); mockDocument = [{}]; - mockDomainObject.getModel.andReturn({ name: 'Test name' }); - mockNavigationService.getNavigation.andReturn(mockDomainObject); + mockDomainObject.getModel.and.returnValue({ name: 'Test name' }); + mockNavigationService.getNavigation.and.returnValue(mockDomainObject); titler = new WindowTitler( mockNavigationService, @@ -64,12 +64,12 @@ define( jasmine.any(Function), jasmine.any(Function) ); - expect(mockRootScope.$watch.mostRecentCall.args[0]()) + expect(mockRootScope.$watch.calls.mostRecent().args[0]()) .toEqual('Test name'); }); it("sets the title to the name of the navigated object", function () { - mockRootScope.$watch.mostRecentCall.args[1]("Some name"); + mockRootScope.$watch.calls.mostRecent().args[1]("Some name"); expect(mockDocument[0].title).toEqual("Some name"); }); diff --git a/platform/commonUI/dialog/test/DialogServiceSpec.js b/platform/commonUI/dialog/test/DialogServiceSpec.js index 0945c7fd3a..85347cf2f3 100644 --- a/platform/commonUI/dialog/test/DialogServiceSpec.js +++ b/platform/commonUI/dialog/test/DialogServiceSpec.js @@ -63,12 +63,12 @@ define( ["find"] ); mockBody = jasmine.createSpyObj('body', ['on', 'off']); - mockDocument.find.andReturn(mockBody); + mockDocument.find.and.returnValue(mockBody); mockDeferred.promise = "mock promise"; - mockQ.defer.andReturn(mockDeferred); - mockOverlayService.createOverlay.andReturn(mockOverlay); + mockQ.defer.and.returnValue(mockDeferred); + mockOverlayService.createOverlay.and.returnValue(mockOverlay); dialogService = new DialogService( mockOverlayService, @@ -85,7 +85,7 @@ define( it("allows user input to be canceled", function () { dialogService.getUserInput({}, { someKey: "some value" }); - mockOverlayService.createOverlay.mostRecentCall.args[1].cancel(); + mockOverlayService.createOverlay.calls.mostRecent().args[1].cancel(); expect(mockDeferred.reject).toHaveBeenCalled(); expect(mockDeferred.resolve).not.toHaveBeenCalled(); }); @@ -93,7 +93,7 @@ define( it("passes back the result of user input when confirmed", function () { var value = { someKey: 42 }; dialogService.getUserInput({}, value); - mockOverlayService.createOverlay.mostRecentCall.args[1].confirm(); + mockOverlayService.createOverlay.calls.mostRecent().args[1].confirm(); expect(mockDeferred.reject).not.toHaveBeenCalled(); expect(mockDeferred.resolve).toHaveBeenCalledWith(value); }); @@ -109,7 +109,7 @@ define( it("can show multiple dialogs if prior ones are dismissed", function () { dialogService.getUserInput({}, {}); expect(mockLog.warn).not.toHaveBeenCalled(); - mockOverlayService.createOverlay.mostRecentCall.args[1].confirm(); + mockOverlayService.createOverlay.calls.mostRecent().args[1].confirm(); dialogService.getUserInput({}, {}); expect(mockLog.warn).not.toHaveBeenCalled(); expect(mockDeferred.reject).not.toHaveBeenCalled(); @@ -148,13 +148,13 @@ define( it("destroys the event listener when the dialog is cancelled", function () { dialogService.getUserInput({}, {}); - mockOverlayService.createOverlay.mostRecentCall.args[1].cancel(); + mockOverlayService.createOverlay.calls.mostRecent().args[1].cancel(); expect(mockBody.off).toHaveBeenCalledWith("keydown", jasmine.any(Function)); }); it("cancels the dialog when an escape keydown event is triggered", function () { dialogService.getUserInput({}, {}); - mockBody.on.mostRecentCall.args[1]({ + mockBody.on.calls.mostRecent().args[1]({ keyCode: 27 }); expect(mockDeferred.reject).toHaveBeenCalled(); @@ -163,7 +163,7 @@ define( it("ignores non escape keydown events", function () { dialogService.getUserInput({}, {}); - mockBody.on.mostRecentCall.args[1]({ + mockBody.on.calls.mostRecent().args[1]({ keyCode: 13 }); expect(mockDeferred.reject).not.toHaveBeenCalled(); @@ -197,7 +197,7 @@ define( "overlay", ["dismiss"] ); - mockOverlayService.createOverlay.andReturn(secondMockOverlay); + mockOverlayService.createOverlay.and.returnValue(secondMockOverlay); secondDialogHandle = dialogService.showBlockingMessage(dialogModel); //Dismiss the first dialog. It should only dismiss if it diff --git a/platform/commonUI/dialog/test/OverlayServiceSpec.js b/platform/commonUI/dialog/test/OverlayServiceSpec.js index 958faefeb0..c699fb2a10 100644 --- a/platform/commonUI/dialog/test/OverlayServiceSpec.js +++ b/platform/commonUI/dialog/test/OverlayServiceSpec.js @@ -46,10 +46,10 @@ define( mockElement = jasmine.createSpyObj("element", ["remove"]); mockScope = jasmine.createSpyObj("scope", ["$destroy"]); - mockDocument.find.andReturn(mockBody); - mockCompile.andReturn(mockTemplate); - mockRootScope.$new.andReturn(mockScope); - mockTemplate.andReturn(mockElement); + mockDocument.find.and.returnValue(mockBody); + mockCompile.and.returnValue(mockTemplate); + mockRootScope.$new.and.returnValue(mockScope); + mockTemplate.and.returnValue(mockElement); overlayService = new OverlayService( mockDocument, @@ -61,7 +61,7 @@ define( it("prepends an mct-include to create overlays", function () { overlayService.createOverlay("test", {}); expect(mockCompile).toHaveBeenCalled(); - expect(mockCompile.mostRecentCall.args[0].indexOf("mct-include")) + expect(mockCompile.calls.mostRecent().args[0].indexOf("mct-include")) .not.toEqual(-1); }); diff --git a/platform/commonUI/edit/test/actions/CancelActionSpec.js b/platform/commonUI/edit/test/actions/CancelActionSpec.js index c75d747290..98a3ec28ad 100644 --- a/platform/commonUI/edit/test/actions/CancelActionSpec.js +++ b/platform/commonUI/edit/test/actions/CancelActionSpec.js @@ -49,7 +49,7 @@ define( "getModel" ] ); - mockDomainObject.getModel.andReturn({}); + mockDomainObject.getModel.and.returnValue({}); mockParentObject = jasmine.createSpyObj( "parentObject", @@ -57,7 +57,7 @@ define( "getCapability" ] ); - mockParentObject.getCapability.andCallFake(function (name) { + mockParentObject.getCapability.and.callFake(function (name) { return parentCapabilities[name]; }); @@ -77,14 +77,14 @@ define( "getOriginal" ] ); - capabilities.location.getOriginal.andReturn(mockPromise(mockDomainObject)); + capabilities.location.getOriginal.and.returnValue(mockPromise(mockDomainObject)); capabilities.context = jasmine.createSpyObj( "contextCapability", [ "getParent" ] ); - capabilities.context.getParent.andReturn(mockParentObject); + capabilities.context.getParent.and.returnValue(mockParentObject); parentCapabilities.action = jasmine.createSpyObj( "actionCapability", @@ -97,37 +97,37 @@ define( domainObject: mockDomainObject }; - mockDomainObject.getCapability.andCallFake(function (name) { + mockDomainObject.getCapability.and.callFake(function (name) { return capabilities[name]; }); - mockDomainObject.hasCapability.andCallFake(function (name) { + mockDomainObject.hasCapability.and.callFake(function (name) { return !!capabilities[name]; }); - capabilities.editor.finish.andReturn(mockPromise(true)); + capabilities.editor.finish.and.returnValue(mockPromise(true)); action = new CancelAction(actionContext); }); it("only applies to domain object that is being edited", function () { - capabilities.editor.isEditContextRoot.andReturn(true); + capabilities.editor.isEditContextRoot.and.returnValue(true); expect(CancelAction.appliesTo(actionContext)).toBeTruthy(); expect(mockDomainObject.hasCapability).toHaveBeenCalledWith("editor"); - capabilities.editor.isEditContextRoot.andReturn(false); + capabilities.editor.isEditContextRoot.and.returnValue(false); expect(CancelAction.appliesTo(actionContext)).toBeFalsy(); - mockDomainObject.hasCapability.andReturn(false); + mockDomainObject.hasCapability.and.returnValue(false); expect(CancelAction.appliesTo(actionContext)).toBeFalsy(); }); it("invokes the editor capability's cancel functionality when" + " performed", function () { - mockDomainObject.getModel.andReturn({persisted: 1}); + mockDomainObject.getModel.and.returnValue({persisted: 1}); //Return true from navigate action - capabilities.action.perform.andReturn(mockPromise(true)); + capabilities.action.perform.and.returnValue(mockPromise(true)); action.perform(); // Should have called finish @@ -138,15 +138,15 @@ define( }); it("navigates to object if existing using navigate action", function () { - mockDomainObject.getModel.andReturn({persisted: 1}); + mockDomainObject.getModel.and.returnValue({persisted: 1}); //Return true from navigate action - capabilities.action.perform.andReturn(mockPromise(true)); + capabilities.action.perform.and.returnValue(mockPromise(true)); action.perform(); expect(capabilities.action.perform).toHaveBeenCalledWith("navigate"); }); it("navigates to parent if new using navigate action", function () { - mockDomainObject.getModel.andReturn({persisted: undefined}); + mockDomainObject.getModel.and.returnValue({persisted: undefined}); action.perform(); expect(parentCapabilities.action.perform).toHaveBeenCalledWith("navigate"); }); diff --git a/platform/commonUI/edit/test/actions/EditActionSpec.js b/platform/commonUI/edit/test/actions/EditActionSpec.js index 69bf976496..1dbbbf1432 100644 --- a/platform/commonUI/edit/test/actions/EditActionSpec.js +++ b/platform/commonUI/edit/test/actions/EditActionSpec.js @@ -66,11 +66,11 @@ define( editor: mockEditor }; - mockDomainObject.getCapability.andCallFake(function (name) { + mockDomainObject.getCapability.and.callFake(function (name) { return capabilities[name]; }); - mockDomainObject.hasCapability.andReturn(true); - mockType.hasFeature.andReturn(true); + mockDomainObject.hasCapability.and.returnValue(true); + mockType.hasFeature.and.returnValue(true); actionContext = { domainObject: mockDomainObject }; @@ -92,9 +92,9 @@ define( }); it("is only applicable to objects not already in edit mode", function () { - mockEditor.isEditContextRoot.andReturn(false); + mockEditor.isEditContextRoot.and.returnValue(false); expect(EditAction.appliesTo(actionContext)).toBe(true); - mockEditor.isEditContextRoot.andReturn(true); + mockEditor.isEditContextRoot.and.returnValue(true); expect(EditAction.appliesTo(actionContext)).toBe(false); }); diff --git a/platform/commonUI/edit/test/actions/EditAndComposeActionSpec.js b/platform/commonUI/edit/test/actions/EditAndComposeActionSpec.js index 994104951c..6e2aba90a8 100644 --- a/platform/commonUI/edit/test/actions/EditAndComposeActionSpec.js +++ b/platform/commonUI/edit/test/actions/EditAndComposeActionSpec.js @@ -71,14 +71,14 @@ define( mockActionCapability = jasmine.createSpyObj("actionCapability", ["getActions"]); mockEditAction = jasmine.createSpyObj("editAction", ["perform"]); - mockDomainObject.getId.andReturn("test"); - mockDomainObject.getCapability.andReturn(mockContext); - mockContext.getParent.andReturn(mockParent); - mockType.hasFeature.andReturn(true); - mockType.getKey.andReturn("layout"); - mockComposition.invoke.andReturn(mockPromise(true)); - mockComposition.add.andReturn(mockPromise(true)); - mockActionCapability.getActions.andReturn([]); + mockDomainObject.getId.and.returnValue("test"); + mockDomainObject.getCapability.and.returnValue(mockContext); + mockContext.getParent.and.returnValue(mockParent); + mockType.hasFeature.and.returnValue(true); + mockType.getKey.and.returnValue("layout"); + mockComposition.invoke.and.returnValue(mockPromise(true)); + mockComposition.add.and.returnValue(mockPromise(true)); + mockActionCapability.getActions.and.returnValue([]); capabilities = { composition: mockComposition, @@ -105,14 +105,14 @@ define( }); it("enables edit mode for objects that have an edit action", function () { - mockActionCapability.getActions.andReturn([mockEditAction]); + mockActionCapability.getActions.and.returnValue([mockEditAction]); action.perform(); expect(mockEditAction.perform).toHaveBeenCalled(); }); it("Does not enable edit mode for objects that do not have an" + " edit action", function () { - mockActionCapability.getActions.andReturn([]); + mockActionCapability.getActions.and.returnValue([]); action.perform(); expect(mockEditAction.perform).not.toHaveBeenCalled(); expect(mockComposition.add) diff --git a/platform/commonUI/edit/test/actions/PropertiesActionSpec.js b/platform/commonUI/edit/test/actions/PropertiesActionSpec.js index ae1dc6b1b3..81c36b8d2c 100644 --- a/platform/commonUI/edit/test/actions/PropertiesActionSpec.js +++ b/platform/commonUI/edit/test/actions/PropertiesActionSpec.js @@ -71,8 +71,8 @@ define( } }; - capabilities.type.hasFeature.andReturn(true); - capabilities.mutation.andReturn(true); + capabilities.type.hasFeature.and.returnValue(true); + capabilities.mutation.and.returnValue(true); action = new PropertiesAction(dialogService, context); }); @@ -80,7 +80,7 @@ define( it("mutates an object when performed", function () { action.perform(); expect(capabilities.mutation).toHaveBeenCalled(); - capabilities.mutation.mostRecentCall.args[0]({}); + capabilities.mutation.calls.mostRecent().args[0]({}); }); it("does not muate object upon cancel", function () { diff --git a/platform/commonUI/edit/test/actions/RemoveActionSpec.js b/platform/commonUI/edit/test/actions/RemoveActionSpec.js index 7156ab708a..f9b5089d74 100644 --- a/platform/commonUI/edit/test/actions/RemoveActionSpec.js +++ b/platform/commonUI/edit/test/actions/RemoveActionSpec.js @@ -95,13 +95,13 @@ define( "removeListener" ] ); - mockNavigationService.getNavigation.andReturn(mockDomainObject); + mockNavigationService.getNavigation.and.returnValue(mockDomainObject); - mockDomainObject.getId.andReturn("test"); - mockDomainObject.getCapability.andReturn(mockContext); - mockContext.getParent.andReturn(mockParent); - mockType.hasFeature.andReturn(true); + mockDomainObject.getId.and.returnValue("test"); + mockDomainObject.getCapability.and.returnValue(mockContext); + mockContext.getParent.and.returnValue(mockParent); + mockType.hasFeature.and.returnValue(true); capabilities = { mutation: mockMutation, @@ -119,7 +119,7 @@ define( it("only applies to objects with parents", function () { expect(RemoveAction.appliesTo(actionContext)).toBeTruthy(); - mockContext.getParent.andReturn(undefined); + mockContext.getParent.and.returnValue(undefined); expect(RemoveAction.appliesTo(actionContext)).toBeFalsy(); @@ -136,7 +136,7 @@ define( it("changes composition from its mutation function", function () { var mutator, result; action.perform(); - mutator = mockMutation.invoke.mostRecentCall.args[0]; + mutator = mockMutation.invoke.calls.mostRecent().args[0]; result = mutator(model); // Should not have cancelled the mutation @@ -153,22 +153,22 @@ define( it("removes parent of object currently navigated to", function () { // Navigates to child object - mockNavigationService.getNavigation.andReturn(mockChildObject); + mockNavigationService.getNavigation.and.returnValue(mockChildObject); // Test is id of object being removed // Child object has different id - mockDomainObject.getId.andReturn("test"); - mockChildObject.getId.andReturn("not test"); + mockDomainObject.getId.and.returnValue("test"); + mockChildObject.getId.and.returnValue("not test"); // Sets context for the child and domainObject - mockDomainObject.getCapability.andReturn(mockContext); - mockChildObject.getCapability.andReturn(mockChildContext); + mockDomainObject.getCapability.and.returnValue(mockContext); + mockChildObject.getCapability.and.returnValue(mockChildContext); // Parents of child and domainObject are set - mockContext.getParent.andReturn(mockParent); - mockChildContext.getParent.andReturn(mockDomainObject); + mockContext.getParent.and.returnValue(mockParent); + mockChildContext.getParent.and.returnValue(mockDomainObject); - mockType.hasFeature.andReturn(true); + mockType.hasFeature.and.returnValue(true); action.perform(); @@ -178,25 +178,25 @@ define( it("checks if removing object not in ascendent path (reaches ROOT)", function () { // Navigates to grandchild of ROOT - mockNavigationService.getNavigation.andReturn(mockGrandchildObject); + mockNavigationService.getNavigation.and.returnValue(mockGrandchildObject); // domainObject (grandparent) is set as ROOT, child and grandchild // are set objects not being removed - mockDomainObject.getId.andReturn("test 1"); - mockRootObject.getId.andReturn("ROOT"); - mockChildObject.getId.andReturn("not test 2"); - mockGrandchildObject.getId.andReturn("not test 3"); + mockDomainObject.getId.and.returnValue("test 1"); + mockRootObject.getId.and.returnValue("ROOT"); + mockChildObject.getId.and.returnValue("not test 2"); + mockGrandchildObject.getId.and.returnValue("not test 3"); // Sets context for the grandchild, child, and domainObject - mockRootObject.getCapability.andReturn(mockRootContext); - mockChildObject.getCapability.andReturn(mockChildContext); - mockGrandchildObject.getCapability.andReturn(mockGrandchildContext); + mockRootObject.getCapability.and.returnValue(mockRootContext); + mockChildObject.getCapability.and.returnValue(mockChildContext); + mockGrandchildObject.getCapability.and.returnValue(mockGrandchildContext); // Parents of grandchild and child are set - mockChildContext.getParent.andReturn(mockRootObject); - mockGrandchildContext.getParent.andReturn(mockChildObject); + mockChildContext.getParent.and.returnValue(mockRootObject); + mockGrandchildContext.getParent.and.returnValue(mockChildObject); - mockType.hasFeature.andReturn(true); + mockType.hasFeature.and.returnValue(true); action.perform(); diff --git a/platform/commonUI/edit/test/actions/SaveActionSpec.js b/platform/commonUI/edit/test/actions/SaveActionSpec.js index 9183aff47f..a8b282bd3e 100644 --- a/platform/commonUI/edit/test/actions/SaveActionSpec.js +++ b/platform/commonUI/edit/test/actions/SaveActionSpec.js @@ -19,7 +19,7 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global describe,it,expect,beforeEach,jasmine,waitsFor,runs*/ +/*global describe,it,expect,beforeEach,jasmine*/ define( ["../../src/actions/SaveAction"], @@ -81,13 +81,13 @@ define( ["info", "error"] ); - mockDomainObject.hasCapability.andReturn(true); - mockDomainObject.getCapability.andCallFake(function (capability) { + mockDomainObject.hasCapability.and.returnValue(true); + mockDomainObject.getCapability.and.callFake(function (capability) { return capabilities[capability]; }); - mockDomainObject.getModel.andReturn({persisted: 0}); - mockEditorCapability.save.andReturn(mockPromise(true)); - mockEditorCapability.isEditContextRoot.andReturn(true); + mockDomainObject.getModel.and.returnValue({persisted: 0}); + mockEditorCapability.save.and.returnValue(mockPromise(true)); + mockEditorCapability.isEditContextRoot.and.returnValue(true); action = new SaveAction(mockDialogService, mockNotificationService, actionContext); }); @@ -96,14 +96,14 @@ define( expect(SaveAction.appliesTo(actionContext)).toBe(true); expect(mockDomainObject.hasCapability).toHaveBeenCalledWith("editor"); - mockDomainObject.hasCapability.andReturn(false); - mockDomainObject.getCapability.andReturn(undefined); + mockDomainObject.hasCapability.and.returnValue(false); + mockDomainObject.getCapability.and.returnValue(undefined); expect(SaveAction.appliesTo(actionContext)).toBe(false); }); it("only applies to domain object that has already been persisted", function () { - mockDomainObject.getModel.andReturn({persisted: undefined}); + mockDomainObject.getModel.and.returnValue({persisted: undefined}); expect(SaveAction.appliesTo(actionContext)).toBe(false); }); @@ -118,11 +118,11 @@ define( beforeEach(function () { mockDialogHandle = jasmine.createSpyObj("dialogHandle", ["dismiss"]); - mockDialogService.showBlockingMessage.andReturn(mockDialogHandle); + mockDialogService.showBlockingMessage.and.returnValue(mockDialogHandle); }); it("shows a dialog while saving", function () { - mockEditorCapability.save.andReturn(new Promise(function () { + mockEditorCapability.save.and.returnValue(new Promise(function () { })); action.perform(); expect(mockDialogService.showBlockingMessage).toHaveBeenCalled(); @@ -137,12 +137,8 @@ define( it("notifies if saving succeeded", function () { var mockCallback = jasmine.createSpy("callback"); - mockEditorCapability.save.andReturn(Promise.resolve("success")); - action.perform().then(mockCallback); - waitsFor(function () { - return mockCallback.calls.length > 0; - }); - runs(function () { + mockEditorCapability.save.and.returnValue(Promise.resolve()); + return action.perform().then(mockCallback).then(function () { expect(mockNotificationService.info).toHaveBeenCalled(); expect(mockNotificationService.error).not.toHaveBeenCalled(); }); @@ -150,12 +146,8 @@ define( it("notifies if saving failed", function () { var mockCallback = jasmine.createSpy("callback"); - mockEditorCapability.save.andReturn(Promise.reject("some failure reason")); - action.perform().then(mockCallback); - waitsFor(function () { - return mockCallback.calls.length > 0; - }); - runs(function () { + mockEditorCapability.save.and.returnValue(Promise.reject("some failure reason")); + return action.perform().then(mockCallback).then(function () { expect(mockNotificationService.error).toHaveBeenCalled(); expect(mockNotificationService.info).not.toHaveBeenCalled(); }); diff --git a/platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js b/platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js index 828a5c4565..426ad6827e 100644 --- a/platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js +++ b/platform/commonUI/edit/test/actions/SaveAndStopEditingActionSpec.js @@ -86,13 +86,13 @@ define( ["info", "error"] ); - mockDomainObject.hasCapability.andReturn(true); - mockDomainObject.getCapability.andCallFake(function (capability) { + mockDomainObject.hasCapability.and.returnValue(true); + mockDomainObject.getCapability.and.callFake(function (capability) { return capabilities[capability]; }); - mockDomainObject.getModel.andReturn({ persisted: 0 }); - mockEditorCapability.save.andReturn(mockPromise(true)); - mockEditorCapability.isEditContextRoot.andReturn(true); + mockDomainObject.getModel.and.returnValue({ persisted: 0 }); + mockEditorCapability.save.and.returnValue(mockPromise(true)); + mockEditorCapability.isEditContextRoot.and.returnValue(true); action = new SaveAndStopEditingAction(dialogService, notificationService, actionContext); }); @@ -102,18 +102,18 @@ define( expect(SaveAndStopEditingAction.appliesTo(actionContext)).toBe(true); expect(mockDomainObject.hasCapability).toHaveBeenCalledWith("editor"); - mockDomainObject.hasCapability.andReturn(false); - mockDomainObject.getCapability.andReturn(undefined); + mockDomainObject.hasCapability.and.returnValue(false); + mockDomainObject.getCapability.and.returnValue(undefined); expect(SaveAndStopEditingAction.appliesTo(actionContext)).toBe(false); }); it("only applies to domain object that has already been persisted", function () { - mockDomainObject.getModel.andReturn({ persisted: undefined }); + mockDomainObject.getModel.and.returnValue({ persisted: undefined }); expect(SaveAndStopEditingAction.appliesTo(actionContext)).toBe(false); }); it("does not close the editor before completing the save", function () { - mockEditorCapability.save.andReturn(new Promise(function () { + mockEditorCapability.save.and.returnValue(new Promise(function () { })); action.perform(); expect(mockEditorCapability.save).toHaveBeenCalled(); diff --git a/platform/commonUI/edit/test/actions/SaveAsActionSpec.js b/platform/commonUI/edit/test/actions/SaveAsActionSpec.js index 4eeaba866e..73d391cb83 100644 --- a/platform/commonUI/edit/test/actions/SaveAsActionSpec.js +++ b/platform/commonUI/edit/test/actions/SaveAsActionSpec.js @@ -19,7 +19,7 @@ * this source code distribution or the Licensing information page available * at runtime from the About dialog for additional information. *****************************************************************************/ -/*global describe,it,expect,beforeEach,jasmine,runs,waitsFor,spyOn*/ +/*global describe,it,expect,beforeEach,jasmine,spyOn*/ define( ["../../src/actions/SaveAsAction"], @@ -63,12 +63,12 @@ define( "getId" ] ); - mockDomainObject.hasCapability.andReturn(true); - mockDomainObject.getCapability.andCallFake(function (capability) { + mockDomainObject.hasCapability.and.returnValue(true); + mockDomainObject.getCapability.and.callFake(function (capability) { return capabilities[capability]; }); - mockDomainObject.getModel.andReturn({location: 'a', persisted: undefined}); - mockDomainObject.getId.andReturn(0); + mockDomainObject.getModel.and.returnValue({location: 'a', persisted: undefined}); + mockDomainObject.getId.and.returnValue(0); mockClonedObject = jasmine.createSpyObj( "clonedObject", @@ -76,7 +76,7 @@ define( "getId" ] ); - mockClonedObject.getId.andReturn(1); + mockClonedObject.getId.and.returnValue(1); mockParent = jasmine.createSpyObj( "parentObject", @@ -91,9 +91,9 @@ define( "editor", ["save", "finish", "isEditContextRoot"] ); - mockEditorCapability.save.andReturn(mockPromise(true)); - mockEditorCapability.finish.andReturn(mockPromise(true)); - mockEditorCapability.isEditContextRoot.andReturn(true); + mockEditorCapability.save.and.returnValue(mockPromise(true)); + mockEditorCapability.finish.and.returnValue(mockPromise(true)); + mockEditorCapability.isEditContextRoot.and.returnValue(true); capabilities.editor = mockEditorCapability; mockActionCapability = jasmine.createSpyObj( @@ -106,7 +106,7 @@ define( "objectService", ["getObjects"] ); - mockObjectService.getObjects.andReturn(mockPromise({'a': mockParent})); + mockObjectService.getObjects.and.returnValue(mockPromise({'a': mockParent})); mockDialogService = jasmine.createSpyObj( "dialogService", @@ -115,7 +115,7 @@ define( "showBlockingMessage" ] ); - mockDialogService.getUserInput.andReturn(mockPromise(undefined)); + mockDialogService.getUserInput.and.returnValue(mockPromise(undefined)); mockCopyService = jasmine.createSpyObj( "copyService", @@ -123,7 +123,7 @@ define( "perform" ] ); - mockCopyService.perform.andReturn(mockPromise(mockClonedObject)); + mockCopyService.perform.and.returnValue(mockPromise(mockClonedObject)); mockNotificationService = jasmine.createSpyObj( "notificationService", @@ -146,10 +146,10 @@ define( actionContext); spyOn(action, "getObjectService"); - action.getObjectService.andReturn(mockObjectService); + action.getObjectService.and.returnValue(mockObjectService); spyOn(action, "createWizard"); - action.createWizard.andReturn({ + action.createWizard.and.returnValue({ getFormStructure: noop, getInitialFormValue: noop, populateObjectFromInput: function () { @@ -163,8 +163,8 @@ define( expect(SaveAsAction.appliesTo(actionContext)).toBe(true); expect(mockDomainObject.hasCapability).toHaveBeenCalledWith("editor"); - mockDomainObject.hasCapability.andReturn(false); - mockDomainObject.getCapability.andReturn(undefined); + mockDomainObject.hasCapability.and.returnValue(false); + mockDomainObject.getCapability.and.returnValue(undefined); expect(SaveAsAction.appliesTo(actionContext)).toBe(false); }); @@ -173,35 +173,27 @@ define( expect(SaveAsAction.appliesTo(actionContext)).toBe(true); expect(mockDomainObject.hasCapability).toHaveBeenCalledWith("editor"); - mockDomainObject.getModel.andReturn({persisted: 0}); + mockDomainObject.getModel.and.returnValue({persisted: 0}); expect(SaveAsAction.appliesTo(actionContext)).toBe(false); }); it("uses the editor capability to save the object", function () { - mockEditorCapability.save.andReturn(new Promise(function () {})); - runs(function () { - action.perform(); - }); - waitsFor(function () { - return mockEditorCapability.save.calls.length > 0; - }, "perform() should call EditorCapability.save"); - runs(function () { - expect(mockEditorCapability.finish).not.toHaveBeenCalled(); + mockEditorCapability.save.and.returnValue(Promise.resolve()); + + return action.perform().then(function () { + expect(mockEditorCapability.save).toHaveBeenCalled(); }); }); it("uses the editor capability to finish editing the object", function () { - runs(function () { - action.perform(); + return action.perform().then(function () { + expect(mockEditorCapability.finish.calls.count()).toBeGreaterThan(0); }); - waitsFor(function () { - return mockEditorCapability.finish.calls.length > 0; - }, "perform() should call EditorCapability.finish"); }); it("returns to browse after save", function () { spyOn(action, "save"); - action.save.andReturn(mockPromise(mockDomainObject)); + action.save.and.returnValue(mockPromise(mockDomainObject)); action.perform(); expect(mockActionCapability.perform).toHaveBeenCalledWith( "navigate" @@ -218,48 +210,33 @@ define( beforeEach(function () { mockDialogHandle = jasmine.createSpyObj("dialogHandle", ["dismiss"]); - mockDialogService.showBlockingMessage.andReturn(mockDialogHandle); + mockDialogService.showBlockingMessage.and.returnValue(mockDialogHandle); }); it("shows a blocking dialog indicating that saving is in progress", function () { - mockEditorCapability.save.andReturn(new Promise(function () {})); + mockEditorCapability.save.and.returnValue(new Promise(function () {})); action.perform(); expect(mockDialogService.showBlockingMessage).toHaveBeenCalled(); expect(mockDialogHandle.dismiss).not.toHaveBeenCalled(); }); it("hides the blocking dialog after saving finishes", function () { - var mockCallback = jasmine.createSpy(); - action.perform().then(mockCallback); - expect(mockDialogService.showBlockingMessage).toHaveBeenCalled(); - waitsFor(function () { - return mockCallback.calls.length > 0; - }); - runs(function () { + return action.perform().then(function () { + expect(mockDialogService.showBlockingMessage).toHaveBeenCalled(); expect(mockDialogHandle.dismiss).toHaveBeenCalled(); }); }); it("notifies if saving succeeded", function () { - var mockCallback = jasmine.createSpy(); - action.perform().then(mockCallback); - waitsFor(function () { - return mockCallback.calls.length > 0; - }); - runs(function () { + return action.perform().then(function () { expect(mockNotificationService.info).toHaveBeenCalled(); expect(mockNotificationService.error).not.toHaveBeenCalled(); }); }); it("notifies if saving failed", function () { - mockCopyService.perform.andReturn(Promise.reject("some failure reason")); - var mockCallback = jasmine.createSpy(); - action.perform().then(mockCallback); - waitsFor(function () { - return mockCallback.calls.length > 0; - }); - runs(function () { + mockCopyService.perform.and.returnValue(Promise.reject("some failure reason")); + action.perform().then(function () { expect(mockNotificationService.error).toHaveBeenCalled(); expect(mockNotificationService.info).not.toHaveBeenCalled(); }); diff --git a/platform/commonUI/edit/test/capabilities/EditorCapabilitySpec.js b/platform/commonUI/edit/test/capabilities/EditorCapabilitySpec.js index 63720b6473..b469284121 100644 --- a/platform/commonUI/edit/test/capabilities/EditorCapabilitySpec.js +++ b/platform/commonUI/edit/test/capabilities/EditorCapabilitySpec.js @@ -60,8 +60,8 @@ define( "cancel" ] ); - mockTransactionService.commit.andReturn(fastPromise()); - mockTransactionService.cancel.andReturn(fastPromise()); + mockTransactionService.commit.and.returnValue(fastPromise()); + mockTransactionService.cancel.and.returnValue(fastPromise()); mockTransactionService.isActive = jasmine.createSpy('isActive'); mockStatusCapability = jasmine.createSpyObj( @@ -76,23 +76,23 @@ define( "contextCapability", ["getParent"] ); - mockContextCapability.getParent.andReturn(mockParentObject); + mockContextCapability.getParent.and.returnValue(mockParentObject); capabilities = { context: mockContextCapability, status: mockStatusCapability }; - mockDomainObject.hasCapability.andCallFake(function (name) { + mockDomainObject.hasCapability.and.callFake(function (name) { return capabilities[name] !== undefined; }); - mockDomainObject.getCapability.andCallFake(function (name) { + mockDomainObject.getCapability.and.callFake(function (name) { return capabilities[name]; }); - mockParentObject.getCapability.andReturn(mockParentStatus); - mockParentObject.hasCapability.andReturn(false); + mockParentObject.getCapability.and.returnValue(mockParentStatus); + mockParentObject.hasCapability.and.returnValue(false); capability = new EditorCapability( mockTransactionService, @@ -112,18 +112,18 @@ define( it("uses editing status to determine editing context root", function () { capability.edit(); - mockStatusCapability.get.andReturn(false); + mockStatusCapability.get.and.returnValue(false); expect(capability.isEditContextRoot()).toBe(false); - mockStatusCapability.get.andReturn(true); + mockStatusCapability.get.and.returnValue(true); expect(capability.isEditContextRoot()).toBe(true); }); it("inEditingContext returns true if parent object is being" + " edited", function () { - mockStatusCapability.get.andReturn(false); - mockParentStatus.get.andReturn(false); + mockStatusCapability.get.and.returnValue(false); + mockParentStatus.get.and.returnValue(false); expect(capability.inEditContext()).toBe(false); - mockParentStatus.get.andReturn(true); + mockParentStatus.get.and.returnValue(true); expect(capability.inEditContext()).toBe(true); }); @@ -142,7 +142,7 @@ define( describe("finish", function () { beforeEach(function () { - mockTransactionService.isActive.andReturn(true); + mockTransactionService.isActive.and.returnValue(true); capability.edit(); capability.finish(); }); @@ -156,7 +156,7 @@ define( describe("finish", function () { beforeEach(function () { - mockTransactionService.isActive.andReturn(false); + mockTransactionService.isActive.and.returnValue(false); capability.edit(); }); @@ -175,15 +175,15 @@ define( var model = {}; beforeEach(function () { - mockDomainObject.getModel.andReturn(model); + mockDomainObject.getModel.and.returnValue(model); capability.edit(); capability.finish(); }); it("returns true if the object has been modified since it" + " was last persisted", function () { - mockTransactionService.size.andReturn(0); + mockTransactionService.size.and.returnValue(0); expect(capability.dirty()).toBe(false); - mockTransactionService.size.andReturn(1); + mockTransactionService.size.and.returnValue(1); expect(capability.dirty()).toBe(true); }); }); diff --git a/platform/commonUI/edit/test/capabilities/TransactionCapabilityDecoratorSpec.js b/platform/commonUI/edit/test/capabilities/TransactionCapabilityDecoratorSpec.js index 7e3d4f957f..07bc867e41 100644 --- a/platform/commonUI/edit/test/capabilities/TransactionCapabilityDecoratorSpec.js +++ b/platform/commonUI/edit/test/capabilities/TransactionCapabilityDecoratorSpec.js @@ -37,7 +37,7 @@ define( mockQ = {}; mockTransactionService = {}; mockCapabilityService = jasmine.createSpyObj("capabilityService", ["getCapabilities"]); - mockCapabilityService.getCapabilities.andReturn({ + mockCapabilityService.getCapabilities.and.returnValue({ persistence: function () {} }); diff --git a/platform/commonUI/edit/test/capabilities/TransactionalPersistenceCapabilitySpec.js b/platform/commonUI/edit/test/capabilities/TransactionalPersistenceCapabilitySpec.js index f0da63a8b1..3d038d805d 100644 --- a/platform/commonUI/edit/test/capabilities/TransactionalPersistenceCapabilitySpec.js +++ b/platform/commonUI/edit/test/capabilities/TransactionalPersistenceCapabilitySpec.js @@ -47,7 +47,7 @@ define( testId = "test-id"; mockQ = jasmine.createSpyObj("$q", ["when"]); - mockQ.when.andCallFake(function (val) { + mockQ.when.and.callFake(function (val) { return fastPromise(val); }); mockTransactionManager = jasmine.createSpyObj( @@ -58,15 +58,15 @@ define( "persistenceCapability", ["persist", "refresh", "getSpace"] ); - mockPersistence.persist.andReturn(fastPromise()); - mockPersistence.refresh.andReturn(fastPromise()); + mockPersistence.persist.and.returnValue(fastPromise()); + mockPersistence.refresh.and.returnValue(fastPromise()); mockDomainObject = jasmine.createSpyObj( "domainObject", ["getModel", "getId"] ); - mockDomainObject.getModel.andReturn({persisted: 1}); - mockDomainObject.getId.andReturn(testId); + mockDomainObject.getModel.and.returnValue({persisted: 1}); + mockDomainObject.getId.and.returnValue(testId); capability = new TransactionalPersistenceCapability( mockQ, @@ -78,24 +78,24 @@ define( it("if no transaction is active, passes through to persistence" + " provider", function () { - mockTransactionManager.isActive.andReturn(false); + mockTransactionManager.isActive.and.returnValue(false); capability.persist(); expect(mockPersistence.persist).toHaveBeenCalled(); }); it("if transaction is active, persist and cancel calls are" + " queued", function () { - mockTransactionManager.isActive.andReturn(true); + mockTransactionManager.isActive.and.returnValue(true); capability.persist(); expect(mockTransactionManager.addToTransaction).toHaveBeenCalled(); - mockTransactionManager.addToTransaction.mostRecentCall.args[1](); + mockTransactionManager.addToTransaction.calls.mostRecent().args[1](); expect(mockPersistence.persist).toHaveBeenCalled(); - mockTransactionManager.addToTransaction.mostRecentCall.args[2](); + mockTransactionManager.addToTransaction.calls.mostRecent().args[2](); expect(mockPersistence.refresh).toHaveBeenCalled(); }); it("wraps getSpace", function () { - mockPersistence.getSpace.andReturn('foo'); + mockPersistence.getSpace.and.returnValue('foo'); expect(capability.getSpace()).toEqual('foo'); }); diff --git a/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js b/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js index 4f454d8bf1..12183efdb3 100644 --- a/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js +++ b/platform/commonUI/edit/test/controllers/EditActionControllerSpec.js @@ -38,7 +38,7 @@ define( jasmine.createSpyObj("mockSaveAction", ["getMetadata", "perform"]) ]; mockedSaveActions.forEach(function (action) { - action.getMetadata.andReturn(mockSaveActionMetadata); + action.getMetadata.and.returnValue(mockSaveActionMetadata); }); return mockedSaveActions; } else if (actionContext.category === "conclude-editing") { @@ -54,14 +54,14 @@ define( beforeEach(function () { mockActions = jasmine.createSpyObj("action", ["getActions"]); - mockActions.getActions.andCallFake(fakeGetActions); + mockActions.getActions.and.callFake(fakeGetActions); mockScope = jasmine.createSpyObj("$scope", ["$watch"]); mockScope.action = mockActions; controller = new EditActionController(mockScope); }); function makeControllerUpdateActions() { - mockScope.$watch.mostRecentCall.args[1](); + mockScope.$watch.calls.mostRecent().args[1](); } it("watches scope that may change applicable actions", function () { diff --git a/platform/commonUI/edit/test/controllers/EditObjectControllerSpec.js b/platform/commonUI/edit/test/controllers/EditObjectControllerSpec.js index 4ad82456f8..d3dd66459d 100644 --- a/platform/commonUI/edit/test/controllers/EditObjectControllerSpec.js +++ b/platform/commonUI/edit/test/controllers/EditObjectControllerSpec.js @@ -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(); diff --git a/platform/commonUI/edit/test/controllers/EditPanesControllerSpec.js b/platform/commonUI/edit/test/controllers/EditPanesControllerSpec.js index 98f0c7d02c..abb02df272 100644 --- a/platform/commonUI/edit/test/controllers/EditPanesControllerSpec.js +++ b/platform/commonUI/edit/test/controllers/EditPanesControllerSpec.js @@ -41,13 +41,13 @@ define( ['getTrueRoot'] ); - mockDomainObject.getId.andReturn('test-id'); - mockDomainObject.getCapability.andReturn(mockContext); + mockDomainObject.getId.and.returnValue('test-id'); + mockDomainObject.getCapability.and.returnValue(mockContext); // Return a new instance of the root object each time - mockContext.getTrueRoot.andCallFake(function () { + mockContext.getTrueRoot.and.callFake(function () { var mockRoot = jasmine.createSpyObj('root', ['getId']); - mockRoot.getId.andReturn('root-id'); + mockRoot.getId.and.returnValue('root-id'); return mockRoot; }); @@ -63,7 +63,7 @@ define( }); it("exposes the root object found via the object's context capability", function () { - mockScope.$watch.mostRecentCall.args[1](mockDomainObject); + mockScope.$watch.calls.mostRecent().args[1](mockDomainObject); // Verify that the correct capability was used expect(mockDomainObject.getCapability) @@ -76,10 +76,10 @@ define( it("preserves the same root instance to avoid excessive refreshing", function () { var firstRoot; // Expose the domain object - mockScope.$watch.mostRecentCall.args[1](mockDomainObject); + mockScope.$watch.calls.mostRecent().args[1](mockDomainObject); firstRoot = controller.getRoot(); // Update! - mockScope.$watch.mostRecentCall.args[1](mockDomainObject); + mockScope.$watch.calls.mostRecent().args[1](mockDomainObject); // Should still have the same object instance, to avoid // triggering the watch used by the template we're supporting expect(controller.getRoot()).toBe(firstRoot); @@ -90,18 +90,18 @@ define( it("updates the root when it changes", function () { var firstRoot; // Expose the domain object - mockScope.$watch.mostRecentCall.args[1](mockDomainObject); + mockScope.$watch.calls.mostRecent().args[1](mockDomainObject); firstRoot = controller.getRoot(); // Change the exposed root - mockContext.getTrueRoot.andCallFake(function () { + mockContext.getTrueRoot.and.callFake(function () { var mockRoot = jasmine.createSpyObj('root', ['getId']); - mockRoot.getId.andReturn('other-root-id'); + mockRoot.getId.and.returnValue('other-root-id'); return mockRoot; }); // Update! - mockScope.$watch.mostRecentCall.args[1](mockDomainObject); + mockScope.$watch.calls.mostRecent().args[1](mockDomainObject); // Should still have the same object instance, to avoid // triggering the watch used by the template we're supporting diff --git a/platform/commonUI/edit/test/controllers/ElementsControllerSpec.js b/platform/commonUI/edit/test/controllers/ElementsControllerSpec.js index 2dd8dba2bb..9a46941080 100644 --- a/platform/commonUI/edit/test/controllers/ElementsControllerSpec.js +++ b/platform/commonUI/edit/test/controllers/ElementsControllerSpec.js @@ -63,13 +63,13 @@ define( mockMutationCapability = jasmine.createSpyObj("mutationCapability", [ "listen" ]); - mockMutationCapability.listen.andReturn(mockUnlisten); + mockMutationCapability.listen.and.returnValue(mockUnlisten); mockDomainObject = jasmine.createSpyObj("domainObject", [ "getCapability", "useCapability" ]); - mockDomainObject.useCapability.andReturn(mockCompositionCapability); - mockDomainObject.getCapability.andReturn(mockMutationCapability); + mockDomainObject.useCapability.and.returnValue(mockCompositionCapability); + mockDomainObject.getCapability.and.returnValue(mockMutationCapability); mockScope = jasmine.createSpyObj("$scope", ['$on']); mockSelection = jasmine.createSpyObj("selection", [ @@ -77,7 +77,7 @@ define( 'off', 'get' ]); - mockSelection.get.andReturn([]); + mockSelection.get.and.returnValue([]); mockOpenMCT = { selection: mockSelection }; @@ -88,7 +88,7 @@ define( } }; - spyOn(ElementsController.prototype, 'refreshComposition').andCallThrough(); + spyOn(ElementsController.prototype, 'refreshComposition').and.callThrough(); controller = new ElementsController(mockScope, mockOpenMCT); }); @@ -123,29 +123,29 @@ define( }); it("refreshes composition on selection", function () { - mockOpenMCT.selection.on.mostRecentCall.args[1](selectable); + mockOpenMCT.selection.on.calls.mostRecent().args[1](selectable); expect(ElementsController.prototype.refreshComposition).toHaveBeenCalledWith(mockDomainObject); }); it("listens on mutation and refreshes composition", function () { - mockOpenMCT.selection.on.mostRecentCall.args[1](selectable); + mockOpenMCT.selection.on.calls.mostRecent().args[1](selectable); expect(mockDomainObject.getCapability).toHaveBeenCalledWith('mutation'); expect(mockMutationCapability.listen).toHaveBeenCalled(); - expect(ElementsController.prototype.refreshComposition.calls.length).toBe(1); + expect(ElementsController.prototype.refreshComposition.calls.count()).toBe(1); - mockMutationCapability.listen.mostRecentCall.args[0](mockDomainObject); + mockMutationCapability.listen.calls.mostRecent().args[0](mockDomainObject); - expect(ElementsController.prototype.refreshComposition.calls.length).toBe(2); + expect(ElementsController.prototype.refreshComposition.calls.count()).toBe(2); }); it("cleans up mutation listener when selection changes", function () { - mockOpenMCT.selection.on.mostRecentCall.args[1](selectable); + mockOpenMCT.selection.on.calls.mostRecent().args[1](selectable); expect(mockMutationCapability.listen).toHaveBeenCalled(); - mockOpenMCT.selection.on.mostRecentCall.args[1](selectable); + mockOpenMCT.selection.on.calls.mostRecent().args[1](selectable); expect(mockUnlisten).toHaveBeenCalled(); }); @@ -156,7 +156,7 @@ define( elementProxy: {} } }; - mockOpenMCT.selection.on.mostRecentCall.args[1](selectable); + mockOpenMCT.selection.on.calls.mostRecent().args[1](selectable); expect(mockDomainObject.getCapability).not.toHaveBeenCalledWith('mutation'); }); @@ -167,13 +167,13 @@ define( firstCompositionCallback, secondCompositionCallback; - spyOn(mockCompositionCapability, "then").andCallThrough(); + spyOn(mockCompositionCapability, "then").and.callThrough(); controller.refreshComposition(mockDomainObject); controller.refreshComposition(mockDomainObject); - firstCompositionCallback = mockCompositionCapability.then.calls[0].args[0]; - secondCompositionCallback = mockCompositionCapability.then.calls[1].args[0]; + firstCompositionCallback = mockCompositionCapability.then.calls.all()[0].args[0]; + secondCompositionCallback = mockCompositionCapability.then.calls.all()[1].args[0]; secondCompositionCallback(secondMockCompositionObjects); firstCompositionCallback(mockCompositionObjects); diff --git a/platform/commonUI/edit/test/creation/AddActionProviderSpec.js b/platform/commonUI/edit/test/creation/AddActionProviderSpec.js index 5ecf8442e9..6d410919d5 100644 --- a/platform/commonUI/edit/test/creation/AddActionProviderSpec.js +++ b/platform/commonUI/edit/test/creation/AddActionProviderSpec.js @@ -51,9 +51,9 @@ define( "hasFeature" ] ); - mockType.hasFeature.andReturn(true); - mockType.getName.andReturn(name); - mockType.getKey.andReturn(name); + mockType.hasFeature.and.returnValue(true); + mockType.getName.and.returnValue(name); + mockType.getKey.and.returnValue(name); return mockType; } @@ -77,7 +77,7 @@ define( mockTypeMap[type.getKey()] = type; }); - mockTypeService.getType.andCallFake(function (key) { + mockTypeService.getType.and.callFake(function (key) { return mockTypeMap[key]; }); diff --git a/platform/commonUI/edit/test/creation/CreateActionProviderSpec.js b/platform/commonUI/edit/test/creation/CreateActionProviderSpec.js index d558732ab6..bc97c73a24 100644 --- a/platform/commonUI/edit/test/creation/CreateActionProviderSpec.js +++ b/platform/commonUI/edit/test/creation/CreateActionProviderSpec.js @@ -49,8 +49,8 @@ define( "hasFeature" ] ); - mockType.hasFeature.andReturn(true); - mockType.getName.andReturn(name); + mockType.hasFeature.and.returnValue(true); + mockType.getName.and.returnValue(name); return mockType; } @@ -74,11 +74,11 @@ define( return mockPolicyMap[type.getName()]; }; - mockPolicyService.allow.andCallFake(function (category, type) { + mockPolicyService.allow.and.callFake(function (category, type) { return category === "creation" && mockCreationPolicy(type) ? true : false; }); - mockTypeService.listTypes.andReturn(mockTypes); + mockTypeService.listTypes.and.returnValue(mockTypes); provider = new CreateActionProvider( mockTypeService, diff --git a/platform/commonUI/edit/test/creation/CreateActionSpec.js b/platform/commonUI/edit/test/creation/CreateActionSpec.js index 0070f686dc..267258dc1d 100644 --- a/platform/commonUI/edit/test/creation/CreateActionSpec.js +++ b/platform/commonUI/edit/test/creation/CreateActionSpec.js @@ -77,10 +77,10 @@ define( "useCapability" ] ); - mockDomainObject.hasCapability.andCallFake(function (name) { + mockDomainObject.hasCapability.and.callFake(function (name) { return !!capabilities[name]; }); - mockDomainObject.getCapability.andCallFake(function (name) { + mockDomainObject.getCapability.and.callFake(function (name) { return capabilities[name]; }); mockSaveAction = jasmine.createSpyObj( @@ -117,14 +117,14 @@ define( mockContext = { domainObject: mockParent }; - mockParent.useCapability.andReturn(mockDomainObject); + mockParent.useCapability.and.returnValue(mockDomainObject); - mockType.getKey.andReturn("test"); - mockType.getCssClass.andReturn("icon-telemetry"); - mockType.getDescription.andReturn("a test type"); - mockType.getName.andReturn("Test"); - mockType.getProperties.andReturn([]); - mockType.getInitialModel.andReturn({}); + mockType.getKey.and.returnValue("test"); + mockType.getCssClass.and.returnValue("icon-telemetry"); + mockType.getDescription.and.returnValue("a test type"); + mockType.getName.and.returnValue("Test"); + mockType.getProperties.and.returnValue([]); + mockType.getInitialModel.and.returnValue({}); action = new CreateAction( mockType, @@ -144,7 +144,7 @@ define( describe("the perform function", function () { var promise = jasmine.createSpyObj("promise", ["then"]); beforeEach(function () { - capabilities.action.getActions.andReturn([mockEditAction]); + capabilities.action.getActions.and.returnValue([mockEditAction]); }); it("uses the instantiation capability when performed", function () { @@ -159,30 +159,30 @@ define( it("uses the save-as action if object does not have an edit action" + " available", function () { - capabilities.action.getActions.andReturn([]); - capabilities.action.perform.andReturn(mockPromise(undefined)); - capabilities.editor.save.andReturn(promise); + capabilities.action.getActions.and.returnValue([]); + capabilities.action.perform.and.returnValue(mockPromise(undefined)); + capabilities.editor.save.and.returnValue(promise); action.perform(); expect(capabilities.action.perform).toHaveBeenCalledWith("save-as"); }); describe("uses to editor capability", function () { beforeEach(function () { - capabilities.action.getActions.andReturn([]); - capabilities.action.perform.andReturn(promise); - capabilities.editor.save.andReturn(promise); + capabilities.action.getActions.and.returnValue([]); + capabilities.action.perform.and.returnValue(promise); + capabilities.editor.save.and.returnValue(promise); }); it("to save the edit if user saves dialog", function () { action.perform(); expect(promise.then).toHaveBeenCalled(); - promise.then.mostRecentCall.args[0](); + promise.then.calls.mostRecent().args[0](); expect(capabilities.editor.save).toHaveBeenCalled(); }); it("to finish the edit if user cancels dialog", function () { action.perform(); - promise.then.mostRecentCall.args[1](); + promise.then.calls.mostRecent().args[1](); expect(capabilities.editor.finish).toHaveBeenCalled(); }); }); diff --git a/platform/commonUI/edit/test/creation/CreateMenuControllerSpec.js b/platform/commonUI/edit/test/creation/CreateMenuControllerSpec.js index 978a87f8de..de09b0ac35 100644 --- a/platform/commonUI/edit/test/creation/CreateMenuControllerSpec.js +++ b/platform/commonUI/edit/test/creation/CreateMenuControllerSpec.js @@ -49,10 +49,10 @@ define( it("populates the scope with create actions", function () { mockScope.action = mockActions; - mockActions.getActions.andReturn(["a", "b", "c"]); + mockActions.getActions.and.returnValue(["a", "b", "c"]); // Call the watch - mockScope.$watch.mostRecentCall.args[1](); + mockScope.$watch.calls.mostRecent().args[1](); // Should have grouped and ungrouped actions in scope now expect(mockScope.createActions.length).toEqual(3); diff --git a/platform/commonUI/edit/test/creation/CreateWizardSpec.js b/platform/commonUI/edit/test/creation/CreateWizardSpec.js index ee0fa04a51..fd424e0471 100644 --- a/platform/commonUI/edit/test/creation/CreateWizardSpec.js +++ b/platform/commonUI/edit/test/creation/CreateWizardSpec.js @@ -41,10 +41,10 @@ define( "property" + name, ["getDefinition", "getValue", "setValue"] ); - mockProperty.getDefinition.andReturn({ + mockProperty.getDefinition.and.returnValue({ control: "textfield" }); - mockProperty.getValue.andReturn(name); + mockProperty.getValue.and.returnValue(name); return mockProperty; } @@ -74,12 +74,12 @@ define( testModel = { someKey: "some value" }; - mockType.getKey.andReturn("test"); - mockType.getCssClass.andReturn("icon-telemetry"); - mockType.getDescription.andReturn("a test type"); - mockType.getName.andReturn("Test"); - mockType.getInitialModel.andReturn(testModel); - mockType.getProperties.andReturn(mockProperties); + mockType.getKey.and.returnValue("test"); + mockType.getCssClass.and.returnValue("icon-telemetry"); + mockType.getDescription.and.returnValue("a test type"); + mockType.getName.and.returnValue("Test"); + mockType.getInitialModel.and.returnValue(testModel); + mockType.getProperties.and.returnValue(mockProperties); mockDomainObject = jasmine.createSpyObj( 'domainObject', @@ -87,9 +87,9 @@ define( ); //Mocking the getCapability('type') call - mockDomainObject.getCapability.andReturn(mockType); - mockDomainObject.useCapability.andReturn(); - mockDomainObject.getModel.andReturn(testModel); + mockDomainObject.getCapability.and.returnValue(mockType); + mockDomainObject.useCapability.and.returnValue(); + mockDomainObject.getModel.and.returnValue(testModel); wizard = new CreateWizard( mockDomainObject, @@ -147,9 +147,11 @@ define( "C": "ValueC" }, compareModel = wizard.createModel(formValue); + //populateObjectFromInput adds a .location attribute that is not added by createModel. + compareModel.location = undefined; wizard.populateObjectFromInput(formValue); expect(mockDomainObject.useCapability).toHaveBeenCalledWith('mutation', jasmine.any(Function)); - expect(mockDomainObject.useCapability.mostRecentCall.args[1]()).toEqual(compareModel); + expect(mockDomainObject.useCapability.calls.mostRecent().args[1]()).toEqual(compareModel); }); it("validates selection types using policy", function () { @@ -168,7 +170,7 @@ define( rows = structure.sections[sections.length - 1].rows, locationRow = rows[rows.length - 1]; - mockDomainObj.getCapability.andReturn(mockOtherType); + mockDomainObj.getCapability.and.returnValue(mockOtherType); locationRow.validate(mockDomainObj); // Should check policy to see if the user-selected location diff --git a/platform/commonUI/edit/test/creation/CreationPolicySpec.js b/platform/commonUI/edit/test/creation/CreationPolicySpec.js index 11ff40f170..a76d89179a 100644 --- a/platform/commonUI/edit/test/creation/CreationPolicySpec.js +++ b/platform/commonUI/edit/test/creation/CreationPolicySpec.js @@ -38,12 +38,12 @@ define( }); it("allows creation of types with the creation feature", function () { - mockType.hasFeature.andReturn(true); + mockType.hasFeature.and.returnValue(true); expect(policy.allow(mockType)).toBeTruthy(); }); it("disallows creation of types without the creation feature", function () { - mockType.hasFeature.andReturn(false); + mockType.hasFeature.and.returnValue(false); expect(policy.allow(mockType)).toBeFalsy(); }); }); diff --git a/platform/commonUI/edit/test/creation/CreationServiceSpec.js b/platform/commonUI/edit/test/creation/CreationServiceSpec.js index 5757f31d1e..3f0139230e 100644 --- a/platform/commonUI/edit/test/creation/CreationServiceSpec.js +++ b/platform/commonUI/edit/test/creation/CreationServiceSpec.js @@ -103,33 +103,33 @@ define( ["persist", "getSpace"] ); - mockParentObject.getCapability.andCallFake(function (key) { + mockParentObject.getCapability.and.callFake(function (key) { return mockCapabilities[key]; }); - mockParentObject.useCapability.andCallFake(function (key, value) { + mockParentObject.useCapability.and.callFake(function (key, value) { return mockCapabilities[key].invoke(value); }); - mockParentObject.getId.andReturn('parentId'); + mockParentObject.getId.and.returnValue('parentId'); - mockNewObject.getId.andReturn('newId'); - mockNewObject.getCapability.andCallFake(function (c) { + mockNewObject.getId.and.returnValue('newId'); + mockNewObject.getCapability.and.callFake(function (c) { return c === 'persistence' ? mockNewPersistenceCapability : undefined; }); mockPersistenceCapability.persist - .andReturn(mockPromise(true)); + .and.returnValue(mockPromise(true)); mockNewPersistenceCapability.persist - .andReturn(mockPromise(true)); + .and.returnValue(mockPromise(true)); - mockMutationCapability.invoke.andReturn(mockPromise(true)); - mockPersistenceCapability.getSpace.andReturn("testSpace"); - mockCompositionCapability.invoke.andReturn( + mockMutationCapability.invoke.and.returnValue(mockPromise(true)); + mockPersistenceCapability.getSpace.and.returnValue("testSpace"); + mockCompositionCapability.invoke.and.returnValue( mockPromise([mockNewObject]) ); - mockCompositionCapability.add.andReturn(mockPromise(true)); - mockCreationCapability.instantiate.andReturn(mockNewObject); - mockCreationCapability.invoke.andCallFake(function (model) { + mockCompositionCapability.add.and.returnValue(mockPromise(true)); + mockCreationCapability.instantiate.and.returnValue(mockNewObject); + mockCreationCapability.invoke.and.callFake(function (model) { return mockCreationCapability.instantiate(model); }); @@ -163,10 +163,10 @@ define( mockCallback = jasmine.createSpy('callback'); // Act as if the object had been created - mockCompositionCapability.add.andCallFake(function (id) { - mockDomainObject.getId.andReturn(id); + mockCompositionCapability.add.and.callFake(function (id) { + mockDomainObject.getId.and.returnValue(id); mockCompositionCapability.invoke - .andReturn(mockPromise([mockDomainObject])); + .and.returnValue(mockPromise([mockDomainObject])); return mockPromise(mockDomainObject); }); @@ -200,7 +200,7 @@ define( // created object - this is an error. var model = { someKey: "some value" }; - mockCompositionCapability.add.andReturn(mockPromise(false)); + mockCompositionCapability.add.and.returnValue(mockPromise(false)); creationService.createObject(model, mockParentObject); diff --git a/platform/commonUI/edit/test/creation/LocatorControllerSpec.js b/platform/commonUI/edit/test/creation/LocatorControllerSpec.js index a960242382..5024323783 100644 --- a/platform/commonUI/edit/test/creation/LocatorControllerSpec.js +++ b/platform/commonUI/edit/test/creation/LocatorControllerSpec.js @@ -64,9 +64,9 @@ define( ["then"] ); - mockDomainObject.getCapability.andReturn(mockContext); - mockContext.getRoot.andReturn(mockRootObject); - mockObjectService.getObjects.andReturn(getObjectsPromise); + mockDomainObject.getCapability.and.returnValue(mockContext); + mockContext.getRoot.and.returnValue(mockRootObject); + mockObjectService.getObjects.and.returnValue(getObjectsPromise); mockScope.ngModel = {}; mockScope.field = "someField"; @@ -76,7 +76,7 @@ define( describe("when context is available", function () { beforeEach(function () { - mockContext.getRoot.andReturn(mockRootObject); + mockContext.getRoot.and.returnValue(mockRootObject); controller = new LocatorController(mockScope, mockTimeout, mockObjectService); }); @@ -96,8 +96,8 @@ define( it("changes its own model on embedded model updates", function () { // Need to pass on selection changes as updates to // the control's value - mockScope.$watch.mostRecentCall.args[1](mockDomainObject); - mockTimeout.mostRecentCall.args[0](); + mockScope.$watch.calls.mostRecent().args[1](mockDomainObject); + mockTimeout.calls.mostRecent().args[0](); expect(mockScope.ngModel.someField).toEqual(mockDomainObject); expect(mockScope.rootObject).toEqual(mockRootObject); @@ -109,11 +109,11 @@ define( it("rejects changes which fail validation", function () { mockScope.structure = { validate: jasmine.createSpy('validate') }; - mockScope.structure.validate.andReturn(false); + mockScope.structure.validate.and.returnValue(false); // Pass selection change - mockScope.$watch.mostRecentCall.args[1](mockDomainObject); - mockTimeout.mostRecentCall.args[0](); + mockScope.$watch.calls.mostRecent().args[1](mockDomainObject); + mockTimeout.calls.mostRecent().args[0](); expect(mockScope.structure.validate).toHaveBeenCalled(); // Change should have been rejected @@ -126,13 +126,13 @@ define( ['$setValidity'] ); - mockScope.$watch.mostRecentCall.args[1](mockDomainObject); - mockTimeout.mostRecentCall.args[0](); + mockScope.$watch.calls.mostRecent().args[1](mockDomainObject); + mockTimeout.calls.mostRecent().args[0](); expect(mockScope.ngModelController.$setValidity) .toHaveBeenCalledWith(jasmine.any(String), true); - mockScope.$watch.mostRecentCall.args[1](undefined); - mockTimeout.mostRecentCall.args[0](); + mockScope.$watch.calls.mostRecent().args[1](undefined); + mockTimeout.calls.mostRecent().args[0](); expect(mockScope.ngModelController.$setValidity) .toHaveBeenCalledWith(jasmine.any(String), false); }); @@ -141,27 +141,27 @@ define( var defaultRoot = "DEFAULT_ROOT"; beforeEach(function () { - mockContext.getRoot.andReturn(undefined); - getObjectsPromise.then.andCallFake(function (callback) { + mockContext.getRoot.and.returnValue(undefined); + getObjectsPromise.then.and.callFake(function (callback) { callback({'ROOT': defaultRoot}); }); controller = new LocatorController(mockScope, mockTimeout, mockObjectService); }); it("provides a default context where none is available", function () { - mockScope.$watch.mostRecentCall.args[1](mockDomainObject); - mockTimeout.mostRecentCall.args[0](); + mockScope.$watch.calls.mostRecent().args[1](mockDomainObject); + mockTimeout.calls.mostRecent().args[0](); expect(mockScope.rootObject).toBe(defaultRoot); }); it("does not issue redundant requests for the root object", function () { - mockScope.$watch.mostRecentCall.args[1](mockDomainObject); - mockTimeout.mostRecentCall.args[0](); - mockScope.$watch.mostRecentCall.args[1](undefined); - mockTimeout.mostRecentCall.args[0](); - mockScope.$watch.mostRecentCall.args[1](mockDomainObject); - mockTimeout.mostRecentCall.args[0](); - expect(mockObjectService.getObjects.calls.length) + mockScope.$watch.calls.mostRecent().args[1](mockDomainObject); + mockTimeout.calls.mostRecent().args[0](); + mockScope.$watch.calls.mostRecent().args[1](undefined); + mockTimeout.calls.mostRecent().args[0](); + mockScope.$watch.calls.mostRecent().args[1](mockDomainObject); + mockTimeout.calls.mostRecent().args[0](); + expect(mockObjectService.getObjects.calls.count()) .toEqual(1); }); diff --git a/platform/commonUI/edit/test/policies/EditActionPolicySpec.js b/platform/commonUI/edit/test/policies/EditActionPolicySpec.js index 9cfbc1e690..2b9174488f 100644 --- a/platform/commonUI/edit/test/policies/EditActionPolicySpec.js +++ b/platform/commonUI/edit/test/policies/EditActionPolicySpec.js @@ -58,10 +58,10 @@ define( mockEditAction = jasmine.createSpyObj('edit', ['getMetadata']); mockPropertiesAction = jasmine.createSpyObj('edit', ['getMetadata']); - mockDomainObject.getCapability.andCallFake(function (capability) { + mockDomainObject.getCapability.and.callFake(function (capability) { return capabilities[capability]; }); - mockDomainObject.hasCapability.andCallFake(function (capability) { + mockDomainObject.hasCapability.and.callFake(function (capability) { return !!capabilities[capability]; }); @@ -71,13 +71,13 @@ define( plotView = { key: "plot", editable: false }; testViews = []; - mockDomainObject.useCapability.andCallFake(function (c) { + mockDomainObject.useCapability.and.callFake(function (c) { // Provide test views, only for the view capability return c === 'view' && testViews; }); - mockEditAction.getMetadata.andReturn({ key: 'edit' }); - mockPropertiesAction.getMetadata.andReturn({ key: 'properties' }); + mockEditAction.getMetadata.and.returnValue({ key: 'edit' }); + mockPropertiesAction.getMetadata.and.returnValue({ key: 'properties' }); testContext = { domainObject: mockDomainObject, @@ -111,20 +111,20 @@ define( it("disallows the edit action when object is already being" + " edited", function () { testViews = [editableView]; - mockEditorCapability.isEditContextRoot.andReturn(true); + mockEditorCapability.isEditContextRoot.and.returnValue(true); expect(policy.allow(mockEditAction, testContext)).toBe(false); }); it("allows editing of panels in plot view", function () { testViews = [plotView]; - mockTypeCapability.getKey.andReturn('telemetry.panel'); + mockTypeCapability.getKey.and.returnValue('telemetry.panel'); expect(policy.allow(mockEditAction, testContext)).toBe(true); }); it("disallows editing of plot view when object not a panel type", function () { testViews = [plotView]; - mockTypeCapability.getKey.andReturn('something.else'); + mockTypeCapability.getKey.and.returnValue('something.else'); expect(policy.allow(mockEditAction, testContext)).toBe(false); }); diff --git a/platform/commonUI/edit/test/policies/EditContextualActionPolicySpec.js b/platform/commonUI/edit/test/policies/EditContextualActionPolicySpec.js index 4c832d4130..f197abb7b9 100644 --- a/platform/commonUI/edit/test/policies/EditContextualActionPolicySpec.js +++ b/platform/commonUI/edit/test/policies/EditContextualActionPolicySpec.js @@ -41,20 +41,20 @@ define( mockEditorCapability = jasmine.createSpyObj("editorCapability", ["isEditContextRoot", "inEditContext"]); navigatedObject = jasmine.createSpyObj("navigatedObject", ["hasCapability", "getCapability"]); - navigatedObject.getCapability.andReturn(mockEditorCapability); - navigatedObject.hasCapability.andReturn(false); + navigatedObject.getCapability.and.returnValue(mockEditorCapability); + navigatedObject.hasCapability.and.returnValue(false); mockDomainObject = jasmine.createSpyObj("domainObject", ["hasCapability", "getCapability"]); - mockDomainObject.hasCapability.andReturn(false); - mockDomainObject.getCapability.andReturn(mockEditorCapability); + mockDomainObject.hasCapability.and.returnValue(false); + mockDomainObject.getCapability.and.returnValue(mockEditorCapability); navigationService = jasmine.createSpyObj("navigationService", ["getNavigation"]); - navigationService.getNavigation.andReturn(navigatedObject); + navigationService.getNavigation.and.returnValue(navigatedObject); metadata = {key: "move"}; mockAction = jasmine.createSpyObj("action", ["getMetadata"]); - mockAction.getMetadata.andReturn(metadata); + mockAction.getMetadata.and.returnValue(metadata); context = {domainObject: mockDomainObject}; @@ -67,8 +67,8 @@ define( it('Allows "window" action when navigated object in edit mode,' + ' but selected object not in edit mode ', function () { - navigatedObject.hasCapability.andReturn(true); - mockEditorCapability.isEditContextRoot.andReturn(true); + navigatedObject.hasCapability.and.returnValue(true); + mockEditorCapability.isEditContextRoot.and.returnValue(true); metadata.key = "window"; expect(policy.allow(mockAction, context)).toBe(true); }); @@ -79,12 +79,12 @@ define( var mockParent = jasmine.createSpyObj("parentObject", ["hasCapability"]), mockContextCapability = jasmine.createSpyObj("contextCapability", ["getParent"]); - mockParent.hasCapability.andReturn(true); - mockContextCapability.getParent.andReturn(mockParent); - navigatedObject.hasCapability.andReturn(true); + mockParent.hasCapability.and.returnValue(true); + mockContextCapability.getParent.and.returnValue(mockParent); + navigatedObject.hasCapability.and.returnValue(true); - mockDomainObject.getCapability.andReturn(mockContextCapability); - mockDomainObject.hasCapability.andCallFake(function (capability) { + mockDomainObject.getCapability.and.returnValue(mockContextCapability); + mockDomainObject.hasCapability.and.callFake(function (capability) { switch (capability) { case "editor": return false; case "context": return true; @@ -97,19 +97,19 @@ define( it('Disallows "move" action when navigated object in edit mode,' + ' but selected object not in edit mode ', function () { - navigatedObject.hasCapability.andReturn(true); - mockEditorCapability.isEditContextRoot.andReturn(true); - mockEditorCapability.inEditContext.andReturn(false); + navigatedObject.hasCapability.and.returnValue(true); + mockEditorCapability.isEditContextRoot.and.returnValue(true); + mockEditorCapability.inEditContext.and.returnValue(false); metadata.key = "move"; expect(policy.allow(mockAction, context)).toBe(false); }); it('Disallows copy action when navigated object and' + ' selected object in edit mode', function () { - navigatedObject.hasCapability.andReturn(true); - mockDomainObject.hasCapability.andReturn(true); - mockEditorCapability.isEditContextRoot.andReturn(true); - mockEditorCapability.inEditContext.andReturn(true); + navigatedObject.hasCapability.and.returnValue(true); + mockDomainObject.hasCapability.and.returnValue(true); + mockEditorCapability.isEditContextRoot.and.returnValue(true); + mockEditorCapability.inEditContext.and.returnValue(true); metadata.key = "copy"; expect(policy.allow(mockAction, context)).toBe(false); diff --git a/platform/commonUI/edit/test/policies/EditPersistableObjectsSpec.js b/platform/commonUI/edit/test/policies/EditPersistableObjectsSpec.js index 4615582176..ed9c61bf1d 100644 --- a/platform/commonUI/edit/test/policies/EditPersistableObjectsSpec.js +++ b/platform/commonUI/edit/test/policies/EditPersistableObjectsSpec.js @@ -54,11 +54,11 @@ define( mockPropertiesAction = jasmine.createSpyObj('properties', ['getMetadata']); mockOtherAction = jasmine.createSpyObj('other', ['getMetadata']); - mockEditAction.getMetadata.andReturn({ key: 'edit' }); - mockPropertiesAction.getMetadata.andReturn({ key: 'properties' }); - mockOtherAction.getMetadata.andReturn({key: 'other'}); + mockEditAction.getMetadata.and.returnValue({ key: 'edit' }); + mockPropertiesAction.getMetadata.and.returnValue({ key: 'properties' }); + mockOtherAction.getMetadata.and.returnValue({key: 'other'}); - mockDomainObject.getId.andReturn('test:testId'); + mockDomainObject.getId.and.returnValue('test:testId'); testContext = { domainObject: mockDomainObject, @@ -69,7 +69,7 @@ define( }); it("Applies to edit action", function () { - mockObjectAPI.getProvider.andReturn({}); + mockObjectAPI.getProvider.and.returnValue({}); expect(mockObjectAPI.getProvider).not.toHaveBeenCalled(); policy.allow(mockEditAction, testContext); @@ -77,7 +77,7 @@ define( }); it("Applies to properties action", function () { - mockObjectAPI.getProvider.andReturn({}); + mockObjectAPI.getProvider.and.returnValue({}); expect(mockObjectAPI.getProvider).not.toHaveBeenCalled(); policy.allow(mockPropertiesAction, testContext); @@ -85,7 +85,7 @@ define( }); it("does not apply to other actions", function () { - mockObjectAPI.getProvider.andReturn({}); + mockObjectAPI.getProvider.and.returnValue({}); expect(mockObjectAPI.getProvider).not.toHaveBeenCalled(); policy.allow(mockOtherAction, testContext); @@ -93,10 +93,10 @@ define( }); it("Tests object provider for editability", function () { - mockObjectAPI.getProvider.andReturn({}); + mockObjectAPI.getProvider.and.returnValue({}); expect(policy.allow(mockEditAction, testContext)).toBe(false); expect(mockObjectAPI.getProvider).toHaveBeenCalled(); - mockObjectAPI.getProvider.andReturn({save: function () {}}); + mockObjectAPI.getProvider.and.returnValue({save: function () {}}); expect(policy.allow(mockEditAction, testContext)).toBe(true); }); }); diff --git a/platform/commonUI/edit/test/policies/EditableViewPolicySpec.js b/platform/commonUI/edit/test/policies/EditableViewPolicySpec.js index b964cd3339..7b6b97b556 100644 --- a/platform/commonUI/edit/test/policies/EditableViewPolicySpec.js +++ b/platform/commonUI/edit/test/policies/EditableViewPolicySpec.js @@ -35,12 +35,12 @@ define( 'domainObject', ['hasCapability', 'getCapability'] ); - mockDomainObject.getCapability.andReturn({ + mockDomainObject.getCapability.and.returnValue({ inEditContext: function () { return true; } }); - mockDomainObject.hasCapability.andCallFake(function (c) { + mockDomainObject.hasCapability.and.callFake(function (c) { return (c === 'editor') && testMode; }); diff --git a/platform/commonUI/edit/test/representers/EditRepresenterSpec.js b/platform/commonUI/edit/test/representers/EditRepresenterSpec.js index 5ebe3d1b83..f1f73aca41 100644 --- a/platform/commonUI/edit/test/representers/EditRepresenterSpec.js +++ b/platform/commonUI/edit/test/representers/EditRepresenterSpec.js @@ -52,8 +52,8 @@ define([ 'useCapability' ]); - domainObject.getId.andReturn('anId'); - domainObject.getModel.andReturn({name: 'anObject'}); + domainObject.getId.and.returnValue('anId'); + domainObject.getModel.and.returnValue({name: 'anObject'}); representation = { key: 'someRepresentation' @@ -75,7 +75,7 @@ define([ expect(domainObject.useCapability) .toHaveBeenCalledWith('mutation', jasmine.any(Function)); - var mutateValue = domainObject.useCapability.calls[0].args[1](); + var mutateValue = domainObject.useCapability.calls.all()[0].args[1](); expect(mutateValue.configuration.someRepresentation) .toEqual({some: 'config'}); diff --git a/platform/commonUI/edit/test/representers/EditToolbarSpec.js b/platform/commonUI/edit/test/representers/EditToolbarSpec.js index 922567b192..b394ff3519 100644 --- a/platform/commonUI/edit/test/representers/EditToolbarSpec.js +++ b/platform/commonUI/edit/test/representers/EditToolbarSpec.js @@ -41,13 +41,13 @@ define( beforeEach(function () { mockOpenMCT = jasmine.createSpy('openmct', ['objects']); mockObjects = jasmine.createSpyObj('objects', ['observe']); - mockObjects.observe.andReturn(); + mockObjects.observe.and.returnValue(); mockOpenMCT.objects = mockObjects; mockScope = jasmine.createSpyObj("$scope", [ "$watchCollection", "$on" ]); - mockScope.$watchCollection.andReturn(); + mockScope.$watchCollection.and.returnValue(); mockDomainObject = jasmine.createSpyObj("domainObject", [ 'identifier' ]); diff --git a/platform/commonUI/edit/test/services/TransactionManagerSpec.js b/platform/commonUI/edit/test/services/TransactionManagerSpec.js index 4d44301893..25b317f3a8 100644 --- a/platform/commonUI/edit/test/services/TransactionManagerSpec.js +++ b/platform/commonUI/edit/test/services/TransactionManagerSpec.js @@ -44,10 +44,10 @@ define( testId = 'test-id'; mockPromise = jasmine.createSpyObj('promise', ['then']); - mockOnCommit.andReturn(mockPromise); - mockOnCancel.andReturn(mockPromise); + mockOnCommit.and.returnValue(mockPromise); + mockOnCancel.and.returnValue(mockPromise); - mockTransactionService.addToTransaction.andCallFake(function () { + mockTransactionService.addToTransaction.and.callFake(function () { var mockRemove = jasmine.createSpy('remove-' + mockRemoves.length); mockRemoves.push(mockRemove); @@ -59,7 +59,7 @@ define( it("delegates isActive calls", function () { [false, true].forEach(function (state) { - mockTransactionService.isActive.andReturn(state); + mockTransactionService.isActive.and.returnValue(state); expect(manager.isActive()).toBe(state); }); }); @@ -84,12 +84,12 @@ define( it("invokes passed-in callbacks from its own callbacks", function () { expect(mockOnCommit).not.toHaveBeenCalled(); mockTransactionService.addToTransaction - .mostRecentCall.args[0](); + .calls.mostRecent().args[0](); expect(mockOnCommit).toHaveBeenCalled(); expect(mockOnCancel).not.toHaveBeenCalled(); mockTransactionService.addToTransaction - .mostRecentCall.args[1](); + .calls.mostRecent().args[1](); expect(mockOnCancel).toHaveBeenCalled(); }); @@ -99,7 +99,7 @@ define( jasmine.createSpy(), jasmine.createSpy() ); - expect(mockTransactionService.addToTransaction.calls.length) + expect(mockTransactionService.addToTransaction.calls.count()) .toEqual(1); }); @@ -109,7 +109,7 @@ define( jasmine.createSpy(), jasmine.createSpy() ); - expect(mockTransactionService.addToTransaction.calls.length) + expect(mockTransactionService.addToTransaction.calls.count()) .toEqual(2); }); diff --git a/platform/commonUI/edit/test/services/TransactionServiceSpec.js b/platform/commonUI/edit/test/services/TransactionServiceSpec.js index 8e96d6b7f8..8ffe4ada55 100644 --- a/platform/commonUI/edit/test/services/TransactionServiceSpec.js +++ b/platform/commonUI/edit/test/services/TransactionServiceSpec.js @@ -40,7 +40,7 @@ define( beforeEach(function () { mockQ = jasmine.createSpyObj("$q", ["all"]); - mockQ.all.andReturn(fastPromise()); + mockQ.all.and.returnValue(fastPromise()); mockLog = jasmine.createSpyObj("$log", ["error"]); transactionService = new TransactionService(mockQ, mockLog); }); diff --git a/platform/commonUI/edit/test/services/TransactionSpec.js b/platform/commonUI/edit/test/services/TransactionSpec.js index 29e512084c..d51eb0bacd 100644 --- a/platform/commonUI/edit/test/services/TransactionSpec.js +++ b/platform/commonUI/edit/test/services/TransactionSpec.js @@ -92,7 +92,7 @@ define( describe("and an exception is encountered during commit", function () { beforeEach(function () { - mockCommit.andCallFake(function () { + mockCommit.and.callFake(function () { throw new Error("test error"); }); transaction.commit(); diff --git a/platform/commonUI/general/test/SplashScreenManagerSpec.js b/platform/commonUI/general/test/SplashScreenManagerSpec.js index 2f27c47599..d143bf346b 100644 --- a/platform/commonUI/general/test/SplashScreenManagerSpec.js +++ b/platform/commonUI/general/test/SplashScreenManagerSpec.js @@ -46,12 +46,12 @@ define([ splashElement.className = 'some-class-name'; - $document.querySelectorAll.andReturn([splashElement]); + $document.querySelectorAll.and.returnValue([splashElement]); }); describe('when element exists', function () { beforeEach(function () { - $document.querySelectorAll.andReturn([splashElement]); + $document.querySelectorAll.and.returnValue([splashElement]); return new SplashScreenManager([$document]); }); @@ -69,14 +69,14 @@ define([ .not .toHaveBeenCalled(); - splashElement.addEventListener.mostRecentCall.args[1](); + splashElement.addEventListener.calls.mostRecent().args[1](); expect(splashElement.parentNode.removeChild) .toHaveBeenCalledWith(splashElement); }); }); it('does not error when element doesn\'t exist', function () { - $document.querySelectorAll.andReturn([]); + $document.querySelectorAll.and.returnValue([]); function run() { return new SplashScreenManager([$document]); diff --git a/platform/commonUI/general/test/StyleSheetLoaderSpec.js b/platform/commonUI/general/test/StyleSheetLoaderSpec.js index 7e4e3481dc..2733b92d70 100644 --- a/platform/commonUI/general/test/StyleSheetLoaderSpec.js +++ b/platform/commonUI/general/test/StyleSheetLoaderSpec.js @@ -52,14 +52,14 @@ define( mockHead = jasmine.createSpyObj("head", ["append"]); mockElement = jasmine.createSpyObj("link", ["setAttribute"]); - mockDocument.find.andReturn(mockHead); - mockPlainDocument.createElement.andReturn(mockElement); + mockDocument.find.and.returnValue(mockHead); + mockPlainDocument.createElement.and.returnValue(mockElement); loader = new StyleSheetLoader(testStyleSheets, mockDocument); }); it("appends one link per stylesheet extension", function () { - expect(mockHead.append.calls.length) + expect(mockHead.append.calls.count()) .toEqual(testStyleSheets.length); }); diff --git a/platform/commonUI/general/test/controllers/ActionGroupControllerSpec.js b/platform/commonUI/general/test/controllers/ActionGroupControllerSpec.js index dd303e8179..1dbe07fcd9 100644 --- a/platform/commonUI/general/test/controllers/ActionGroupControllerSpec.js +++ b/platform/commonUI/general/test/controllers/ActionGroupControllerSpec.js @@ -34,7 +34,7 @@ define( "action" + index, ["perform", "getMetadata"] ); - action.getMetadata.andReturn(metadata); + action.getMetadata.and.returnValue(metadata); return action; } @@ -61,7 +61,7 @@ define( mockScope.action = mockActions; mockScope.parameters = { category: "test" }; - mockActions.getActions.andReturn([ + mockActions.getActions.and.returnValue([ { group: "a", someKey: 0 }, { group: "a", someKey: 1 }, { group: "b", someKey: 2 }, @@ -74,7 +74,7 @@ define( ].map(mockAction)); // Call the watch - mockScope.$watch.mostRecentCall.args[1](); + mockScope.$watch.calls.mostRecent().args[1](); // Should have grouped and ungrouped actions in scope now expect(mockScope.groups.length).toEqual(2); @@ -85,7 +85,7 @@ define( it("provides empty arrays when no action capability is available", function () { // Call the watch - mockScope.$watch.mostRecentCall.args[1](); + mockScope.$watch.calls.mostRecent().args[1](); expect(mockScope.groups.length).toEqual(0); expect(mockScope.ungrouped.length).toEqual(0); diff --git a/platform/commonUI/general/test/controllers/ClickAwayControllerSpec.js b/platform/commonUI/general/test/controllers/ClickAwayControllerSpec.js index a0a5cb0091..a24c074a00 100644 --- a/platform/commonUI/general/test/controllers/ClickAwayControllerSpec.js +++ b/platform/commonUI/general/test/controllers/ClickAwayControllerSpec.js @@ -79,9 +79,9 @@ define( it("deactivates and detaches listener on document click", function () { var callback, timeout; controller.setState(true); - callback = mockDocument.on.mostRecentCall.args[1]; + callback = mockDocument.on.calls.mostRecent().args[1]; callback(); - timeout = mockTimeout.mostRecentCall.args[0]; + timeout = mockTimeout.calls.mostRecent().args[0]; timeout(); expect(controller.isActive()).toEqual(false); expect(mockDocument.off).toHaveBeenCalledWith("mouseup", callback); diff --git a/platform/commonUI/general/test/controllers/ContextMenuControllerSpec.js b/platform/commonUI/general/test/controllers/ContextMenuControllerSpec.js index 6655519de7..ba695a7477 100644 --- a/platform/commonUI/general/test/controllers/ContextMenuControllerSpec.js +++ b/platform/commonUI/general/test/controllers/ContextMenuControllerSpec.js @@ -47,10 +47,10 @@ define( mockScope.action = mockActions; mockScope.parameters = { category: "test" }; - mockActions.getActions.andReturn(["a", "b", "c"]); + mockActions.getActions.and.returnValue(["a", "b", "c"]); // Call the watch - mockScope.$watch.mostRecentCall.args[1](); + mockScope.$watch.calls.mostRecent().args[1](); // Should have grouped and ungrouped actions in scope now expect(mockScope.menuActions.length).toEqual(3); diff --git a/platform/commonUI/general/test/controllers/DateTimeFieldControllerSpec.js b/platform/commonUI/general/test/controllers/DateTimeFieldControllerSpec.js index 3beb9f33ae..f1a895cc84 100644 --- a/platform/commonUI/general/test/controllers/DateTimeFieldControllerSpec.js +++ b/platform/commonUI/general/test/controllers/DateTimeFieldControllerSpec.js @@ -33,7 +33,7 @@ define( controller; function fireWatch(expr, value) { - mockScope.$watch.calls.forEach(function (call) { + mockScope.$watch.calls.all().forEach(function (call) { if (call.args[0] === expr) { call.args[1](value); } @@ -50,15 +50,15 @@ define( 'format' ]); - mockFormatService.getFormat.andReturn(mockFormat); + mockFormatService.getFormat.and.returnValue(mockFormat); - mockFormat.validate.andCallFake(function (text) { + mockFormat.validate.and.callFake(function (text) { return moment.utc(text, TEST_FORMAT).isValid(); }); - mockFormat.parse.andCallFake(function (text) { + mockFormat.parse.and.callFake(function (text) { return moment.utc(text, TEST_FORMAT).valueOf(); }); - mockFormat.format.andCallFake(function (value) { + mockFormat.format.and.callFake(function (value) { return moment.utc(value).format(TEST_FORMAT); }); @@ -159,8 +159,8 @@ define( var newText = "2015-3-3 01:02:04", oldValue = mockScope.ngModel.testField; - mockFormat.validate.andReturn(true); - mockFormat.parse.andReturn(42); + mockFormat.validate.and.returnValue(true); + mockFormat.parse.and.returnValue(42); mockScope.textValue = newText; fireWatch("textValue", newText); @@ -176,7 +176,7 @@ define( }); it("throws an error for unknown formats", function () { - mockFormatService.getFormat.andReturn(undefined); + mockFormatService.getFormat.and.returnValue(undefined); expect(function () { fireWatch("structure.format", "some-format"); }).toThrow(); @@ -187,9 +187,9 @@ define( testText = "some text"; beforeEach(function () { - mockFormat.validate.andReturn(true); - mockFormat.parse.andReturn(testValue); - mockFormat.format.andReturn(testText); + mockFormat.validate.and.returnValue(true); + mockFormat.parse.and.returnValue(testValue); + mockFormat.format.and.returnValue(testText); }); it("parses user input", function () { diff --git a/platform/commonUI/general/test/controllers/DateTimePickerControllerSpec.js b/platform/commonUI/general/test/controllers/DateTimePickerControllerSpec.js index 66edcbe873..91cf011871 100644 --- a/platform/commonUI/general/test/controllers/DateTimePickerControllerSpec.js +++ b/platform/commonUI/general/test/controllers/DateTimePickerControllerSpec.js @@ -30,7 +30,7 @@ define( controller; function fireWatch(expr, value) { - mockScope.$watch.calls.forEach(function (call) { + mockScope.$watch.calls.all().forEach(function (call) { if (call.args[0] === expr) { call.args[1](value); } @@ -38,7 +38,7 @@ define( } function fireWatchCollection(expr, value) { - mockScope.$watchCollection.calls.forEach(function (call) { + mockScope.$watchCollection.calls.all().forEach(function (call) { if (call.args[0] === expr) { call.args[1](value); } diff --git a/platform/commonUI/general/test/controllers/GetterSetterControllerSpec.js b/platform/commonUI/general/test/controllers/GetterSetterControllerSpec.js index edcdd5851c..30c0771a9e 100644 --- a/platform/commonUI/general/test/controllers/GetterSetterControllerSpec.js +++ b/platform/commonUI/general/test/controllers/GetterSetterControllerSpec.js @@ -53,7 +53,7 @@ define( expect(mockScope.ngModel) .not.toHaveBeenCalledWith("some new value"); // Fire the matching watcher - mockScope.$watch.calls.forEach(function (call) { + mockScope.$watch.calls.all().forEach(function (call) { if (call.args[0] === "getterSetter.value") { call.args[1](mockScope.getterSetter.value); } @@ -64,11 +64,11 @@ define( }); it("updates internal state when external changes are detected", function () { - mockScope.ngModel.andReturn("some other new value"); + mockScope.ngModel.and.returnValue("some other new value"); // Verify precondition expect(mockScope.getterSetter.value).toBeUndefined(); // Fire the matching watcher - mockScope.$watch.calls.forEach(function (call) { + mockScope.$watch.calls.all().forEach(function (call) { if (call.args[0] === "ngModel()") { call.args[1]("some other new value"); } diff --git a/platform/commonUI/general/test/controllers/ObjectInspectorControllerSpec.js b/platform/commonUI/general/test/controllers/ObjectInspectorControllerSpec.js index 9972292285..8f5b8e5e4f 100644 --- a/platform/commonUI/general/test/controllers/ObjectInspectorControllerSpec.js +++ b/platform/commonUI/general/test/controllers/ObjectInspectorControllerSpec.js @@ -50,14 +50,14 @@ define( "promise", ["then"] ); - mockObjectService.getObjects.andReturn(mockPromise); + mockObjectService.getObjects.and.returnValue(mockPromise); mockDomainObject = jasmine.createSpyObj( "selectedObject", ["hasCapability", "getCapability", "useCapability", "getModel"] ); - mockDomainObject.getModel.andReturn({location: 'somewhere'}); - mockDomainObject.hasCapability.andReturn(true); + mockDomainObject.getModel.and.returnValue({location: 'somewhere'}); + mockDomainObject.hasCapability.and.returnValue(true); mockContextCapability = jasmine.createSpyObj( "context capability", @@ -68,7 +68,7 @@ define( ["isLink"] ); - mockDomainObject.getCapability.andCallFake(function (param) { + mockDomainObject.getCapability.and.callFake(function (param) { if (param === 'location') { return mockLocationCapability; } else if (param === 'context') { @@ -91,21 +91,21 @@ define( }); it("looks for contextual parent objects", function () { - mockScope.$watch.mostRecentCall.args[1](); + mockScope.$watch.calls.mostRecent().args[1](); expect(mockContextCapability.getParent).toHaveBeenCalled(); }); it("if link, looks for primary parent objects", function () { - mockLocationCapability.isLink.andReturn(true); + mockLocationCapability.isLink.and.returnValue(true); - mockScope.$watch.mostRecentCall.args[1](); + mockScope.$watch.calls.mostRecent().args[1](); expect(mockDomainObject.getModel).toHaveBeenCalled(); expect(mockObjectService.getObjects).toHaveBeenCalled(); - mockPromise.then.mostRecentCall.args[0]({'somewhere': mockDomainObject}); + mockPromise.then.calls.mostRecent().args[0]({'somewhere': mockDomainObject}); }); it("gets metadata", function () { - mockScope.$watch.mostRecentCall.args[1](); + mockScope.$watch.calls.mostRecent().args[1](); expect(mockDomainObject.useCapability).toHaveBeenCalledWith('metadata'); }); }); diff --git a/platform/commonUI/general/test/controllers/SelectorControllerSpec.js b/platform/commonUI/general/test/controllers/SelectorControllerSpec.js index 7665e54162..2e6eaedf2b 100644 --- a/platform/commonUI/general/test/controllers/SelectorControllerSpec.js +++ b/platform/commonUI/general/test/controllers/SelectorControllerSpec.js @@ -45,7 +45,7 @@ define( 'object-' + id, ['getId'] ); - mockObject.getId.andReturn(id); + mockObject.getId.and.returnValue(id); return mockObject; } @@ -72,8 +72,8 @@ define( mockDomainObjects[id] = makeMockObject(id); }); - mockDomainObject.getCapability.andReturn(mockType); - mockObjectService.getObjects.andReturn(promiseOf(mockDomainObjects)); + mockDomainObject.getCapability.and.returnValue(mockType); + mockObjectService.getObjects.and.returnValue(promiseOf(mockDomainObjects)); mockScope.field = "testField"; mockScope.ngModel = {}; @@ -91,27 +91,27 @@ define( it("watches for changes in selection in left-hand tree", function () { var testObject = { a: 123, b: 456 }; // This test is sensitive to ordering of watch calls - expect(mockScope.$watch.calls.length).toEqual(1); + expect(mockScope.$watch.calls.count()).toEqual(1); // Make sure we're watching the correct object controller.treeModel.selectedObject = testObject; - expect(mockScope.$watch.calls[0].args[0]()).toBe(testObject); + expect(mockScope.$watch.calls.all()[0].args[0]()).toBe(testObject); }); it("watches for changes in controlled property", function () { var testValue = ["a", "b", 1, 2]; // This test is sensitive to ordering of watch calls - expect(mockScope.$watchCollection.calls.length).toEqual(1); + expect(mockScope.$watchCollection.calls.count()).toEqual(1); // Make sure we're watching the correct object mockScope.ngModel = { testField: testValue }; - expect(mockScope.$watchCollection.calls[0].args[0]()).toBe(testValue); + expect(mockScope.$watchCollection.calls.all()[0].args[0]()).toBe(testValue); }); it("rejects selection of incorrect types", function () { mockScope.structure = { type: "someType" }; - mockType.instanceOf.andReturn(false); + mockType.instanceOf.and.returnValue(false); controller.treeModel.selectedObject = mockDomainObject; // Fire the watch - mockScope.$watch.calls[0].args[1](mockDomainObject); + mockScope.$watch.calls.all()[0].args[1](mockDomainObject); // Should have cleared the selection expect(controller.treeModel.selectedObject).toBeUndefined(); // Verify interaction (that instanceOf got a useful argument) @@ -120,10 +120,10 @@ define( it("permits selection of matching types", function () { mockScope.structure = { type: "someType" }; - mockType.instanceOf.andReturn(true); + mockType.instanceOf.and.returnValue(true); controller.treeModel.selectedObject = mockDomainObject; // Fire the watch - mockScope.$watch.calls[0].args[1](mockDomainObject); + mockScope.$watch.calls.all()[0].args[1](mockDomainObject); // Should have preserved the selection expect(controller.treeModel.selectedObject).toEqual(mockDomainObject); // Verify interaction (that instanceOf got a useful argument) @@ -133,11 +133,11 @@ define( it("loads objects when the underlying list changes", function () { var testIds = ["abc", "def", "xyz"]; // This test is sensitive to ordering of watch calls - expect(mockScope.$watchCollection.calls.length).toEqual(1); + expect(mockScope.$watchCollection.calls.count()).toEqual(1); // Make sure we're watching the correct object mockScope.ngModel = { testField: testIds }; // Fire the watch - mockScope.$watchCollection.calls[0].args[1](testIds); + mockScope.$watchCollection.calls.all()[0].args[1](testIds); // Should have loaded the corresponding objects expect(mockObjectService.getObjects).toHaveBeenCalledWith(testIds); }); @@ -169,8 +169,8 @@ define( controller.select(mockDomainObjects.def); controller.select(mockDomainObjects.abc); // Fire the watch for the id changes... - mockScope.$watchCollection.calls[0].args[1]( - mockScope.$watchCollection.calls[0].args[0]() + mockScope.$watchCollection.calls.all()[0].args[1]( + mockScope.$watchCollection.calls.all()[0].args[0]() ); // Should have loaded and exposed those objects expect(controller.selected()).toEqual( diff --git a/platform/commonUI/general/test/controllers/TimeRangeControllerSpec.js b/platform/commonUI/general/test/controllers/TimeRangeControllerSpec.js index 2b3f756e64..34706ab93a 100644 --- a/platform/commonUI/general/test/controllers/TimeRangeControllerSpec.js +++ b/platform/commonUI/general/test/controllers/TimeRangeControllerSpec.js @@ -39,7 +39,7 @@ define( controller; function fireWatch(expr, value) { - mockScope.$watch.calls.forEach(function (call) { + mockScope.$watch.calls.all().forEach(function (call) { if (call.args[0] === expr) { call.args[1](value); } @@ -47,7 +47,7 @@ define( } function fireWatchCollection(expr, value) { - mockScope.$watchCollection.calls.forEach(function (call) { + mockScope.$watchCollection.calls.all().forEach(function (call) { if (call.args[0] === expr) { call.args[1](value); } @@ -73,9 +73,9 @@ define( ["validate", "format", "parse"] ); - mockFormatService.getFormat.andReturn(mockFormat); + mockFormatService.getFormat.and.returnValue(mockFormat); - mockFormat.format.andCallFake(function (value) { + mockFormat.format.and.callFake(function (value) { return moment.utc(value).format("YYYY-MM-DD HH:mm:ss"); }); @@ -300,7 +300,7 @@ define( }); it("throws an error for unknown formats", function () { - mockFormatService.getFormat.andReturn(undefined); + mockFormatService.getFormat.and.returnValue(undefined); expect(function () { fireWatch("parameters.format", "some-format"); }).toThrow(); diff --git a/platform/commonUI/general/test/controllers/TreeNodeControllerSpec.js b/platform/commonUI/general/test/controllers/TreeNodeControllerSpec.js index 3552d47a38..080726de9e 100644 --- a/platform/commonUI/general/test/controllers/TreeNodeControllerSpec.js +++ b/platform/commonUI/general/test/controllers/TreeNodeControllerSpec.js @@ -62,7 +62,7 @@ define( // Expansion is tracked on a timeout, because too // much expansion can result in an unstable digest. expect(mockTimeout).toHaveBeenCalled(); - mockTimeout.mostRecentCall.args[0](); + mockTimeout.calls.mostRecent().args[0](); expect(controller.hasBeenExpanded()).toBeTruthy(); controller.trackExpansion(); @@ -77,7 +77,7 @@ define( ), obj = new TestObject("test-object", mockContext); - mockContext.getPath.andReturn([obj]); + mockContext.getPath.and.returnValue([obj]); // Verify precondition expect(controller.isSelected()).toBeFalsy(); @@ -86,7 +86,7 @@ define( mockScope.domainObject = obj; // Invoke the watch with the new selection - mockScope.$watch.calls[0].args[1](obj); + mockScope.$watch.calls.all()[0].args[1](obj); expect(controller.isSelected()).toBeTruthy(); }); @@ -103,9 +103,9 @@ define( parent = new TestObject("parent", mockParentContext), child = new TestObject("child", mockChildContext); - mockChildContext.getParent.andReturn(parent); - mockChildContext.getPath.andReturn([parent, child]); - mockParentContext.getPath.andReturn([parent]); + mockChildContext.getParent.and.returnValue(parent); + mockChildContext.getPath.and.returnValue([parent, child]); + mockParentContext.getPath.and.returnValue([parent]); // Set up such that we are on, but not at the end of, a path mockScope.ngModel = { selectedObject: child }; @@ -113,13 +113,13 @@ define( mockScope.toggle = jasmine.createSpyObj("toggle", ["setState"]); // Invoke the watch with the new selection - mockScope.$watch.calls[0].args[1](child); + mockScope.$watch.calls.all()[0].args[1](child); // Expansion is tracked on a timeout, because too // much expansion can result in an unstable digest. // Trigger that timeout. expect(mockTimeout).toHaveBeenCalled(); - mockTimeout.mostRecentCall.args[0](); + mockTimeout.calls.mostRecent().args[0](); expect(mockScope.toggle.setState).toHaveBeenCalledWith(true); expect(controller.hasBeenExpanded()).toBeTruthy(); @@ -139,9 +139,9 @@ define( parent = new TestObject("parent", mockParentContext), child = new TestObject("child", mockChildContext); - mockChildContext.getParent.andReturn(parent); - mockChildContext.getPath.andReturn([child, child]); - mockParentContext.getPath.andReturn([parent]); + mockChildContext.getParent.and.returnValue(parent); + mockChildContext.getPath.and.returnValue([child, child]); + mockParentContext.getPath.and.returnValue([parent]); // Set up such that we are on, but not at the end of, a path mockScope.ngModel = { selectedObject: child }; @@ -149,7 +149,7 @@ define( mockScope.toggle = jasmine.createSpyObj("toggle", ["setState"]); // Invoke the watch with the new selection - mockScope.$watch.calls[0].args[1](child); + mockScope.$watch.calls.all()[0].args[1](child); // Expansion is tracked on a timeout, because too // much expansion can result in an unstable digest. @@ -172,9 +172,9 @@ define( parent = new TestObject("parent", mockParentContext), child = new TestObject("child", undefined); - mockChildContext.getParent.andReturn(parent); - mockChildContext.getPath.andReturn([parent, child]); - mockParentContext.getPath.andReturn([parent]); + mockChildContext.getParent.and.returnValue(parent); + mockChildContext.getPath.and.returnValue([parent, child]); + mockParentContext.getPath.and.returnValue([parent]); // Set up such that we are on, but not at the end of, a path mockScope.ngModel = { selectedObject: child }; @@ -182,7 +182,7 @@ define( mockScope.toggle = jasmine.createSpyObj("toggle", ["setState"]); // Invoke the watch with the new selection - mockScope.$watch.calls[0].args[1](child); + mockScope.$watch.calls.all()[0].args[1](child); expect(mockScope.toggle.setState).not.toHaveBeenCalled(); expect(controller.hasBeenExpanded()).toBeFalsy(); diff --git a/platform/commonUI/general/test/controllers/ViewSwitcherControllerSpec.js b/platform/commonUI/general/test/controllers/ViewSwitcherControllerSpec.js index f81d633a86..f88440b488 100644 --- a/platform/commonUI/general/test/controllers/ViewSwitcherControllerSpec.js +++ b/platform/commonUI/general/test/controllers/ViewSwitcherControllerSpec.js @@ -35,7 +35,7 @@ define( beforeEach(function () { mockScope = jasmine.createSpyObj("$scope", ["$watch"]); mockTimeout = jasmine.createSpy("$timeout"); - mockTimeout.andCallFake(function (cb) { + mockTimeout.and.callFake(function (cb) { cb(); }); mockScope.ngModel = {}; @@ -60,11 +60,11 @@ define( { key: "c", name: "View C" }, { key: "d", name: "View D" } ]; - mockScope.$watch.mostRecentCall.args[1](views); + mockScope.$watch.calls.mostRecent().args[1](views); mockScope.ngModel.selected = views[1]; // Change the set of applicable views - mockScope.$watch.mostRecentCall.args[1]([ + mockScope.$watch.calls.mostRecent().args[1]([ { key: "a", name: "View A" }, { key: "b", name: "View B" }, { key: "x", name: "View X" } @@ -81,11 +81,11 @@ define( { key: "c", name: "View C" }, { key: "d", name: "View D" } ]; - mockScope.$watch.mostRecentCall.args[1](views); + mockScope.$watch.calls.mostRecent().args[1](views); mockScope.ngModel.selected = views[1]; // Change the set of applicable views - mockScope.$watch.mostRecentCall.args[1]([ + mockScope.$watch.calls.mostRecent().args[1]([ { key: "a", name: "View A" }, { key: "c", name: "View C" }, { key: "x", name: "View X" } @@ -102,7 +102,7 @@ define( expect(mockTimeout).not.toHaveBeenCalled(); // Invoke the watch for set of views - mockScope.$watch.mostRecentCall.args[1]([]); + mockScope.$watch.calls.mostRecent().args[1]([]); // Should have run on a timeout expect(mockTimeout).toHaveBeenCalled(); diff --git a/platform/commonUI/general/test/directives/MCTClickElsewhereSpec.js b/platform/commonUI/general/test/directives/MCTClickElsewhereSpec.js index 9377334490..f2d3ff3827 100644 --- a/platform/commonUI/general/test/directives/MCTClickElsewhereSpec.js +++ b/platform/commonUI/general/test/directives/MCTClickElsewhereSpec.js @@ -66,9 +66,9 @@ define( height: 75 }; mockElement[0] = mockPlainEl; - mockPlainEl.getBoundingClientRect.andReturn(testRect); + mockPlainEl.getBoundingClientRect.and.returnValue(testRect); - mockDocument.find.andReturn(mockBody); + mockDocument.find.and.returnValue(mockBody); mctClickElsewhere = new MCTClickElsewhere(mockDocument); mctClickElsewhere.link(mockScope, mockElement, testAttrs); @@ -80,14 +80,14 @@ define( it("detaches listeners when destroyed", function () { expect(mockBody.off).not.toHaveBeenCalled(); - mockScope.$on.calls.forEach(function (call) { + mockScope.$on.calls.all().forEach(function (call) { if (call.args[0] === '$destroy') { call.args[1](); } }); expect(mockBody.off).toHaveBeenCalled(); - expect(mockBody.off.mostRecentCall.args) - .toEqual(mockBody.on.mostRecentCall.args); + expect(mockBody.off.calls.mostRecent().args) + .toEqual(mockBody.on.calls.mostRecent().args); }); it("listens for mousedown on the document's body", function () { @@ -97,7 +97,7 @@ define( describe("when a click occurs outside the element's bounds", function () { beforeEach(function () { - mockBody.on.mostRecentCall.args[1](testEvent( + mockBody.on.calls.mostRecent().args[1](testEvent( testRect.left + testRect.width + 10, testRect.top + testRect.height + 10 )); @@ -105,7 +105,7 @@ define( it("triggers an evaluation of its related Angular expression", function () { expect(mockScope.$apply).toHaveBeenCalled(); - mockScope.$apply.mostRecentCall.args[0](); + mockScope.$apply.calls.mostRecent().args[0](); expect(mockScope.$eval) .toHaveBeenCalledWith(testAttrs.mctClickElsewhere); }); @@ -113,7 +113,7 @@ define( describe("when a click occurs within the element's bounds", function () { beforeEach(function () { - mockBody.on.mostRecentCall.args[1](testEvent( + mockBody.on.calls.mostRecent().args[1](testEvent( testRect.left + testRect.width / 2, testRect.top + testRect.height / 2 )); diff --git a/platform/commonUI/general/test/directives/MCTDragSpec.js b/platform/commonUI/general/test/directives/MCTDragSpec.js index 1a23d09dbc..c8f0f6dbca 100644 --- a/platform/commonUI/general/test/directives/MCTDragSpec.js +++ b/platform/commonUI/general/test/directives/MCTDragSpec.js @@ -61,8 +61,8 @@ define( mctDragUp: "ending a drag" }; - mockDocument.find.andReturn(mockBody); - mockAgentService.isMobile.andReturn(true); + mockDocument.find.and.returnValue(mockBody); + mockAgentService.isMobile.and.returnValue(true); mctDrag = new MCTDrag(mockDocument, mockAgentService); mctDrag.link(mockScope, mockElement, testAttrs); @@ -84,7 +84,7 @@ define( it("invokes mctDragDown when dragging begins", function () { var event = testEvent(42, 60); - mockElement.on.mostRecentCall.args[1](event); + mockElement.on.calls.mostRecent().args[1](event); expect(mockScope.$eval).toHaveBeenCalledWith( testAttrs.mctDragDown, { delta: [0, 0], $event: event } @@ -92,7 +92,7 @@ define( }); it("listens for touchmove after dragging begins", function () { - mockElement.on.mostRecentCall.args[1](testEvent(42, 60)); + mockElement.on.calls.mostRecent().args[1](testEvent(42, 60)); expect(mockBody.on).toHaveBeenCalledWith( "touchmove", jasmine.any(Function) @@ -106,10 +106,10 @@ define( it("invokes mctDrag expression during drag", function () { var event; - mockElement.on.mostRecentCall.args[1](testEvent(42, 60)); + mockElement.on.calls.mostRecent().args[1](testEvent(42, 60)); // Find and invoke the touchmove listener - mockBody.on.calls.forEach(function (call) { + mockBody.on.calls.all().forEach(function (call) { if (call.args[0] === 'touchmove') { call.args[1](event = testEvent(52, 200)); } @@ -125,16 +125,16 @@ define( it("invokes mctDragUp expression after drag", function () { var event; - mockElement.on.mostRecentCall.args[1](testEvent(42, 60)); + mockElement.on.calls.mostRecent().args[1](testEvent(42, 60)); // Find and invoke the touchmove listener - mockBody.on.calls.forEach(function (call) { + mockBody.on.calls.all().forEach(function (call) { if (call.args[0] === 'touchmove') { call.args[1](testEvent(52, 200)); } }); // Find and invoke the touchmove listener - mockBody.on.calls.forEach(function (call) { + mockBody.on.calls.all().forEach(function (call) { if (call.args[0] === 'touchend') { call.args[1](event = testEvent(40, 71)); } @@ -189,8 +189,8 @@ define( mctDragUp: "ending a drag" }; - mockDocument.find.andReturn(mockBody); - mockAgentService.isMobile.andReturn(false); + mockDocument.find.and.returnValue(mockBody); + mockAgentService.isMobile.and.returnValue(false); mctDrag = new MCTDrag(mockDocument, mockAgentService); mctDrag.link(mockScope, mockElement, testAttrs); @@ -212,7 +212,7 @@ define( it("invokes mctDragDown when dragging begins", function () { var event = testEvent(42, 60); - mockElement.on.mostRecentCall.args[1](event); + mockElement.on.calls.mostRecent().args[1](event); expect(mockScope.$eval).toHaveBeenCalledWith( testAttrs.mctDragDown, { delta: [0, 0], $event: event } @@ -220,7 +220,7 @@ define( }); it("listens for mousemove after dragging begins", function () { - mockElement.on.mostRecentCall.args[1](testEvent(42, 60)); + mockElement.on.calls.mostRecent().args[1](testEvent(42, 60)); expect(mockBody.on).toHaveBeenCalledWith( "mousemove", jasmine.any(Function) @@ -234,10 +234,10 @@ define( it("invokes mctDrag expression during drag", function () { var event; - mockElement.on.mostRecentCall.args[1](testEvent(42, 60)); + mockElement.on.calls.mostRecent().args[1](testEvent(42, 60)); // Find and invoke the mousemove listener - mockBody.on.calls.forEach(function (call) { + mockBody.on.calls.all().forEach(function (call) { if (call.args[0] === 'mousemove') { call.args[1](event = testEvent(52, 200)); } @@ -253,16 +253,16 @@ define( it("invokes mctDragUp expression after drag", function () { var event; - mockElement.on.mostRecentCall.args[1](testEvent(42, 60)); + mockElement.on.calls.mostRecent().args[1](testEvent(42, 60)); // Find and invoke the mousemove listener - mockBody.on.calls.forEach(function (call) { + mockBody.on.calls.all().forEach(function (call) { if (call.args[0] === 'mousemove') { call.args[1](testEvent(52, 200)); } }); // Find and invoke the mousemove listener - mockBody.on.calls.forEach(function (call) { + mockBody.on.calls.all().forEach(function (call) { if (call.args[0] === 'mouseup') { call.args[1](event = testEvent(40, 71)); } diff --git a/platform/commonUI/general/test/directives/MCTPopupSpec.js b/platform/commonUI/general/test/directives/MCTPopupSpec.js index 9b5a482863..9884c665c6 100644 --- a/platform/commonUI/general/test/directives/MCTPopupSpec.js +++ b/platform/commonUI/general/test/directives/MCTPopupSpec.js @@ -78,14 +78,14 @@ define( height: 75 }; - mockCompile.andCallFake(function () { + mockCompile.and.callFake(function () { var mockFn = jasmine.createSpy(); - mockFn.andReturn(mockNewElement); + mockFn.and.returnValue(mockNewElement); return mockFn; }); - mockElement.parent.andReturn([mockParentEl]); - mockParentEl.getBoundingClientRect.andReturn(testRect); - mockPopupService.display.andReturn(mockPopup); + mockElement.parent.and.returnValue([mockParentEl]); + mockParentEl.getBoundingClientRect.and.returnValue(testRect); + mockPopupService.display.and.returnValue(mockPopup); mctPopup = new MCTPopup(mockCompile, mockPopupService); @@ -113,14 +113,14 @@ define( it("displays transcluded content", function () { var mockClone = jasmine.createSpyObj('clone', JQLITE_METHODS); - mockTransclude.mostRecentCall.args[0](mockClone); + mockTransclude.calls.mostRecent().args[0](mockClone); expect(mockNewElement.append) .toHaveBeenCalledWith(mockClone); }); it("is removed when its containing scope is destroyed", function () { expect(mockPopup.dismiss).not.toHaveBeenCalled(); - mockScope.$on.calls.forEach(function (call) { + mockScope.$on.calls.all().forEach(function (call) { if (call.args[0] === '$destroy') { call.args[1](); } diff --git a/platform/commonUI/general/test/directives/MCTResizeSpec.js b/platform/commonUI/general/test/directives/MCTResizeSpec.js index a01a70a542..125269673a 100644 --- a/platform/commonUI/general/test/directives/MCTResizeSpec.js +++ b/platform/commonUI/general/test/directives/MCTResizeSpec.js @@ -73,7 +73,7 @@ define( ); // Fire the timeout - mockTimeout.mostRecentCall.args[0](); + mockTimeout.calls.mostRecent().args[0](); // Should have triggered an evaluation of mctResize // with the new width & height @@ -91,56 +91,56 @@ define( .toHaveBeenCalledWith("$destroy", jasmine.any(Function)); // Should have scheduled the first timeout - expect(mockTimeout.calls.length).toEqual(1); + expect(mockTimeout.calls.count()).toEqual(1); // Fire the timeout - mockTimeout.mostRecentCall.args[0](); + mockTimeout.calls.mostRecent().args[0](); // Should have scheduled another timeout - expect(mockTimeout.calls.length).toEqual(2); + expect(mockTimeout.calls.count()).toEqual(2); // Broadcast a destroy event - mockScope.$on.mostRecentCall.args[1](); + mockScope.$on.calls.mostRecent().args[1](); testElement.offsetWidth = 300; testElement.offsetHeight = 350; - mockScope.$eval.reset(); + mockScope.$eval.calls.reset(); // Fire the timeout - mockTimeout.mostRecentCall.args[0](); + mockTimeout.calls.mostRecent().args[0](); // Should NOT have scheduled another timeout - expect(mockTimeout.calls.length).toEqual(2); + expect(mockTimeout.calls.count()).toEqual(2); expect(mockScope.$eval).not.toHaveBeenCalled(); }); it("triggers a digest cycle when size changes", function () { var applyCount; mctResize.link(mockScope, [testElement], testAttrs); - applyCount = mockScope.$apply.calls.length; + applyCount = mockScope.$apply.calls.count(); // Change the element's apparent size testElement.offsetWidth = 300; testElement.offsetHeight = 350; // Fire the timeout - mockTimeout.mostRecentCall.args[0](); + mockTimeout.calls.mostRecent().args[0](); // No more apply calls - expect(mockScope.$apply.calls.length) + expect(mockScope.$apply.calls.count()) .toBeGreaterThan(applyCount); }); it("does not trigger a digest cycle when size does not change", function () { var applyCount; mctResize.link(mockScope, [testElement], testAttrs); - applyCount = mockScope.$apply.calls.length; + applyCount = mockScope.$apply.calls.count(); // Fire the timeout - mockTimeout.mostRecentCall.args[0](); + mockTimeout.calls.mostRecent().args[0](); // No more apply calls - expect(mockScope.$apply.calls.length).toEqual(applyCount); + expect(mockScope.$apply.calls.count()).toEqual(applyCount); }); }); diff --git a/platform/commonUI/general/test/directives/MCTScrollSpec.js b/platform/commonUI/general/test/directives/MCTScrollSpec.js index 8d0f14a769..aa5d730855 100644 --- a/platform/commonUI/general/test/directives/MCTScrollSpec.js +++ b/platform/commonUI/general/test/directives/MCTScrollSpec.js @@ -49,7 +49,7 @@ define( mockElement = [{ testProperty: 42 }]; mockElement.on = jasmine.createSpy('on'); - mockParse.andReturn(mockParsed); + mockParse.and.returnValue(mockParsed); testAttrs = {}; testAttrs[ATTRIBUTE] = EXPRESSION; @@ -76,7 +76,7 @@ define( jasmine.any(Function) ); // Should have been only watch (other tests need this to be true) - expect(mockScope.$watch.calls.length).toEqual(1); + expect(mockScope.$watch.calls.count()).toEqual(1); }); it("listens for scroll events", function () { @@ -85,7 +85,7 @@ define( jasmine.any(Function) ); // Should have been only listener (other tests need this to be true) - expect(mockElement.on.calls.length).toEqual(1); + expect(mockElement.on.calls.count()).toEqual(1); }); it("publishes initial scroll state", function () { @@ -94,13 +94,13 @@ define( }); it("updates scroll state when scope changes", function () { - mockScope.$watch.mostRecentCall.args[1](64); + mockScope.$watch.calls.mostRecent().args[1](64); expect(mockElement[0].testProperty).toEqual(64); }); it("updates scope when scroll state changes", function () { mockElement[0].testProperty = 12321; - mockElement.on.mostRecentCall.args[1]({ target: mockElement[0] }); + mockElement.on.calls.mostRecent().args[1]({ target: mockElement[0] }); expect(mockParsed.assign).toHaveBeenCalledWith(mockScope, 12321); expect(mockScope.$apply).toHaveBeenCalledWith(EXPRESSION); }); diff --git a/platform/commonUI/general/test/directives/MCTSplitPaneSpec.js b/platform/commonUI/general/test/directives/MCTSplitPaneSpec.js index 2216eeed70..09ed25f407 100644 --- a/platform/commonUI/general/test/directives/MCTSplitPaneSpec.js +++ b/platform/commonUI/general/test/directives/MCTSplitPaneSpec.js @@ -49,7 +49,7 @@ define( mockInterval.cancel = jasmine.createSpy('mockCancel'); mockParsed = jasmine.createSpy('parsed'); mockParsed.assign = jasmine.createSpy('assign'); - mockParse.andReturn(mockParsed); + mockParse.and.returnValue(mockParsed); mockWindow.localStorage = { store: {}, @@ -84,7 +84,7 @@ define( controller; function fireOn(eventType) { - mockScope.$on.calls.forEach(function (call) { + mockScope.$on.calls.all().forEach(function (call) { if (call.args[0] === eventType) { call.args[1](); } @@ -106,12 +106,12 @@ define( mockSecondPane = jasmine.createSpyObj('secondPane', JQLITE_METHODS); - mockElement.children.andReturn(mockChildren); + mockElement.children.and.returnValue(mockChildren); mockElement[0] = { offsetWidth: 12321, offsetHeight: 45654 }; - mockChildren.eq.andCallFake(function (i) { + mockChildren.eq.and.callFake(function (i) { return [mockFirstPane, mockSplitter, mockSecondPane][i]; }); mockFirstPane[0] = { offsetWidth: 123, offsetHeight: 456 }; @@ -135,7 +135,7 @@ define( }); it("sets an interval which does not trigger digests", function () { - expect(mockInterval.mostRecentCall.args[3]).toBe(false); + expect(mockInterval.calls.mostRecent().args[3]).toBe(false); }); it("exposes its splitter's initial position", function () { @@ -202,7 +202,7 @@ define( expect(controller.position()).not.toEqual( mockFirstPane[0].offsetWidth ); - mockInterval.mostRecentCall.args[0](); + mockInterval.calls.mostRecent().args[0](); expect(controller.position()).toEqual( mockFirstPane[0].offsetWidth ); diff --git a/platform/commonUI/general/test/directives/MCTSplitterSpec.js b/platform/commonUI/general/test/directives/MCTSplitterSpec.js index 75e2375ec7..8ed70f1d1b 100644 --- a/platform/commonUI/general/test/directives/MCTSplitterSpec.js +++ b/platform/commonUI/general/test/directives/MCTSplitterSpec.js @@ -78,8 +78,8 @@ define( beforeEach(function () { testPosition = 12321; - mockSplitPane.position.andReturn(testPosition); - mockSplitPane.anchor.andReturn({ + mockSplitPane.position.and.returnValue(testPosition); + mockSplitPane.anchor.and.returnValue({ orientation: 'vertical', reversed: false }); diff --git a/platform/commonUI/general/test/directives/MCTTreeSpec.js b/platform/commonUI/general/test/directives/MCTTreeSpec.js index ea12d35b5d..84b0c8da63 100644 --- a/platform/commonUI/general/test/directives/MCTTreeSpec.js +++ b/platform/commonUI/general/test/directives/MCTTreeSpec.js @@ -38,8 +38,8 @@ define([ 'getCapability', 'hasCapability' ]); - mockDomainObject.getId.andReturn(id); - mockDomainObject.getModel.andReturn({}); + mockDomainObject.getId.and.returnValue(id); + mockDomainObject.getModel.and.returnValue({}); return mockDomainObject; } @@ -51,8 +51,8 @@ define([ mockParse = jasmine.createSpy('$parse'); mockExpr = jasmine.createSpy('expr'); mockExpr.assign = jasmine.createSpy('assign'); - mockParse.andReturn(mockExpr); - spyOn(TreeView.prototype, 'observe').andCallThrough(); + mockParse.and.returnValue(mockExpr); + spyOn(TreeView.prototype, 'observe').and.callThrough(); mctTree = new MCTTree(mockParse, mockGestureService); }); @@ -118,7 +118,7 @@ define([ it("does not trigger $apply during $watches", function () { mockScope.mctObject = makeMockDomainObject('root'); mockScope.mctMode = makeMockDomainObject('selection'); - mockScope.$watch.calls.forEach(function (call) { + mockScope.$watch.calls.all().forEach(function (call) { call.args[1](mockScope[call.args[0]]); }); expect(mockScope.$apply).not.toHaveBeenCalled(); @@ -129,7 +129,7 @@ define([ return; } // White-boxy; we know this is the setter for the tree's value - var treeValueFn = TreeView.prototype.observe.calls[0].args[0]; + var treeValueFn = TreeView.prototype.observe.calls.all()[0].args[0]; mockScope.mctObject = makeMockDomainObject('root'); mockScope.mctMode = makeMockDomainObject('selection'); diff --git a/platform/commonUI/general/test/services/PopupServiceSpec.js b/platform/commonUI/general/test/services/PopupServiceSpec.js index 09048b8a8e..2306af35e8 100644 --- a/platform/commonUI/general/test/services/PopupServiceSpec.js +++ b/platform/commonUI/general/test/services/PopupServiceSpec.js @@ -41,7 +41,7 @@ define( 'remove' ]); - mockDocument.find.andCallFake(function (query) { + mockDocument.find.and.callFake(function (query) { return query === 'body' && mockBody; }); diff --git a/platform/commonUI/general/test/services/UrlServiceSpec.js b/platform/commonUI/general/test/services/UrlServiceSpec.js index 43f1fc29fe..f305e9485c 100644 --- a/platform/commonUI/general/test/services/UrlServiceSpec.js +++ b/platform/commonUI/general/test/services/UrlServiceSpec.js @@ -60,25 +60,25 @@ define( // The mockContext is set a path // for the mockDomainObject - mockContext.getPath.andReturn( + mockContext.getPath.and.returnValue( [mockDomainObject] ); // view capability used with the testviews made - mockDomainObject.useCapability.andCallFake(function (c) { + mockDomainObject.useCapability.and.callFake(function (c) { return (c === 'view') && testViews; }); // context capability used with the mockContext created // so the variables including context in the urlFor are // initialized and reached - mockDomainObject.getCapability.andCallFake(function (c) { + mockDomainObject.getCapability.and.callFake(function (c) { return c === 'context' && mockContext; }); // Uses the mockLocation to get the current // "mock" website's view - mockLocation.search.andReturn({ view: 'def' }); + mockLocation.search.and.returnValue({ view: 'def' }); urlService = new UrlService(mockLocation); }); diff --git a/platform/commonUI/general/test/ui/TreeViewSpec.js b/platform/commonUI/general/test/ui/TreeViewSpec.js index d8acce3b84..44ec36f58d 100644 --- a/platform/commonUI/general/test/ui/TreeViewSpec.js +++ b/platform/commonUI/general/test/ui/TreeViewSpec.js @@ -46,15 +46,15 @@ define([ 'useCapability' ] ); - mockDomainObj.getId.andReturn(id); - mockDomainObj.getModel.andReturn(model); - mockDomainObj.hasCapability.andCallFake(function (c) { + mockDomainObj.getId.and.returnValue(id); + mockDomainObj.getModel.and.returnValue(model); + mockDomainObj.hasCapability.and.callFake(function (c) { return !!(capabilities[c]); }); - mockDomainObj.getCapability.andCallFake(function (c) { + mockDomainObj.getCapability.and.callFake(function (c) { return capabilities[c]; }); - mockDomainObj.useCapability.andCallFake(function (c) { + mockDomainObj.useCapability.and.callFake(function (c) { return capabilities[c] && capabilities[c].invoke(); }); return mockDomainObj; @@ -68,11 +68,11 @@ define([ mockGestureHandle = jasmine.createSpyObj('gestures', ['destroy']); - mockGestureService.attachGestures.andReturn(mockGestureHandle); + mockGestureService.attachGestures.and.returnValue(mockGestureHandle); mockMutation = jasmine.createSpyObj('mutation', ['listen']); mockUnlisten = jasmine.createSpy('unlisten'); - mockMutation.listen.andReturn(mockUnlisten); + mockMutation.listen.and.returnValue(mockUnlisten); testCapabilities = { mutation: mockMutation }; @@ -102,7 +102,7 @@ define([ var mockStatus = jasmine.createSpyObj('status', ['listen', 'list']); - mockStatus.list.andReturn([]); + mockStatus.list.and.returnValue([]); return { context: jasmine.createSpyObj('context', ['getPath']), @@ -113,16 +113,6 @@ define([ }; } - function waitForCompositionCallback() { - var calledBack = false; - testCapabilities.composition.invoke().then(function () { - calledBack = true; - }); - waitsFor(function () { - return calledBack; - }); - } - beforeEach(function () { mockComposition = ['a', 'b', 'c'].map(function (id) { var testCaps = makeGenericCapabilities(), @@ -130,7 +120,7 @@ define([ makeMockDomainObject(id, {}, testCaps); testCaps.context.getPath - .andReturn([mockDomainObject, mockChild]); + .and.returnValue([mockDomainObject, mockChild]); return mockChild; }); @@ -138,10 +128,10 @@ define([ testCapabilities.composition = jasmine.createSpyObj('composition', ['invoke']); testCapabilities.composition.invoke - .andReturn(Promise.resolve(mockComposition)); + .and.returnValue(Promise.resolve(mockComposition)); treeView.model(mockDomainObject); - waitForCompositionCallback(); + return testCapabilities.composition.invoke(); }); it("adds one node per composition element", function () { @@ -158,8 +148,8 @@ define([ beforeEach(function () { mockComposition.pop(); testCapabilities.mutation.listen - .mostRecentCall.args[0](mockDomainObject.getModel()); - waitForCompositionCallback(); + .calls.mostRecent().args[0](mockDomainObject.getModel()); + return testCapabilities.composition.invoke(); }); it("continues to show one node per composition element", function () { @@ -219,38 +209,30 @@ define([ mockNewChild = makeMockDomainObject('d', {}, newCapabilities), mockGrandchild = - makeMockDomainObject('gc', {}, gcCapabilities), - calledBackInner = false; + makeMockDomainObject('gc', {}, gcCapabilities); newCapabilities.composition = jasmine.createSpyObj('composition', ['invoke']); newCapabilities.composition.invoke - .andReturn(Promise.resolve([mockGrandchild])); + .and.returnValue(Promise.resolve([mockGrandchild])); mockComposition.push(mockNewChild); - newCapabilities.context.getPath.andReturn([ + newCapabilities.context.getPath.and.returnValue([ mockDomainObject, mockNewChild ]); - gcCapabilities.context.getPath.andReturn([ + gcCapabilities.context.getPath.and.returnValue([ mockDomainObject, mockNewChild, mockGrandchild ]); testCapabilities.mutation.listen - .mostRecentCall.args[0](mockDomainObject); - waitForCompositionCallback(); - runs(function () { - // Select the innermost object to force expansion, - // such that we can verify the subtree is present. + .calls.mostRecent().args[0](mockDomainObject); + + return testCapabilities.composition.invoke().then(function () { treeView.value(mockGrandchild); - newCapabilities.composition.invoke().then(function () { - calledBackInner = true; - }); - }); - waitsFor(function () { - return calledBackInner; + return newCapabilities.composition.invoke(); }); }); @@ -268,8 +250,8 @@ define([ testStatuses = ['foo']; - mockStatus.list.andReturn(testStatuses); - mockStatus.listen.mostRecentCall.args[0](testStatuses); + mockStatus.list.and.returnValue(testStatuses); + mockStatus.listen.calls.mostRecent().args[0](testStatuses); }); it("reflects the status change in the tree", function () { diff --git a/platform/commonUI/inspect/test/gestures/InfoButtonGestureSpec.js b/platform/commonUI/inspect/test/gestures/InfoButtonGestureSpec.js index 8615523b97..d5eedf1540 100644 --- a/platform/commonUI/inspect/test/gestures/InfoButtonGestureSpec.js +++ b/platform/commonUI/inspect/test/gestures/InfoButtonGestureSpec.js @@ -45,7 +45,7 @@ define( mockTimeout = jasmine.createSpy('$timeout'); mockDocument = jasmine.createSpyObj('$document', ['find']); mockBody = jasmine.createSpyObj('body', ['on', 'off', 'scope', 'css', 'unbind']); - mockDocument.find.andReturn(mockBody); + mockDocument.find.and.returnValue(mockBody); mockAgentService = jasmine.createSpyObj('agentService', ['isMobile', 'isPhone']); mockInfoService = jasmine.createSpyObj( 'infoService', @@ -68,14 +68,14 @@ define( testMetadata = [{ name: "Test name", value: "Test value" }]; 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); - mockInfoService.display.andReturn(mockHide); - mockAgentService.isMobile.andReturn(true); + mockElement.scope.and.returnValue(mockScope); + mockScope.$on.and.returnValue(mockOff); + mockInfoService.display.and.returnValue(mockHide); + mockAgentService.isMobile.and.returnValue(true); gesture = new InfoButtonGesture( mockDocument, mockAgentService, @@ -83,7 +83,7 @@ define( mockElement, mockDomainObject ); - fireGesture = mockElement.on.mostRecentCall.args[1]; + fireGesture = mockElement.on.calls.mostRecent().args[1]; }); it("expect click on the representation", function () { @@ -106,7 +106,7 @@ define( // Get the touch start on the body // and fire the dismiss gesture - fireDismissGesture = mockBody.on.mostRecentCall.args[1]; + fireDismissGesture = mockBody.on.calls.mostRecent().args[1]; fireDismissGesture(mockEvent); // Expect Body to have been touched, event.preventDefault() // to be called, then the mockBody listener to be detached diff --git a/platform/commonUI/inspect/test/gestures/InfoGestureSpec.js b/platform/commonUI/inspect/test/gestures/InfoGestureSpec.js index 15e1baaf49..6a2a7a35cf 100644 --- a/platform/commonUI/inspect/test/gestures/InfoGestureSpec.js +++ b/platform/commonUI/inspect/test/gestures/InfoGestureSpec.js @@ -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] diff --git a/platform/commonUI/inspect/test/services/InfoServiceSpec.js b/platform/commonUI/inspect/test/services/InfoServiceSpec.js index 1eac6f5b70..274dd26246 100644 --- a/platform/commonUI/inspect/test/services/InfoServiceSpec.js +++ b/platform/commonUI/inspect/test/services/InfoServiceSpec.js @@ -53,19 +53,19 @@ define( mockScope = jasmine.createSpyObj("scope", ["$destroy"]); mockElements = []; - mockPopupService.display.andReturn(mockPopup); - mockCompile.andCallFake(function () { + mockPopupService.display.and.returnValue(mockPopup); + mockCompile.and.callFake(function () { var mockCompiledTemplate = jasmine.createSpy('template'), mockElement = jasmine.createSpyObj('element', [ 'css', 'remove', 'append' ]); - mockCompiledTemplate.andReturn(mockElement); + mockCompiledTemplate.and.returnValue(mockElement); mockElements.push(mockElement); return mockCompiledTemplate; }); - mockRootScope.$new.andReturn(mockScope); + mockRootScope.$new.and.returnValue(mockScope); service = new InfoService( mockCompile, @@ -92,7 +92,7 @@ define( }); it("when on phone device, positions at bottom", function () { - mockAgentService.isPhone.andReturn(true); + mockAgentService.isPhone.and.returnValue(true); service = new InfoService( mockCompile, mockRootScope, @@ -119,10 +119,10 @@ define( ].join('-'); beforeEach(function () { - mockPopup.goesUp.andReturn(goesUp); - mockPopup.goesDown.andReturn(!goesUp); - mockPopup.goesLeft.andReturn(goesLeft); - mockPopup.goesRight.andReturn(!goesLeft); + mockPopup.goesUp.and.returnValue(goesUp); + mockPopup.goesDown.and.returnValue(!goesUp); + mockPopup.goesLeft.and.returnValue(goesLeft); + mockPopup.goesRight.and.returnValue(!goesLeft); service.display('', '', {}, [10, 10]); }); diff --git a/platform/commonUI/mobile/test/DeviceClassifierSpec.js b/platform/commonUI/mobile/test/DeviceClassifierSpec.js index 60e6073876..c7dd7046b9 100644 --- a/platform/commonUI/mobile/test/DeviceClassifierSpec.js +++ b/platform/commonUI/mobile/test/DeviceClassifierSpec.js @@ -60,11 +60,11 @@ define( 'body', ['addClass'] ); - mockDocument.find.andCallFake(function (sel) { + mockDocument.find.and.callFake(function (sel) { return sel === 'body' && mockBody; }); AGENT_SERVICE_METHODS.forEach(function (m) { - mockAgentService[m].andReturn(false); + mockAgentService[m].and.returnValue(false); }); }); @@ -78,7 +78,7 @@ define( beforeEach(function () { trueMethods.forEach(function (m) { - mockAgentService[m].andReturn(true); + mockAgentService[m].and.returnValue(true); }); classifier = new DeviceClassifier( mockAgentService, diff --git a/platform/commonUI/mobile/test/DeviceMatchersSpec.js b/platform/commonUI/mobile/test/DeviceMatchersSpec.js index 29b0f4b4f2..2a20914fa6 100644 --- a/platform/commonUI/mobile/test/DeviceMatchersSpec.js +++ b/platform/commonUI/mobile/test/DeviceMatchersSpec.js @@ -43,10 +43,10 @@ define( }); it("detects when a device is a desktop device", function () { - mockAgentService.isMobile.andReturn(false); + mockAgentService.isMobile.and.returnValue(false); expect(DeviceMatchers.desktop(mockAgentService)) .toBe(true); - mockAgentService.isMobile.andReturn(true); + mockAgentService.isMobile.and.returnValue(true); expect(DeviceMatchers.desktop(mockAgentService)) .toBe(false); }); @@ -65,10 +65,10 @@ define( "touch" ].forEach(function (deviceType) { it("detects when a device is a " + deviceType + " device", function () { - mockAgentService[method(deviceType)].andReturn(true); + mockAgentService[method(deviceType)].and.returnValue(true); expect(DeviceMatchers[deviceType](mockAgentService)) .toBe(true); - mockAgentService[method(deviceType)].andReturn(false); + mockAgentService[method(deviceType)].and.returnValue(false); expect(DeviceMatchers[deviceType](mockAgentService)) .toBe(false); }); diff --git a/platform/commonUI/mobile/test/MCTDeviceSpec.js b/platform/commonUI/mobile/test/MCTDeviceSpec.js index f4309fc918..5cfc31274a 100644 --- a/platform/commonUI/mobile/test/MCTDeviceSpec.js +++ b/platform/commonUI/mobile/test/MCTDeviceSpec.js @@ -47,12 +47,12 @@ define( mockElement = jasmine.createSpyObj(name, JQLITE_METHODS); mockClone = jasmine.createSpyObj(name, JQLITE_METHODS); - mockTransclude.andCallFake(function (fn) { + mockTransclude.and.callFake(function (fn) { fn(mockClone); }); // Look desktop-like by default - mockAgentService.isLandscape.andReturn(true); + mockAgentService.isLandscape.and.returnValue(true); testAttrs = {}; @@ -85,40 +85,40 @@ define( link(); expectExclusion(); - mockAgentService.isMobile.andReturn(true); + mockAgentService.isMobile.and.returnValue(true); link(); expectInclusion(); }); it("restricts element inclusion for tablet devices", function () { testAttrs.mctDevice = "tablet"; - mockAgentService.isMobile.andReturn(true); + mockAgentService.isMobile.and.returnValue(true); link(); expectExclusion(); - mockAgentService.isTablet.andReturn(true); + mockAgentService.isTablet.and.returnValue(true); link(); expectInclusion(); }); it("restricts element inclusion for phone devices", function () { testAttrs.mctDevice = "phone"; - mockAgentService.isMobile.andReturn(true); + mockAgentService.isMobile.and.returnValue(true); link(); expectExclusion(); - mockAgentService.isPhone.andReturn(true); + mockAgentService.isPhone.and.returnValue(true); link(); expectInclusion(); }); it("restricts element inclusion for desktop devices", function () { testAttrs.mctDevice = "desktop"; - mockAgentService.isMobile.andReturn(true); + mockAgentService.isMobile.and.returnValue(true); link(); expectExclusion(); - mockAgentService.isMobile.andReturn(false); + mockAgentService.isMobile.and.returnValue(false); link(); expectInclusion(); }); @@ -128,19 +128,19 @@ define( link(); expectExclusion(); - mockAgentService.isPortrait.andReturn(true); + mockAgentService.isPortrait.and.returnValue(true); link(); expectInclusion(); }); it("restricts element inclusion for landscape orientation", function () { testAttrs.mctDevice = "landscape"; - mockAgentService.isLandscape.andReturn(false); - mockAgentService.isPortrait.andReturn(true); + mockAgentService.isLandscape.and.returnValue(false); + mockAgentService.isPortrait.and.returnValue(true); link(); expectExclusion(); - mockAgentService.isLandscape.andReturn(true); + mockAgentService.isLandscape.and.returnValue(true); link(); expectInclusion(); }); @@ -153,13 +153,13 @@ define( // Neither portrait nor mobile, not called expectExclusion(); - mockAgentService.isPortrait.andReturn(true); + mockAgentService.isPortrait.and.returnValue(true); link(); // Was portrait, but not mobile, so no expectExclusion(); - mockAgentService.isMobile.andReturn(true); + mockAgentService.isMobile.and.returnValue(true); link(); expectInclusion(); }); diff --git a/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js b/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js index c4ae6e0878..c19c04b0b6 100644 --- a/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js +++ b/platform/commonUI/notification/test/NotificationIndicatorControllerSpec.js @@ -52,8 +52,8 @@ define( expect(mockScope.showNotificationsList).toBeDefined(); mockScope.showNotificationsList(); expect(mockDialogService.getDialogResponse).toHaveBeenCalled(); - expect(mockDialogService.getDialogResponse.mostRecentCall.args[0]).toBe('overlay-message-list'); - expect(mockDialogService.getDialogResponse.mostRecentCall.args[1].dialog).toBeDefined(); + expect(mockDialogService.getDialogResponse.calls.mostRecent().args[0]).toBe('overlay-message-list'); + expect(mockDialogService.getDialogResponse.calls.mostRecent().args[1].dialog).toBeDefined(); }); }); } diff --git a/platform/commonUI/notification/test/NotificationServiceSpec.js b/platform/commonUI/notification/test/NotificationServiceSpec.js index 3080b537a0..bc315eba46 100644 --- a/platform/commonUI/notification/test/NotificationServiceSpec.js +++ b/platform/commonUI/notification/test/NotificationServiceSpec.js @@ -37,14 +37,14 @@ define( errorModel; function elapseTimeout() { - mockTimeout.mostRecentCall.args[0](); + mockTimeout.calls.mostRecent().args[0](); } beforeEach(function () { mockTimeout = jasmine.createSpy("$timeout"); mockTopicFunction = jasmine.createSpy("topic"); mockTopicObject = jasmine.createSpyObj("topicObject", ["listen", "notify"]); - mockTopicFunction.andReturn(mockTopicObject); + mockTopicFunction.and.returnValue(mockTopicObject); mockAutoDismiss = mockMinimizeTimeout = 1000; notificationService = new NotificationService(mockTimeout, mockTopicFunction, mockAutoDismiss, mockMinimizeTimeout); @@ -72,7 +72,7 @@ define( expect(mockTopicObject.listen).toHaveBeenCalled(); notification.dismiss(); expect(mockTopicObject.notify).toHaveBeenCalled(); - mockTopicObject.listen.mostRecentCall.args[0](); + mockTopicObject.listen.calls.mostRecent().args[0](); expect(dismissListener).toHaveBeenCalled(); }); @@ -132,7 +132,7 @@ define( }); it("keeps alert notifications active if the caller disables auto-dismiss", function () { - mockTimeout.andCallFake(function (callback, time) { + mockTimeout.and.callFake(function (callback, time) { callback(); }); alertModel.autoDismiss = false; @@ -143,7 +143,7 @@ define( }); it("keeps alert notifications active if the caller ignores auto-dismiss", function () { - mockTimeout.andCallFake(function (callback, time) { + mockTimeout.and.callFake(function (callback, time) { callback(); }); var notification = notificationService.alert(alertModel); @@ -165,7 +165,7 @@ define( }); it("keeps error notifications active if the caller disables auto-dismiss", function () { - mockTimeout.andCallFake(function (callback, time) { + mockTimeout.and.callFake(function (callback, time) { callback(); }); errorModel.autoDismiss = false; @@ -176,7 +176,7 @@ define( }); it("keeps error notifications active if the caller ignores auto-dismiss", function () { - mockTimeout.andCallFake(function (callback, time) { + mockTimeout.and.callFake(function (callback, time) { callback(); }); var notification = notificationService.error(errorModel); diff --git a/platform/commonUI/regions/test/EditableRegionPolicySpec.js b/platform/commonUI/regions/test/EditableRegionPolicySpec.js index 3cc5c768b4..f8fcc30960 100644 --- a/platform/commonUI/regions/test/EditableRegionPolicySpec.js +++ b/platform/commonUI/regions/test/EditableRegionPolicySpec.js @@ -46,26 +46,26 @@ define( mockDomainObject = jasmine.createSpyObj("domainObject", [ "hasCapability", "getCapability" ]); - mockDomainObject.hasCapability.andReturn(true); - mockDomainObject.getCapability.andReturn(mockEditorCapability); + mockDomainObject.hasCapability.and.returnValue(true); + mockDomainObject.getCapability.and.returnValue(mockEditorCapability); }); it("includes only browse region parts for object not in edit mode", function () { - mockEditorCapability.inEditContext.andReturn(false); + mockEditorCapability.inEditContext.and.returnValue(false); expect(editableRegionPolicy.allow(mockBrowseRegionPart, mockDomainObject)).toBe(true); expect(editableRegionPolicy.allow(mockEditRegionPart, mockDomainObject)).toBe(false); }); it("includes only edit region parts for object in edit mode", function () { - mockEditorCapability.inEditContext.andReturn(true); + mockEditorCapability.inEditContext.and.returnValue(true); expect(editableRegionPolicy.allow(mockBrowseRegionPart, mockDomainObject)).toBe(false); expect(editableRegionPolicy.allow(mockEditRegionPart, mockDomainObject)).toBe(true); }); it("includes region parts with no mode specification", function () { - mockEditorCapability.inEditContext.andReturn(false); + mockEditorCapability.inEditContext.and.returnValue(false); expect(editableRegionPolicy.allow(mockAllModesRegionPart, mockDomainObject)).toBe(true); - mockEditorCapability.inEditContext.andReturn(true); + mockEditorCapability.inEditContext.and.returnValue(true); expect(editableRegionPolicy.allow(mockAllModesRegionPart, mockDomainObject)).toBe(true); }); diff --git a/platform/commonUI/regions/test/InspectorControllerSpec.js b/platform/commonUI/regions/test/InspectorControllerSpec.js index d0bc14b2d8..99b3d757f0 100644 --- a/platform/commonUI/regions/test/InspectorControllerSpec.js +++ b/platform/commonUI/regions/test/InspectorControllerSpec.js @@ -46,7 +46,7 @@ define( mockDomainObject = jasmine.createSpyObj('domainObject', [ 'getCapability' ]); - mockDomainObject.getCapability.andReturn(mockTypeDef); + mockDomainObject.getCapability.and.returnValue(mockTypeDef); mockScope = jasmine.createSpyObj('$scope', ['$on', 'selection'] @@ -63,7 +63,7 @@ define( 'off', 'get' ]); - mockSelection.get.andReturn(selectable); + mockSelection.get.and.returnValue(selectable); mockInspectorViews = jasmine.createSpyObj('inspectorViews', ['get']); mockOpenMCT = { @@ -73,7 +73,7 @@ define( container = jasmine.createSpy('container', ['innerHTML']); $document[0] = jasmine.createSpyObj("$document", ['querySelectorAll']); - $document[0].querySelectorAll.andReturn([container]); + $document[0].querySelectorAll.and.returnValue([container]); controller = new InspectorController(mockScope, mockOpenMCT, $document); }); @@ -89,10 +89,10 @@ define( var mockItem = jasmine.createSpyObj('domainObject', [ 'getCapability' ]); - mockItem.getCapability.andReturn(mockTypeDef); + mockItem.getCapability.and.returnValue(mockTypeDef); selectable[0].context.oldItem = mockItem; - mockOpenMCT.selection.on.mostRecentCall.args[1](selectable); + mockOpenMCT.selection.on.calls.mostRecent().args[1](selectable); expect(controller.selectedItem()).toEqual(mockItem); }); @@ -103,7 +103,7 @@ define( jasmine.any(Function) ); - mockScope.$on.calls[0].args[1](); + mockScope.$on.calls.all()[0].args[1](); expect(mockOpenMCT.selection.off).toHaveBeenCalledWith( 'change', diff --git a/platform/containment/test/ComposeActionPolicySpec.js b/platform/containment/test/ComposeActionPolicySpec.js index f409579d34..23b3b8cda4 100644 --- a/platform/containment/test/ComposeActionPolicySpec.js +++ b/platform/containment/test/ComposeActionPolicySpec.js @@ -40,7 +40,7 @@ define( ); mockTypes = ['a', 'b'].map(function (type) { var mockType = jasmine.createSpyObj('type-' + type, ['getKey']); - mockType.getKey.andReturn(type); + mockType.getKey.and.returnValue(type); return mockType; }); mockDomainObjects = ['a', 'b'].map(function (id, index) { @@ -48,8 +48,8 @@ define( 'domainObject-' + id, ['getId', 'getCapability'] ); - mockDomainObject.getId.andReturn(id); - mockDomainObject.getCapability.andCallFake(function (c) { + mockDomainObject.getId.and.returnValue(id); + mockDomainObject.getCapability.and.callFake(function (c) { return c === 'type' && mockTypes[index]; }); return mockDomainObject; @@ -62,8 +62,8 @@ define( selectedObject: mockDomainObjects[1] }; - mockAction.getMetadata.andReturn(testContext); - mockInjector.get.andCallFake(function (service) { + mockAction.getMetadata.and.returnValue(testContext); + mockInjector.get.and.callFake(function (service) { return service === 'policyService' && mockPolicyService; }); @@ -71,9 +71,9 @@ define( }); it("defers to composition policy", function () { - mockPolicyService.allow.andReturn(false); + mockPolicyService.allow.and.returnValue(false); expect(policy.allow(mockAction, testContext)).toBeFalsy(); - mockPolicyService.allow.andReturn(true); + mockPolicyService.allow.and.returnValue(true); expect(policy.allow(mockAction, testContext)).toBeTruthy(); expect(mockPolicyService.allow).toHaveBeenCalledWith( @@ -85,7 +85,7 @@ define( it("allows actions other than compose", function () { testContext.key = 'somethingElse'; - mockPolicyService.allow.andReturn(false); + mockPolicyService.allow.and.returnValue(false); expect(policy.allow(mockAction, testContext)).toBeTruthy(); }); }); diff --git a/platform/containment/test/CompositionModelPolicySpec.js b/platform/containment/test/CompositionModelPolicySpec.js index 3165312179..c2ebb9e45d 100644 --- a/platform/containment/test/CompositionModelPolicySpec.js +++ b/platform/containment/test/CompositionModelPolicySpec.js @@ -19,9 +19,9 @@ define( }); it("only allows composition for types which will have a composition property", function () { - mockType.getInitialModel.andReturn({}); + mockType.getInitialModel.and.returnValue({}); expect(policy.allow(mockObject)).toBeFalsy(); - mockType.getInitialModel.andReturn({ composition: [] }); + mockType.getInitialModel.and.returnValue({ composition: [] }); expect(policy.allow(mockObject)).toBeTruthy(); }); }); diff --git a/platform/containment/test/CompositionMutabilityPolicySpec.js b/platform/containment/test/CompositionMutabilityPolicySpec.js index 0cf8dbf7eb..009ae135eb 100644 --- a/platform/containment/test/CompositionMutabilityPolicySpec.js +++ b/platform/containment/test/CompositionMutabilityPolicySpec.js @@ -41,7 +41,7 @@ define( it("only allows composition for types which can be created/modified", function () { expect(policy.allow(mockObject)).toBeFalsy(); - mockType.hasFeature.andReturn(true); + mockType.hasFeature.and.returnValue(true); expect(policy.allow(mockObject)).toBeTruthy(); expect(mockType.hasFeature).toHaveBeenCalledWith('creation'); }); diff --git a/platform/containment/test/CompositionPolicySpec.js b/platform/containment/test/CompositionPolicySpec.js index 6cc7a4ac73..6ec25f2fe3 100644 --- a/platform/containment/test/CompositionPolicySpec.js +++ b/platform/containment/test/CompositionPolicySpec.js @@ -40,8 +40,8 @@ define( 'type A-- the particular kind', ['getKey', 'getDefinition'] ); - typeA.getKey.andReturn('a'); - typeA.getDefinition.andReturn({ + typeA.getKey.and.returnValue('a'); + typeA.getDefinition.and.returnValue({ contains: ['a'] }); @@ -50,8 +50,8 @@ define( 'type B-- anything goes', ['getKey', 'getDefinition'] ); - typeB.getKey.andReturn('b'); - typeB.getDefinition.andReturn({ + typeB.getKey.and.returnValue('b'); + typeB.getDefinition.and.returnValue({ contains: ['a', 'b'] }); @@ -59,8 +59,8 @@ define( 'type C-- distinguishing and interested in telemetry', ['getKey', 'getDefinition'] ); - typeC.getKey.andReturn('c'); - typeC.getDefinition.andReturn({ + typeC.getKey.and.returnValue('c'); + typeC.getDefinition.and.returnValue({ contains: [{has: 'telemetry'}] }); @@ -75,17 +75,17 @@ define( describe('enforces simple containment rules', function () { it('allows when type matches', function () { - mockParentObject.getCapability.andReturn(typeA); + mockParentObject.getCapability.and.returnValue(typeA); - mockChildObject.getCapability.andReturn(typeA); + mockChildObject.getCapability.and.returnValue(typeA); expect(policy.allow(mockParentObject, mockChildObject)) .toBeTruthy(); - mockParentObject.getCapability.andReturn(typeB); + mockParentObject.getCapability.and.returnValue(typeB); expect(policy.allow(mockParentObject, mockChildObject)) .toBeTruthy(); - mockChildObject.getCapability.andReturn(typeB); + mockChildObject.getCapability.and.returnValue(typeB); expect(policy.allow(mockParentObject, mockChildObject)) .toBeTruthy(); }); @@ -93,12 +93,12 @@ define( it('disallows when type doesn\'t match', function () { - mockParentObject.getCapability.andReturn(typeA); - mockChildObject.getCapability.andReturn(typeB); + mockParentObject.getCapability.and.returnValue(typeA); + mockChildObject.getCapability.and.returnValue(typeB); expect(policy.allow(mockParentObject, mockChildObject)) .toBeFalsy(); - mockChildObject.getCapability.andReturn(typeC); + mockChildObject.getCapability.and.returnValue(typeC); expect(policy.allow(mockParentObject, mockChildObject)) .toBeFalsy(); }); @@ -107,9 +107,9 @@ define( describe('enforces capability-based containment rules', function () { it('allows when object has capability', function () { - mockParentObject.getCapability.andReturn(typeC); + mockParentObject.getCapability.and.returnValue(typeC); - mockChildObject.hasCapability.andReturn(true); + mockChildObject.hasCapability.and.returnValue(true); expect(policy.allow(mockParentObject, mockChildObject)) .toBeTruthy(); expect(mockChildObject.hasCapability) @@ -117,9 +117,9 @@ define( }); it('skips when object doesn\'t have capability', function () { - mockChildObject.hasCapability.andReturn(false); + mockChildObject.hasCapability.and.returnValue(false); - mockParentObject.getCapability.andReturn(typeC); + mockParentObject.getCapability.and.returnValue(typeC); expect(policy.allow(mockParentObject, mockChildObject)) .toBeFalsy(); diff --git a/platform/containment/test/PersistableCompositionPolicySpec.js b/platform/containment/test/PersistableCompositionPolicySpec.js index 56c4ce6575..f06ef7d16b 100644 --- a/platform/containment/test/PersistableCompositionPolicySpec.js +++ b/platform/containment/test/PersistableCompositionPolicySpec.js @@ -44,15 +44,15 @@ define( 'getCapability', 'getId' ]); - mockParent.hasCapability.andReturn(true); - mockParent.getId.andReturn('someNamespace:someId'); + mockParent.hasCapability.and.returnValue(true); + mockParent.getId.and.returnValue('someNamespace:someId'); mockChild = {}; mockEditorCapability = jasmine.createSpyObj('domainObject', [ 'isEditContextRoot' ]); - mockParent.getCapability.andReturn(mockEditorCapability); + mockParent.getCapability.and.returnValue(mockEditorCapability); - objectAPI.getProvider.andReturn({ + objectAPI.getProvider.and.returnValue({ save: function () {} }); persistableCompositionPolicy = new PersistableCompositionPolicy(mockOpenMCT); @@ -64,18 +64,18 @@ define( // - openMct.objects.getProvider it("Does not allow composition for objects that are not persistable", function () { - mockEditorCapability.isEditContextRoot.andReturn(false); + mockEditorCapability.isEditContextRoot.and.returnValue(false); expect(persistableCompositionPolicy.allow(mockParent, mockChild)).toBe(true); - objectAPI.getProvider.andReturn({}); + objectAPI.getProvider.and.returnValue({}); expect(persistableCompositionPolicy.allow(mockParent, mockChild)).toBe(false); }); it("Always allows composition of objects in edit mode to support object creation", function () { - mockEditorCapability.isEditContextRoot.andReturn(true); + mockEditorCapability.isEditContextRoot.and.returnValue(true); expect(persistableCompositionPolicy.allow(mockParent, mockChild)).toBe(true); expect(objectAPI.getProvider).not.toHaveBeenCalled(); - mockEditorCapability.isEditContextRoot.andReturn(false); + mockEditorCapability.isEditContextRoot.and.returnValue(false); expect(persistableCompositionPolicy.allow(mockParent, mockChild)).toBe(true); expect(objectAPI.getProvider).toHaveBeenCalled(); }); diff --git a/platform/core/src/actions/ActionCapability.js b/platform/core/src/actions/ActionCapability.js index 4cd959a485..48cfa0bdf8 100644 --- a/platform/core/src/actions/ActionCapability.js +++ b/platform/core/src/actions/ActionCapability.js @@ -24,8 +24,8 @@ * Module defining ActionCapability. Created by vwoeltje on 11/10/14. */ define( - [], - function () { + ['lodash'], + function (_) { /** * The ActionCapability allows applicable Actions to be retrieved and @@ -74,10 +74,14 @@ define( // Get all actions which are valid in this context; // this simply redirects to the action service, // but additionally adds a domainObject field. - var baseContext = typeof context === 'string' ? - { key: context } : (context || {}), - actionContext = Object.create(baseContext); + var baseContext; + if (typeof context === 'string') { + baseContext = { key: context }; + } else { + baseContext = context || {}; + } + var actionContext = _.extend({}, baseContext); actionContext.domainObject = this.domainObject; return this.actionService.getActions(actionContext); diff --git a/platform/core/test/actions/ActionAggregatorSpec.js b/platform/core/test/actions/ActionAggregatorSpec.js index a7ef3ef33c..2eac74ff14 100644 --- a/platform/core/test/actions/ActionAggregatorSpec.js +++ b/platform/core/test/actions/ActionAggregatorSpec.js @@ -33,7 +33,7 @@ define( function createMockActionProvider(actions, i) { var spy = jasmine.createSpyObj("agg" + i, ["getActions"]); - spy.getActions.andReturn(actions); + spy.getActions.and.returnValue(actions); return spy; } diff --git a/platform/core/test/actions/ActionCapabilitySpec.js b/platform/core/test/actions/ActionCapabilitySpec.js index 63b5e08246..b03e704b48 100644 --- a/platform/core/test/actions/ActionCapabilitySpec.js +++ b/platform/core/test/actions/ActionCapabilitySpec.js @@ -52,7 +52,7 @@ define( ["getId", "getModel", "getCapability", "hasCapability", "useCapability"] ); - mockActionService.getActions.andReturn([mockAction, {}]); + mockActionService.getActions.and.returnValue([mockAction, {}]); capability = new ActionCapability( mockQ, @@ -77,8 +77,8 @@ define( it("promises the result of performed actions", function () { var mockPromise = jasmine.createSpyObj("promise", ["then"]); - mockQ.when.andReturn(mockPromise); - mockAction.perform.andReturn("the action's result"); + mockQ.when.and.returnValue(mockPromise); + mockAction.perform.and.returnValue("the action's result"); // Verify precondition expect(mockAction.perform).not.toHaveBeenCalled(); diff --git a/platform/core/test/actions/ActionProviderSpec.js b/platform/core/test/actions/ActionProviderSpec.js index 2c0d60fc27..60017e80e2 100644 --- a/platform/core/test/actions/ActionProviderSpec.js +++ b/platform/core/test/actions/ActionProviderSpec.js @@ -176,7 +176,7 @@ define( it("reports the error's message", function () { expect( - mockLog.error.mostRecentCall.args[0].indexOf(errorText) + mockLog.error.calls.mostRecent().args[0].indexOf(errorText) ).not.toEqual(-1); }); diff --git a/platform/core/test/actions/LoggingActionDecoratorSpec.js b/platform/core/test/actions/LoggingActionDecoratorSpec.js index 858f262b92..4cd0f37d77 100644 --- a/platform/core/test/actions/LoggingActionDecoratorSpec.js +++ b/platform/core/test/actions/LoggingActionDecoratorSpec.js @@ -47,7 +47,7 @@ define( ["error", "warn", "info", "debug"] ); - mockActionService.getActions.andReturn([mockAction]); + mockActionService.getActions.and.returnValue([mockAction]); decorator = new LoggingActionDecorator( mockLog, diff --git a/platform/core/test/capabilities/CompositionCapabilitySpec.js b/platform/core/test/capabilities/CompositionCapabilitySpec.js index 0a944e6b08..16b5827270 100644 --- a/platform/core/test/capabilities/CompositionCapabilitySpec.js +++ b/platform/core/test/capabilities/CompositionCapabilitySpec.js @@ -72,7 +72,7 @@ define( } }; - mockObjectService.getObjects.andReturn(mockPromise([])); + mockObjectService.getObjects.and.returnValue(mockPromise([])); composition = new CompositionCapability( mockInjector, @@ -90,7 +90,7 @@ define( it("requests ids found in model's composition from the object service", function () { var ids = ["a", "b", "c", "xyz"]; - mockDomainObject.getModel.andReturn({ composition: ids }); + mockDomainObject.getModel.and.returnValue({ composition: ids }); composition.invoke(); @@ -101,9 +101,9 @@ define( var result, mockChild = jasmine.createSpyObj("child", DOMAIN_OBJECT_METHODS); - mockDomainObject.getModel.andReturn({ composition: ["x"] }); - mockObjectService.getObjects.andReturn(mockPromise({x: mockChild})); - mockChild.getCapability.andReturn(undefined); + mockDomainObject.getModel.and.returnValue({ composition: ["x"] }); + mockObjectService.getObjects.and.returnValue(mockPromise({x: mockChild})); + mockChild.getCapability.and.returnValue(undefined); composition.invoke().then(function (c) { result = c; @@ -119,12 +119,12 @@ define( testModel = { composition: [] }, mockChild = jasmine.createSpyObj("child", DOMAIN_OBJECT_METHODS); - mockDomainObject.getModel.andReturn(testModel); - mockObjectService.getObjects.andReturn(mockPromise({a: mockChild})); - mockChild.getCapability.andReturn(undefined); - mockChild.getId.andReturn('a'); + mockDomainObject.getModel.and.returnValue(testModel); + mockObjectService.getObjects.and.returnValue(mockPromise({a: mockChild})); + mockChild.getCapability.and.returnValue(undefined); + mockChild.getId.and.returnValue('a'); - mockDomainObject.useCapability.andCallFake(function (key, mutator) { + mockDomainObject.useCapability.and.callFake(function (key, mutator) { if (key === 'mutation') { mutator(testModel); return mockPromise(true); @@ -149,12 +149,12 @@ define( testModel = { composition: ['a'] }, mockChild = jasmine.createSpyObj("child", DOMAIN_OBJECT_METHODS); - mockDomainObject.getModel.andReturn(testModel); - mockObjectService.getObjects.andReturn(mockPromise({a: mockChild})); - mockChild.getCapability.andReturn(undefined); - mockChild.getId.andReturn('a'); + mockDomainObject.getModel.and.returnValue(testModel); + mockObjectService.getObjects.and.returnValue(mockPromise({a: mockChild})); + mockChild.getCapability.and.returnValue(undefined); + mockChild.getId.and.returnValue('a'); - mockDomainObject.useCapability.andCallFake(function (key, mutator) { + mockDomainObject.useCapability.and.callFake(function (key, mutator) { if (key === 'mutation') { mutator(testModel); return mockPromise(true); @@ -180,12 +180,12 @@ define( testModel = { composition: ['a', 'b', 'c'] }, mockChild = jasmine.createSpyObj("child", DOMAIN_OBJECT_METHODS); - mockDomainObject.getModel.andReturn(testModel); - mockObjectService.getObjects.andReturn(mockPromise({a: mockChild})); - mockChild.getCapability.andReturn(undefined); - mockChild.getId.andReturn('a'); + mockDomainObject.getModel.and.returnValue(testModel); + mockObjectService.getObjects.and.returnValue(mockPromise({a: mockChild})); + mockChild.getCapability.and.returnValue(undefined); + mockChild.getId.and.returnValue('a'); - mockDomainObject.useCapability.andCallFake(function (key, mutator) { + mockDomainObject.useCapability.and.callFake(function (key, mutator) { if (key === 'mutation') { mutator(testModel); return mockPromise(true); diff --git a/platform/core/test/capabilities/ContextCapabilitySpec.js b/platform/core/test/capabilities/ContextCapabilitySpec.js index 2d6b12ee9e..208f2e299c 100644 --- a/platform/core/test/capabilities/ContextCapabilitySpec.js +++ b/platform/core/test/capabilities/ContextCapabilitySpec.js @@ -48,10 +48,10 @@ define( mockGrandparent = jasmine.createSpyObj("grandparent", DOMAIN_OBJECT_METHODS); mockContext = jasmine.createSpyObj("context", ["getParent", "getRoot", "getPath"]); - mockParent.getCapability.andReturn(mockContext); - mockContext.getParent.andReturn(mockGrandparent); - mockContext.getRoot.andReturn(mockGrandparent); - mockContext.getPath.andReturn([mockGrandparent, mockParent]); + mockParent.getCapability.and.returnValue(mockContext); + mockContext.getParent.and.returnValue(mockGrandparent); + mockContext.getRoot.and.returnValue(mockGrandparent); + mockContext.getPath.and.returnValue([mockGrandparent, mockParent]); context = new ContextCapability(mockParent, mockDomainObject); }); @@ -69,7 +69,7 @@ define( }); it("treats ancestors with no context capability as deepest ancestors", function () { - mockParent.getCapability.andReturn(undefined); + mockParent.getCapability.and.returnValue(undefined); expect(context.getPath()).toEqual([mockParent, mockDomainObject]); expect(context.getRoot()).toEqual(mockParent); }); diff --git a/platform/core/test/capabilities/ContextualDomainObjectSpec.js b/platform/core/test/capabilities/ContextualDomainObjectSpec.js index d7cc5d4986..8ac13f877c 100644 --- a/platform/core/test/capabilities/ContextualDomainObjectSpec.js +++ b/platform/core/test/capabilities/ContextualDomainObjectSpec.js @@ -49,8 +49,8 @@ define( model = { someKey: "some value" }; - mockDomainObject.getCapability.andReturn("some capability"); - mockDomainObject.getModel.andReturn(model); + mockDomainObject.getCapability.and.returnValue("some capability"); + mockDomainObject.getModel.and.returnValue(model); contextualDomainObject = new ContextualDomainObject( mockDomainObject, diff --git a/platform/core/test/capabilities/CoreCapabilityProviderSpec.js b/platform/core/test/capabilities/CoreCapabilityProviderSpec.js index 9a34cc3cc0..6e7a88a41c 100644 --- a/platform/core/test/capabilities/CoreCapabilityProviderSpec.js +++ b/platform/core/test/capabilities/CoreCapabilityProviderSpec.js @@ -49,6 +49,8 @@ define( } beforeEach(function () { + KeylessCapability.key = undefined; + mockLog = jasmine.createSpyObj( "$log", ["error", "warn", "info", "debug"] diff --git a/platform/core/test/capabilities/InstantiationCapabilitySpec.js b/platform/core/test/capabilities/InstantiationCapabilitySpec.js index 960ddbfe37..6b5bc77374 100644 --- a/platform/core/test/capabilities/InstantiationCapabilitySpec.js +++ b/platform/core/test/capabilities/InstantiationCapabilitySpec.js @@ -49,16 +49,16 @@ define( ['getId', 'getCapability', 'getModel'] ); - mockInjector.get.andCallFake(function (key) { + mockInjector.get.and.callFake(function (key) { return { 'instantiate': mockInstantiate }[key]; }); - mockIdentifierService.parse.andReturn(mockIdentifier); - mockIdentifierService.generate.andReturn("some-id"); + mockIdentifierService.parse.and.returnValue(mockIdentifier); + mockIdentifierService.generate.and.returnValue("some-id"); mockNow = jasmine.createSpy(); - mockNow.andReturn(1234321); + mockNow.and.returnValue(1234321); instantiation = new InstantiationCapability( mockInjector, @@ -81,7 +81,7 @@ define( 'useCapability', 'hasCapability' ]), testModel = { someKey: "some value" }; - mockInstantiate.andReturn(mockDomainObj); + mockInstantiate.and.returnValue(mockDomainObj); instantiation.instantiate(testModel); expect(mockInstantiate) .toHaveBeenCalledWith({ diff --git a/platform/core/test/capabilities/MetadataCapabilitySpec.js b/platform/core/test/capabilities/MetadataCapabilitySpec.js index 7c36fb2ae2..d1f22b869b 100644 --- a/platform/core/test/capabilities/MetadataCapabilitySpec.js +++ b/platform/core/test/capabilities/MetadataCapabilitySpec.js @@ -58,18 +58,18 @@ define( 'property-' + k, ['getValue', 'getDefinition'] ); - mockProperty.getValue.andReturn("Value " + k); - mockProperty.getDefinition.andReturn({ name: "Property " + k}); + mockProperty.getValue.and.returnValue("Value " + k); + mockProperty.getDefinition.and.returnValue({ name: "Property " + k}); return mockProperty; }); testModel = { name: "" }; - mockDomainObject.getId.andReturn("Test id"); - mockDomainObject.getModel.andReturn(testModel); - mockDomainObject.getCapability.andCallFake(getCapability); - mockDomainObject.useCapability.andCallFake(getCapability); - mockType.getProperties.andReturn(mockProperties); - mockType.getName.andReturn("Test type"); + mockDomainObject.getId.and.returnValue("Test id"); + mockDomainObject.getModel.and.returnValue(testModel); + mockDomainObject.getCapability.and.callFake(getCapability); + mockDomainObject.useCapability.and.callFake(getCapability); + mockType.getProperties.and.returnValue(mockProperties); + mockType.getName.and.returnValue("Test type"); metadata = new MetadataCapability(mockDomainObject); }); diff --git a/platform/core/test/capabilities/MutationCapabilitySpec.js b/platform/core/test/capabilities/MutationCapabilitySpec.js index 61791d1f04..9df4bd9206 100644 --- a/platform/core/test/capabilities/MutationCapabilitySpec.js +++ b/platform/core/test/capabilities/MutationCapabilitySpec.js @@ -48,7 +48,7 @@ define( testModel = { number: 6 }; topic = new Topic(); mockNow = jasmine.createSpy('now'); - mockNow.andReturn(12321); + mockNow.and.returnValue(12321); mutation = new MutationCapability( topic, mockNow, @@ -105,7 +105,7 @@ define( m.number = 8; }); expect(mockCallback).toHaveBeenCalled(); - expect(mockCallback.mostRecentCall.args[0].number) + expect(mockCallback.calls.mostRecent().args[0].number) .toEqual(8); }); @@ -130,7 +130,7 @@ define( m.number = 8; }); expect(mockCallback).toHaveBeenCalled(); - expect(mockCallback.mostRecentCall.args[0].number) + expect(mockCallback.calls.mostRecent().args[0].number) .toEqual(8); }); }); diff --git a/platform/core/test/capabilities/PersistenceCapabilitySpec.js b/platform/core/test/capabilities/PersistenceCapabilitySpec.js index c3cfe40c0b..94dfc2ae85 100644 --- a/platform/core/test/capabilities/PersistenceCapabilitySpec.js +++ b/platform/core/test/capabilities/PersistenceCapabilitySpec.js @@ -95,15 +95,15 @@ define( useCapability: jasmine.createSpy() }; // Simulate mutation capability - mockDomainObject.useCapability.andCallFake(function (capability, mutator) { + mockDomainObject.useCapability.and.callFake(function (capability, mutator) { if (capability === 'mutation') { model = mutator(model) || model; } }); - mockIdentifierService.parse.andReturn(mockIdentifier); - mockIdentifier.getSpace.andReturn(SPACE); - mockIdentifier.getKey.andReturn(key); - mockQ.when.andCallFake(asPromise); + mockIdentifierService.parse.and.returnValue(mockIdentifier); + mockIdentifier.getSpace.and.returnValue(SPACE); + mockIdentifier.getKey.and.returnValue(key); + mockQ.when.and.callFake(asPromise); persistence = new PersistenceCapability( mockCacheService, mockPersistenceService, @@ -116,8 +116,8 @@ define( describe("successful persistence", function () { beforeEach(function () { - mockPersistenceService.updateObject.andReturn(happyPromise); - mockPersistenceService.createObject.andReturn(happyPromise); + mockPersistenceService.updateObject.and.returnValue(happyPromise); + mockPersistenceService.createObject.and.returnValue(happyPromise); }); it("creates unpersisted objects with the persistence service", function () { // Verify precondition; no call made during constructor @@ -158,7 +158,7 @@ define( it("refreshes the domain object model from persistence", function () { var refreshModel = {someOtherKey: "some other value"}; model.persisted = 1; - mockPersistenceService.readObject.andReturn(asPromise(refreshModel)); + mockPersistenceService.readObject.and.returnValue(asPromise(refreshModel)); persistence.refresh(); expect(model).toEqual(refreshModel); }); @@ -178,7 +178,7 @@ define( } }; beforeEach(function () { - mockPersistenceService.createObject.andReturn(sadPromise); + mockPersistenceService.createObject.and.returnValue(sadPromise); }); it("rejects on falsey persistence result", function () { persistence.persist(); diff --git a/platform/core/test/capabilities/RelationshipCapabilitySpec.js b/platform/core/test/capabilities/RelationshipCapabilitySpec.js index c0ab3215a6..d084e886c8 100644 --- a/platform/core/test/capabilities/RelationshipCapabilitySpec.js +++ b/platform/core/test/capabilities/RelationshipCapabilitySpec.js @@ -69,7 +69,7 @@ define( } }; - mockObjectService.getObjects.andReturn(mockPromise([])); + mockObjectService.getObjects.and.returnValue(mockPromise([])); relationship = new RelationshipCapability( mockInjector, @@ -87,7 +87,7 @@ define( it("requests ids found in model's composition from the object service", function () { var ids = ["a", "b", "c", "xyz"]; - mockDomainObject.getModel.andReturn({ relationships: { xyz: ids } }); + mockDomainObject.getModel.and.returnValue({ relationships: { xyz: ids } }); relationship.getRelatedObjects('xyz'); @@ -95,7 +95,7 @@ define( }); it("provides a list of relationship types", function () { - mockDomainObject.getModel.andReturn({ relationships: { + mockDomainObject.getModel.and.returnValue({ relationships: { abc: ['a', 'b'], def: "not an array, should be ignored", xyz: [] @@ -107,14 +107,14 @@ define( // Lookups can be expensive, so this capability // should have some self-caching mockDomainObject.getModel - .andReturn({ relationships: { xyz: ['a'] } }); + .and.returnValue({ relationships: { xyz: ['a'] } }); // Call twice; response should be the same object instance expect(relationship.getRelatedObjects('xyz')) .toBe(relationship.getRelatedObjects('xyz')); // Should have only made one call - expect(mockObjectService.getObjects.calls.length) + expect(mockObjectService.getObjects.calls.count()) .toEqual(1); }); @@ -125,7 +125,7 @@ define( testModel = { relationships: { xyz: ['a'] } }; - mockDomainObject.getModel.andReturn(testModel); + mockDomainObject.getModel.and.returnValue(testModel); // Call twice, but as if modification had occurred in between relationship.getRelatedObjects('xyz'); @@ -133,7 +133,7 @@ define( relationship.getRelatedObjects('xyz'); // Should have only made one call - expect(mockObjectService.getObjects.calls.length) + expect(mockObjectService.getObjects.calls.count()) .toEqual(2); }); diff --git a/platform/core/test/models/CachingModelDecoratorSpec.js b/platform/core/test/models/CachingModelDecoratorSpec.js index 5739d00aa4..669279d0e0 100644 --- a/platform/core/test/models/CachingModelDecoratorSpec.js +++ b/platform/core/test/models/CachingModelDecoratorSpec.js @@ -67,7 +67,7 @@ define( a: { someKey: "some value" }, b: { someOtherKey: "some other value" } }; - mockModelService.getModels.andReturn(asPromise(testModels)); + mockModelService.getModels.and.returnValue(asPromise(testModels)); decorator = new CachingModelDecorator( new ModelCacheService(), mockModelService @@ -80,19 +80,19 @@ define( }); it("does not try to reload cached models", function () { - mockModelService.getModels.andReturn(asPromise({ a: testModels.a })); + mockModelService.getModels.and.returnValue(asPromise({ a: testModels.a })); decorator.getModels(['a']); - mockModelService.getModels.andReturn(asPromise(testModels)); + mockModelService.getModels.and.returnValue(asPromise(testModels)); decorator.getModels(['a', 'b']); expect(mockModelService.getModels).not.toHaveBeenCalledWith(['a', 'b']); - expect(mockModelService.getModels.mostRecentCall.args[0]).toEqual(['b']); + expect(mockModelService.getModels.calls.mostRecent().args[0]).toEqual(['b']); }); it("does not call its wrapped model service if not needed", function () { decorator.getModels(['a', 'b']); - expect(mockModelService.getModels.calls.length).toEqual(1); + expect(mockModelService.getModels.calls.count()).toEqual(1); decorator.getModels(['a', 'b']).then(mockCallback); - expect(mockModelService.getModels.calls.length).toEqual(1); + expect(mockModelService.getModels.calls.count()).toEqual(1); // Verify that we still got back our models, even though // no new call to the wrapped service was made expect(mockCallback).toHaveBeenCalledWith(testModels); @@ -105,9 +105,9 @@ define( promiseB = fakePromise(); // Issue two calls before those promises resolve - mockModelService.getModels.andReturn(promiseA); + mockModelService.getModels.and.returnValue(promiseA); decorator.getModels(['a']); - mockModelService.getModels.andReturn(promiseB); + mockModelService.getModels.and.returnValue(promiseB); decorator.getModels(['a']).then(mockCallback); // Then resolve those promises. Note that we're whiteboxing here @@ -119,9 +119,9 @@ define( }); // Ensure that we have a pointer-identical instance - expect(mockCallback.mostRecentCall.args[0].a) + expect(mockCallback.calls.mostRecent().args[0].a) .toEqual({ someNewKey: "some other value" }); - expect(mockCallback.mostRecentCall.args[0].a) + expect(mockCallback.calls.mostRecent().args[0].a) .toBe(testModels.a); }); @@ -132,9 +132,9 @@ define( promiseB = fakePromise(); // Issue two calls before those promises resolve - mockModelService.getModels.andReturn(promiseA); + mockModelService.getModels.and.returnValue(promiseA); decorator.getModels(['a']); - mockModelService.getModels.andReturn(promiseB); + mockModelService.getModels.and.returnValue(promiseB); decorator.getModels(['a']).then(mockCallback); // Some model providers might erroneously add undefined values @@ -147,7 +147,7 @@ define( }); // Should still have gotten the model - expect(mockCallback.mostRecentCall.args[0].a) + expect(mockCallback.calls.mostRecent().args[0].a) .toEqual({ someNewKey: "some other value" }); }); diff --git a/platform/core/test/models/MissingModelDecoratorSpec.js b/platform/core/test/models/MissingModelDecoratorSpec.js index 373f5f01af..1b62fa538c 100644 --- a/platform/core/test/models/MissingModelDecoratorSpec.js +++ b/platform/core/test/models/MissingModelDecoratorSpec.js @@ -47,7 +47,7 @@ define( testId: { someKey: "some value" } }; - mockModelService.getModels.andReturn(asPromise(testModels)); + mockModelService.getModels.and.returnValue(asPromise(testModels)); decorator = new MissingModelDecorator(mockModelService); }); diff --git a/platform/core/test/models/ModelAggregatorSpec.js b/platform/core/test/models/ModelAggregatorSpec.js index 6304882c51..49525fc09d 100644 --- a/platform/core/test/models/ModelAggregatorSpec.js +++ b/platform/core/test/models/ModelAggregatorSpec.js @@ -43,11 +43,11 @@ define( "mockProvider" + i, ["getModels"] ); - mockProvider.getModels.andReturn(models); + mockProvider.getModels.and.returnValue(models); return mockProvider; }); - mockQ.all.andReturn({ + mockQ.all.and.returnValue({ then: function (c) { return c(modelList); } diff --git a/platform/core/test/models/PersistedModelProviderSpec.js b/platform/core/test/models/PersistedModelProviderSpec.js index 03b954febf..c504518078 100644 --- a/platform/core/test/models/PersistedModelProviderSpec.js +++ b/platform/core/test/models/PersistedModelProviderSpec.js @@ -67,7 +67,7 @@ define( mockNow = jasmine.createSpy("now"); mockPersistenceService.readObject - .andCallFake(function (space, id) { + .and.callFake(function (space, id) { return mockPromise({ space: space, id: id, @@ -76,7 +76,7 @@ define( }); }); mockPersistenceService.listSpaces - .andReturn(mockPromise([SPACE])); + .and.returnValue(mockPromise([SPACE])); provider = new PersistedModelProvider( mockPersistenceService, @@ -94,9 +94,9 @@ define( }); expect(models).toEqual({ - a: { space: SPACE, id: "a", persisted: 0 }, - x: { space: SPACE, id: "x", persisted: 0 }, - zz: { space: SPACE, id: "zz", persisted: 0 } + a: { space: SPACE, id: "a", persisted: 0, modified: undefined }, + x: { space: SPACE, id: "x", persisted: 0, modified: undefined }, + zz: { space: SPACE, id: "zz", persisted: 0, modified: undefined } }); }); @@ -110,12 +110,12 @@ define( d: { name: "D" } }; - mockPersistenceService.readObject.andCallFake( + mockPersistenceService.readObject.and.callFake( function (space, id) { return mockPromise(testModels[id]); } ); - mockNow.andReturn(12321); + mockNow.and.returnValue(12321); provider.getModels(Object.keys(testModels)).then(mockCallback); diff --git a/platform/core/test/models/StaticModelProviderSpec.js b/platform/core/test/models/StaticModelProviderSpec.js index 37c79cacf0..1ded101f41 100644 --- a/platform/core/test/models/StaticModelProviderSpec.js +++ b/platform/core/test/models/StaticModelProviderSpec.js @@ -58,17 +58,17 @@ define( var mockPromise = { then: function () { return; } }; - mockQ.when.andReturn(mockPromise); + mockQ.when.and.returnValue(mockPromise); // Verify that we got the promise as the return value expect(provider.getModels(["a", "b"])).toEqual(mockPromise); // Verify that the promise has the desired models - expect(mockQ.when.callCount).toEqual(1); - expect(mockQ.when.mostRecentCall.args[0].a.name).toEqual("Thing A"); - expect(mockQ.when.mostRecentCall.args[0].a.someProperty).toEqual("Some Value A"); - expect(mockQ.when.mostRecentCall.args[0].b.name).toEqual("Thing B"); - expect(mockQ.when.mostRecentCall.args[0].b.someProperty).toEqual("Some Value B"); + expect(mockQ.when.calls.count()).toEqual(1); + expect(mockQ.when.calls.mostRecent().args[0].a.name).toEqual("Thing A"); + expect(mockQ.when.calls.mostRecent().args[0].a.someProperty).toEqual("Some Value A"); + expect(mockQ.when.calls.mostRecent().args[0].b.name).toEqual("Thing B"); + expect(mockQ.when.calls.mostRecent().args[0].b.someProperty).toEqual("Some Value B"); }); @@ -76,8 +76,8 @@ define( provider.getModels(["c"]); // Verify that the promise has the desired models - expect(mockQ.when.callCount).toEqual(1); - expect(mockQ.when.mostRecentCall.args[0].c).toBeUndefined(); + expect(mockQ.when.calls.count()).toEqual(1); + expect(mockQ.when.calls.mostRecent().args[0].c).toBeUndefined(); }); it("logs a warning when model definitions are malformed", function () { @@ -94,7 +94,7 @@ define( ], mockQ, mockLog)).toBeDefined(); // Should show warnings - expect(mockLog.warn.callCount).toEqual(5); + expect(mockLog.warn.calls.count()).toEqual(5); }); }); diff --git a/platform/core/test/objects/DomainObjectProviderSpec.js b/platform/core/test/objects/DomainObjectProviderSpec.js index 13f2466267..908aa1cffc 100644 --- a/platform/core/test/objects/DomainObjectProviderSpec.js +++ b/platform/core/test/objects/DomainObjectProviderSpec.js @@ -53,7 +53,7 @@ define( ); mockInstantiate = jasmine.createSpy("instantiate"); - mockInstantiate.andCallFake(function (model, id) { + mockInstantiate.and.callFake(function (model, id) { return new DomainObjectImpl(id, model, {}); }); @@ -65,7 +65,7 @@ define( it("requests models from the model service", function () { var ids = ["a", "b", "c"]; - mockModelService.getModels.andReturn(mockPromise({})); + mockModelService.getModels.and.returnValue(mockPromise({})); provider.getObjects(ids); expect(mockModelService.getModels).toHaveBeenCalledWith(ids); }); @@ -75,7 +75,7 @@ define( var ids = ["a", "b", "c"], model = { someKey: "some value"}, result; - mockModelService.getModels.andReturn(mockPromise({ a: model })); + mockModelService.getModels.and.returnValue(mockPromise({ a: model })); result = provider.getObjects(ids).testValue; expect(mockInstantiate).toHaveBeenCalledWith(model, 'a'); expect(result.a.getId()).toEqual("a"); diff --git a/platform/core/test/runs/TransactingMutationListenerSpec.js b/platform/core/test/runs/TransactingMutationListenerSpec.js index 240ccd51b6..139b0fa6dd 100644 --- a/platform/core/test/runs/TransactingMutationListenerSpec.js +++ b/platform/core/test/runs/TransactingMutationListenerSpec.js @@ -51,15 +51,15 @@ define( ['persist', 'refresh', 'persisted'] ); - mockTopic.andCallFake(function (t) { + mockTopic.and.callFake(function (t) { return (t === 'mutation') && mockMutationTopic; }); - mockDomainObject.getCapability.andCallFake(function (c) { + mockDomainObject.getCapability.and.callFake(function (c) { return (c === 'persistence') && mockPersistence; }); - mockPersistence.persisted.andReturn(true); + mockPersistence.persisted.and.returnValue(true); return new TransactingMutationListener( mockTopic, @@ -83,12 +83,12 @@ define( var innerVerb = isActive ? "does" : "doesn't"; beforeEach(function () { - mockTransactionService.isActive.andReturn(isActive); + mockTransactionService.isActive.and.returnValue(isActive); }); describe("and mutation occurs", function () { beforeEach(function () { - mockMutationTopic.listen.mostRecentCall + mockMutationTopic.listen.calls.mostRecent() .args[0](mockDomainObject); }); diff --git a/platform/core/test/services/InstantiateSpec.js b/platform/core/test/services/InstantiateSpec.js index b8debf2aeb..344262dfa7 100644 --- a/platform/core/test/services/InstantiateSpec.js +++ b/platform/core/test/services/InstantiateSpec.js @@ -49,12 +49,12 @@ define( ); mockCapabilityConstructor = jasmine.createSpy('capability'); mockCapabilityInstance = {}; - mockCapabilityService.getCapabilities.andReturn({ + mockCapabilityService.getCapabilities.and.returnValue({ something: mockCapabilityConstructor }); - mockCapabilityConstructor.andReturn(mockCapabilityInstance); + mockCapabilityConstructor.and.returnValue(mockCapabilityInstance); - mockIdentifierService.generate.andCallFake(function (space) { + mockIdentifierService.generate.and.callFake(function (space) { return (space ? (space + ":") : "") + "some-id-" + (idCounter += 1); }); diff --git a/platform/core/test/services/ThrottleSpec.js b/platform/core/test/services/ThrottleSpec.js index 6f91e72b55..5f4d4675db 100644 --- a/platform/core/test/services/ThrottleSpec.js +++ b/platform/core/test/services/ThrottleSpec.js @@ -34,7 +34,7 @@ define( mockTimeout = jasmine.createSpy("$timeout"); mockPromise = jasmine.createSpyObj("promise", ["then"]); mockFn = jasmine.createSpy("fn"); - mockTimeout.andReturn(mockPromise); + mockTimeout.and.returnValue(mockPromise); throttle = new Throttle(mockTimeout); }); @@ -53,18 +53,18 @@ define( throttled(); throttled(); throttled(); - expect(mockTimeout.calls.length).toEqual(1); + expect(mockTimeout.calls.count()).toEqual(1); }); it("schedules additional invocations after resolution", function () { var throttled = throttle(mockFn); throttled(); - mockTimeout.mostRecentCall.args[0](); // Resolve timeout + mockTimeout.calls.mostRecent().args[0](); // Resolve timeout throttled(); - mockTimeout.mostRecentCall.args[0](); + mockTimeout.calls.mostRecent().args[0](); throttled(); - mockTimeout.mostRecentCall.args[0](); - expect(mockTimeout.calls.length).toEqual(3); + mockTimeout.calls.mostRecent().args[0](); + expect(mockTimeout.calls.count()).toEqual(3); }); }); } diff --git a/platform/core/test/services/TopicSpec.js b/platform/core/test/services/TopicSpec.js index 36e20ec16c..6bc390b15c 100644 --- a/platform/core/test/services/TopicSpec.js +++ b/platform/core/test/services/TopicSpec.js @@ -72,7 +72,7 @@ define( var mockBadCallback = jasmine.createSpy("bad-callback"), t = topic(); - mockBadCallback.andCallFake(function () { + mockBadCallback.and.callFake(function () { throw new Error("I'm afraid I can't do that."); }); diff --git a/platform/core/test/types/TypeCapabilitySpec.js b/platform/core/test/types/TypeCapabilitySpec.js index 8d5fae8a7c..82695cd635 100644 --- a/platform/core/test/types/TypeCapabilitySpec.js +++ b/platform/core/test/types/TypeCapabilitySpec.js @@ -42,16 +42,22 @@ define( "domainObject", ["getId", "getModel", "getCapability"] ); - mockType = { someKey: "some value" }; + mockType = { + someKey: "some value", + someOtherProperty: "some other property", + aThirdProperty: "a third property" + }; - mockTypeService.getType.andReturn(mockType); - mockDomainObject.getModel.andReturn({type: "mockType"}); + mockTypeService.getType.and.returnValue(mockType); + mockDomainObject.getModel.and.returnValue({type: "mockType"}); type = new TypeCapability(mockTypeService, mockDomainObject); }); it("looks up an object's type from type service", function () { - expect(type).toEqual(mockType); + expect(type.someKey).toEqual(mockType.someKey); + expect(type.someOtherProperty).toEqual(mockType.someOtherProperty); + expect(type.aThirdProperty).toEqual(mockType.aThirdProperty); expect(mockTypeService.getType).toHaveBeenCalledWith("mockType"); }); diff --git a/platform/core/test/views/ViewCapabilitySpec.js b/platform/core/test/views/ViewCapabilitySpec.js index 99c530920a..0853d713b5 100644 --- a/platform/core/test/views/ViewCapabilitySpec.js +++ b/platform/core/test/views/ViewCapabilitySpec.js @@ -42,7 +42,7 @@ define( "domainObject", ["getId", "getModel", "getCapability"] ); - mockViewService.getViews.andReturn(views); + mockViewService.getViews.and.returnValue(views); view = new ViewCapability(mockViewService, mockDomainObject); }); diff --git a/platform/core/test/views/ViewProviderSpec.js b/platform/core/test/views/ViewProviderSpec.js index 1387d96a74..2f9e58e709 100644 --- a/platform/core/test/views/ViewProviderSpec.js +++ b/platform/core/test/views/ViewProviderSpec.js @@ -116,17 +116,17 @@ define( "type", ["instanceOf", "invoke", "getDefinition"] ); - capabilities.type.invoke.andReturn(capabilities.type); + capabilities.type.invoke.and.returnValue(capabilities.type); // Should be included when types match - capabilities.type.instanceOf.andReturn(true); + capabilities.type.instanceOf.and.returnValue(true); expect(viewProvider.getViews(mockDomainObject)) .toEqual([testView]); expect(capabilities.type.instanceOf) .toHaveBeenCalledWith(testType); // ...but not when they don't - capabilities.type.instanceOf.andReturn(false); + capabilities.type.instanceOf.and.returnValue(false); expect(viewProvider.getViews(mockDomainObject)) .toEqual([]); @@ -141,17 +141,17 @@ define( "type", ["instanceOf", "invoke", "getDefinition"] ); - capabilities.type.invoke.andReturn(capabilities.type); + capabilities.type.invoke.and.returnValue(capabilities.type); // Should be included when view keys match capabilities.type.getDefinition - .andReturn({ views: [testView.key]}); + .and.returnValue({ views: [testView.key]}); expect(viewProvider.getViews(mockDomainObject)) .toEqual([testView]); // ...but not when they don't capabilities.type.getDefinition - .andReturn({ views: ["somethingElse"]}); + .and.returnValue({ views: ["somethingElse"]}); expect(viewProvider.getViews(mockDomainObject)) .toEqual([]); }); diff --git a/platform/entanglement/test/ControlledPromise.js b/platform/entanglement/test/ControlledPromise.js index 505c78806f..3b3c39fd51 100644 --- a/platform/entanglement/test/ControlledPromise.js +++ b/platform/entanglement/test/ControlledPromise.js @@ -31,7 +31,7 @@ define( function ControlledPromise() { this.resolveHandlers = []; this.rejectHandlers = []; - spyOn(this, 'then').andCallThrough(); + spyOn(this, 'then').and.callThrough(); } diff --git a/platform/entanglement/test/DomainObjectFactory.js b/platform/entanglement/test/DomainObjectFactory.js index abae9b6624..4c45433844 100644 --- a/platform/entanglement/test/DomainObjectFactory.js +++ b/platform/entanglement/test/DomainObjectFactory.js @@ -85,7 +85,7 @@ define( * * @returns {string} id */ - domainObject.getId.andCallFake(function () { + domainObject.getId.and.callFake(function () { return domainObject.id; }); @@ -94,7 +94,7 @@ define( * * @returns {object} model */ - domainObject.getModel.andCallFake(function () { + domainObject.getModel.and.callFake(function () { return domainObject.model; }); @@ -106,7 +106,7 @@ define( * @param {string} capability name of the capability to return. * @returns {*} capability object */ - domainObject.getCapability.andCallFake(function (capability) { + domainObject.getCapability.and.callFake(function (capability) { if (config.capabilities.hasOwnProperty(capability)) { return config.capabilities[capability]; } @@ -120,7 +120,7 @@ define( * existence of. * @returns {boolean} */ - domainObject.hasCapability.andCallFake(function (capability) { + domainObject.hasCapability.and.callFake(function (capability) { return config.capabilities.hasOwnProperty(capability); }); @@ -133,7 +133,7 @@ define( * @param {...*} params to pass to the capability's `invoke` method. * @returns {*} result whatever was returned by `invoke`. */ - domainObject.useCapability.andCallFake(function (capability) { + domainObject.useCapability.and.callFake(function (capability) { if (config.capabilities.hasOwnProperty(capability)) { if (!config.capabilities[capability].invoke) { throw new Error( diff --git a/platform/entanglement/test/actions/AbstractComposeActionSpec.js b/platform/entanglement/test/actions/AbstractComposeActionSpec.js index b7001824f4..e5895ecd81 100644 --- a/platform/entanglement/test/actions/AbstractComposeActionSpec.js +++ b/platform/entanglement/test/actions/AbstractComposeActionSpec.js @@ -71,7 +71,7 @@ define( selectedObjectContextCapability .getParent - .andReturn(currentParent); + .and.returnValue(currentParent); newParent = domainObjectFactory({ name: 'newParent' @@ -91,11 +91,11 @@ define( ] ); - policyService.allow.andReturn(true); + policyService.allow.and.returnValue(true); locationService .getLocationFromUser - .andReturn(locationServicePromise); + .and.returnValue(locationServicePromise); composeService = new MockCopyService(); }); @@ -165,7 +165,7 @@ define( it("copies object to selected location", function () { locationServicePromise .then - .mostRecentCall + .calls.mostRecent() .args[0](newParent); expect(composeService.perform) @@ -177,20 +177,20 @@ define( beforeEach(function () { validator = locationService.getLocationFromUser - .mostRecentCall.args[2]; - composeService.validate.andReturn(true); - policyService.allow.andReturn(true); + .calls.mostRecent().args[2]; + composeService.validate.and.returnValue(true); + policyService.allow.and.returnValue(true); }); it("is sensitive to policy", function () { expect(validator()).toBe(true); - policyService.allow.andReturn(false); + policyService.allow.and.returnValue(false); expect(validator()).toBe(false); }); it("is sensitive to service-specific validation", function () { expect(validator()).toBe(true); - composeService.validate.andReturn(false); + composeService.validate.and.returnValue(false); expect(validator()).toBe(false); }); diff --git a/platform/entanglement/test/actions/CopyActionSpec.js b/platform/entanglement/test/actions/CopyActionSpec.js index 0330fae052..2a28fcae0e 100644 --- a/platform/entanglement/test/actions/CopyActionSpec.js +++ b/platform/entanglement/test/actions/CopyActionSpec.js @@ -55,7 +55,7 @@ define( 'policyService', ['allow'] ); - policyService.allow.andReturn(true); + policyService.allow.and.returnValue(true); selectedObjectContextCapability = jasmine.createSpyObj( 'selectedObjectContextCapability', @@ -80,7 +80,7 @@ define( selectedObjectContextCapability .getParent - .andReturn(currentParent); + .and.returnValue(currentParent); newParent = domainObjectFactory({ name: 'newParent' @@ -107,26 +107,26 @@ define( ] ); - abstractComposePromise.then.andCallFake(function (success, error, notify) { + abstractComposePromise.then.and.callFake(function (success, error, notify) { notify(progress); success(domainObject); }); - locationServicePromise.then.andCallFake(function (callback) { + locationServicePromise.then.and.callFake(function (callback) { callback(newParent); return abstractComposePromise; }); locationService .getLocationFromUser - .andReturn(locationServicePromise); + .and.returnValue(locationServicePromise); dialogService = jasmine.createSpyObj('dialogService', ['showBlockingMessage'] ); mockDialog = jasmine.createSpyObj("dialog", ["dismiss"]); - dialogService.showBlockingMessage.andReturn(mockDialog); + dialogService.showBlockingMessage.and.returnValue(mockDialog); notification = jasmine.createSpyObj('notification', ['dismiss', 'model'] @@ -136,7 +136,7 @@ define( ['notify', 'info'] ); - notificationService.notify.andReturn(notification); + notificationService.notify.and.returnValue(notification); mockLog = jasmine.createSpyObj('log', ['error']); @@ -167,7 +167,7 @@ define( describe("when performed it", function () { beforeEach(function () { - spyOn(copyAction, 'progress').andCallThrough(); + spyOn(copyAction, 'progress').and.callThrough(); copyAction.perform(); }); @@ -189,7 +189,7 @@ define( it("copies object to selected location", function () { locationServicePromise .then - .mostRecentCall + .calls.mostRecent() .args[0](newParent); expect(copyService.perform) diff --git a/platform/entanglement/test/actions/GoToOriginalActionSpec.js b/platform/entanglement/test/actions/GoToOriginalActionSpec.js index a0f2c98827..18188198a7 100644 --- a/platform/entanglement/test/actions/GoToOriginalActionSpec.js +++ b/platform/entanglement/test/actions/GoToOriginalActionSpec.js @@ -47,9 +47,9 @@ define( ['perform', 'getActions'] ); originalPromise = new ControlledPromise(); - mockLocationCapability.getOriginal.andReturn(originalPromise); - mockLocationCapability.isLink.andReturn(true); - mockLocationCapability.isOriginal.andCallFake(function () { + mockLocationCapability.getOriginal.and.returnValue(originalPromise); + mockLocationCapability.isLink.and.returnValue(true); + mockLocationCapability.isOriginal.and.callFake(function () { return !mockLocationCapability.isLink(); }); testContext = { @@ -74,7 +74,7 @@ define( }); it("is not applicable to originals", function () { - mockLocationCapability.isLink.andReturn(false); + mockLocationCapability.isLink.and.returnValue(false); expect(GoToOriginalAction.appliesTo(testContext)) .toBeFalsy(); }); diff --git a/platform/entanglement/test/actions/LinkActionSpec.js b/platform/entanglement/test/actions/LinkActionSpec.js index e62bf79cb7..3d457eada1 100644 --- a/platform/entanglement/test/actions/LinkActionSpec.js +++ b/platform/entanglement/test/actions/LinkActionSpec.js @@ -47,7 +47,7 @@ define( 'policyService', ['allow'] ); - policyService.allow.andReturn(true); + policyService.allow.and.returnValue(true); selectedObjectContextCapability = jasmine.createSpyObj( 'selectedObjectContextCapability', @@ -72,7 +72,7 @@ define( selectedObjectContextCapability .getParent - .andReturn(currentParent); + .and.returnValue(currentParent); newParent = domainObjectFactory({ name: 'newParent' @@ -94,7 +94,7 @@ define( locationService .getLocationFromUser - .andReturn(locationServicePromise); + .and.returnValue(locationServicePromise); linkService = new MockLinkService(); }); @@ -141,7 +141,7 @@ define( it("links object to selected location", function () { locationServicePromise .then - .mostRecentCall + .calls.mostRecent() .args[0](newParent); expect(linkService.perform) diff --git a/platform/entanglement/test/actions/MoveActionSpec.js b/platform/entanglement/test/actions/MoveActionSpec.js index 955599e97e..8303820c21 100644 --- a/platform/entanglement/test/actions/MoveActionSpec.js +++ b/platform/entanglement/test/actions/MoveActionSpec.js @@ -47,7 +47,7 @@ define( 'policyService', ['allow'] ); - policyService.allow.andReturn(true); + policyService.allow.and.returnValue(true); selectedObjectContextCapability = jasmine.createSpyObj( 'selectedObjectContextCapability', @@ -72,7 +72,7 @@ define( selectedObjectContextCapability .getParent - .andReturn(currentParent); + .and.returnValue(currentParent); newParent = domainObjectFactory({ name: 'newParent' @@ -94,7 +94,7 @@ define( locationService .getLocationFromUser - .andReturn(locationServicePromise); + .and.returnValue(locationServicePromise); moveService = new MockMoveService(); }); @@ -141,7 +141,7 @@ define( it("moves object to selected location", function () { locationServicePromise .then - .mostRecentCall + .calls.mostRecent() .args[0](newParent); expect(moveService.perform) diff --git a/platform/entanglement/test/actions/SetPrimaryLocationActionSpec.js b/platform/entanglement/test/actions/SetPrimaryLocationActionSpec.js index 5eba177b93..5c4cff84e8 100644 --- a/platform/entanglement/test/actions/SetPrimaryLocationActionSpec.js +++ b/platform/entanglement/test/actions/SetPrimaryLocationActionSpec.js @@ -43,7 +43,7 @@ define( ['setPrimaryLocation', 'getContextualLocation'] ); - mockLocationCapability.getContextualLocation.andReturn(testId); + mockLocationCapability.getContextualLocation.and.returnValue(testId); testContext = { domainObject: domainObjectFactory({ @@ -58,7 +58,7 @@ define( it("is applicable to objects with no location specified", function () { expect(SetPrimaryLocation.appliesTo(testContext)) .toBe(true); - testContext.domainObject.getModel.andReturn({ + testContext.domainObject.getModel.and.returnValue({ location: "something", name: "some name" }); diff --git a/platform/entanglement/test/capabilities/LocationCapabilitySpec.js b/platform/entanglement/test/capabilities/LocationCapabilitySpec.js index f62e638360..118c61d335 100644 --- a/platform/entanglement/test/capabilities/LocationCapabilitySpec.js +++ b/platform/entanglement/test/capabilities/LocationCapabilitySpec.js @@ -61,7 +61,7 @@ define( jasmine.createSpyObj("objectService", ["getObjects"]); mutationPromise = new ControlledPromise(); - domainObject.capabilities.mutation.invoke.andCallFake( + domainObject.capabilities.mutation.invoke.and.callFake( function (mutator) { return mutationPromise.then(function () { mutator(domainObject.model); @@ -114,10 +114,10 @@ define( mockCallback; function resolvePromises() { - if (mockQ.when.calls.length > 0) { - qPromise.resolve(mockQ.when.mostRecentCall.args[0]); + if (mockQ.when.calls.count() > 0) { + qPromise.resolve(mockQ.when.calls.mostRecent().args[0]); } - if (mockObjectService.getObjects.calls.length > 0) { + if (mockObjectService.getObjects.calls.count() > 0) { objectPromise.resolve(originalObjects); } } @@ -129,11 +129,11 @@ define( testObject: domainObjectFactory() }; - mockInjector.get.andCallFake(function (key) { + mockInjector.get.and.callFake(function (key) { return key === 'objectService' && mockObjectService; }); - mockObjectService.getObjects.andReturn(objectPromise); - mockQ.when.andReturn(qPromise); + mockObjectService.getObjects.and.returnValue(objectPromise); + mockQ.when.and.returnValue(qPromise); mockCallback = jasmine.createSpy('callback'); }); diff --git a/platform/entanglement/test/policies/CopyPolicySpec.js b/platform/entanglement/test/policies/CopyPolicySpec.js index 2c9dc3c76b..1ebd3e6a74 100644 --- a/platform/entanglement/test/policies/CopyPolicySpec.js +++ b/platform/entanglement/test/policies/CopyPolicySpec.js @@ -43,12 +43,12 @@ define([ capabilities: { type: mockType } }); - mockType.hasFeature.andCallFake(function (feature) { + mockType.hasFeature.and.callFake(function (feature) { return feature === 'creation'; }); mockAction = jasmine.createSpyObj('action', ['getMetadata']); - mockAction.getMetadata.andReturn(testMetadata); + mockAction.getMetadata.and.returnValue(testMetadata); testContext = { domainObject: mockDomainObject }; @@ -62,7 +62,7 @@ define([ describe("when an object is non-creatable", function () { beforeEach(function () { - mockType.hasFeature.andReturn(false); + mockType.hasFeature.and.returnValue(false); }); it("disallows the action", function () { @@ -84,7 +84,7 @@ define([ it("simply allows the action", function () { expect(policy.allow(mockAction, testContext)).toBe(true); - mockType.hasFeature.andReturn(false); + mockType.hasFeature.and.returnValue(false); expect(policy.allow(mockAction, testContext)).toBe(true); }); }); diff --git a/platform/entanglement/test/policies/CrossSpacePolicySpec.js b/platform/entanglement/test/policies/CrossSpacePolicySpec.js index 48b8871079..71d2eead73 100644 --- a/platform/entanglement/test/policies/CrossSpacePolicySpec.js +++ b/platform/entanglement/test/policies/CrossSpacePolicySpec.js @@ -39,7 +39,7 @@ define( 'persistence', ['getSpace'] ); - mockPersistence.getSpace.andReturn(space); + mockPersistence.getSpace.and.returnValue(space); return domainObjectFactory({ id: space + ":foo", model: {}, @@ -56,7 +56,7 @@ define( 'action', ['getMetadata'] ); - mockAction.getMetadata.andReturn(testActionMetadata); + mockAction.getMetadata.and.returnValue(testActionMetadata); sameSpaceContext = { domainObject: makeObject('a'), diff --git a/platform/entanglement/test/policies/MovePolicySpec.js b/platform/entanglement/test/policies/MovePolicySpec.js index 3c337d4f3c..75107acf65 100644 --- a/platform/entanglement/test/policies/MovePolicySpec.js +++ b/platform/entanglement/test/policies/MovePolicySpec.js @@ -59,17 +59,17 @@ define([ } }); - mockContextCapability.getParent.andReturn(mockParent); + mockContextCapability.getParent.and.returnValue(mockParent); - mockType.hasFeature.andCallFake(function (feature) { + mockType.hasFeature.and.callFake(function (feature) { return feature === 'creation'; }); - mockParentType.hasFeature.andCallFake(function (feature) { + mockParentType.hasFeature.and.callFake(function (feature) { return feature === 'creation'; }); mockAction = jasmine.createSpyObj('action', ['getMetadata']); - mockAction.getMetadata.andReturn(testMetadata); + mockAction.getMetadata.and.returnValue(testMetadata); testContext = { domainObject: mockDomainObject }; @@ -83,7 +83,7 @@ define([ describe("when an object is non-modifiable", function () { beforeEach(function () { - mockType.hasFeature.andReturn(false); + mockType.hasFeature.and.returnValue(false); }); it("disallows the action", function () { @@ -93,7 +93,7 @@ define([ describe("when a parent is non-modifiable", function () { beforeEach(function () { - mockParentType.hasFeature.andReturn(false); + mockParentType.hasFeature.and.returnValue(false); }); it("disallows the action", function () { @@ -115,9 +115,9 @@ define([ it("simply allows the action", function () { expect(policy.allow(mockAction, testContext)).toBe(true); - mockType.hasFeature.andReturn(false); + mockType.hasFeature.and.returnValue(false); expect(policy.allow(mockAction, testContext)).toBe(true); - mockParentType.hasFeature.andReturn(false); + mockParentType.hasFeature.and.returnValue(false); expect(policy.allow(mockAction, testContext)).toBe(true); }); }); diff --git a/platform/entanglement/test/services/CopyServiceSpec.js b/platform/entanglement/test/services/CopyServiceSpec.js index 9de0131c8b..97bda1af8c 100644 --- a/platform/entanglement/test/services/CopyServiceSpec.js +++ b/platform/entanglement/test/services/CopyServiceSpec.js @@ -38,7 +38,7 @@ define( return synchronousPromise(callback(value)); } }; - spyOn(promise, 'then').andCallThrough(); + spyOn(promise, 'then').and.callThrough(); return promise; } @@ -109,12 +109,12 @@ define( }); it("and returns false", function () { - policyService.allow.andReturn(false); + policyService.allow.and.returnValue(false); expect(validate()).toBe(false); }); it("and returns true", function () { - policyService.allow.andReturn(true); + policyService.allow.and.returnValue(true); expect(validate()).toBe(true); }); }); @@ -139,7 +139,7 @@ define( beforeEach(function () { createObjectPromise = synchronousPromise(undefined); - policyService.allow.andReturn(true); + policyService.allow.and.returnValue(true); persistObjectPromise = synchronousPromise(undefined); @@ -152,26 +152,26 @@ define( "persistenceCapability", ["persist", "getSpace"] ); - persistenceCapability.persist.andReturn(persistObjectPromise); + persistenceCapability.persist.and.returnValue(persistObjectPromise); compositionCapability = jasmine.createSpyObj( 'compositionCapability', ['invoke', 'add'] ); - compositionCapability.add.andCallFake(synchronousPromise); + compositionCapability.add.and.callFake(synchronousPromise); locationCapability = jasmine.createSpyObj( 'locationCapability', ['isLink'] ); - locationCapability.isLink.andReturn(false); + locationCapability.isLink.and.returnValue(false); mockDeferred = jasmine.createSpyObj( 'mockDeferred', ['notify', 'resolve', 'reject'] ); - mockDeferred.notify.andCallFake(function () {}); - mockDeferred.resolve.andCallFake(function (value) { + mockDeferred.notify.and.callFake(function () {}); + mockDeferred.resolve.and.callFake(function (value) { resolvedValue = value; }); mockDeferred.promise = { @@ -184,9 +184,9 @@ define( 'mockQ', ['when', 'all', 'reject', 'defer'] ); - mockQ.reject.andReturn(synchronousPromise(undefined)); - mockQ.when.andCallFake(synchronousPromise); - mockQ.all.andCallFake(function (promises) { + mockQ.reject.and.returnValue(synchronousPromise(undefined)); + mockQ.when.and.callFake(synchronousPromise); + mockQ.all.and.callFake(function (promises) { var result = {}; Object.keys(promises).forEach(function (k) { promises[k].then(function (v) { @@ -195,7 +195,7 @@ define( }); return synchronousPromise(result); }); - mockQ.defer.andReturn(mockDeferred); + mockQ.defer.and.returnValue(mockDeferred); }); @@ -241,7 +241,7 @@ define( } }); - instantiationCapability.invoke.andCallFake( + instantiationCapability.invoke.and.callFake( function (model) { objectCopy.model = model; return objectCopy; @@ -260,7 +260,7 @@ define( }); it("deep clones object model", function () { - var newModel = copyFinished.calls[0].args[0].getModel(); + var newModel = copyFinished.calls.all()[0].args[0].getModel(); expect(newModel).toEqual(object.model); expect(newModel).not.toBe(object.model); }); @@ -282,7 +282,7 @@ define( var invocationCount = 0, objectClones; - instantiationCapability.invoke.andCallFake( + instantiationCapability.invoke.and.callFake( function (model) { var cloneToReturn = objectClones[invocationCount++]; cloneToReturn.model = model; @@ -332,7 +332,7 @@ define( compositionCapability .invoke - .andReturn(synchronousPromise([childObject])); + .and.returnValue(synchronousPromise([childObject])); object = domainObjectFactory({ name: 'some object', @@ -390,7 +390,7 @@ define( describe("when cloning non-creatable objects", function () { beforeEach(function () { - policyService.allow.andCallFake(function (category) { + policyService.allow.and.callFake(function (category) { //Return false for 'creation' policy return category !== 'creation'; }); @@ -400,7 +400,7 @@ define( copyResult.then(copyFinished); }); it ("creates link instead of clone", function () { - var copiedObject = copyFinished.calls[0].args[0]; + var copiedObject = copyFinished.calls.all()[0].args[0]; expect(copiedObject).toBe(object); expect(compositionCapability.add) .toHaveBeenCalledWith(copiedObject); @@ -408,6 +408,10 @@ define( }); describe("when provided a filtering function", function () { + beforeEach(function () { + copyFinished = jasmine.createSpy('copyFinished'); + }); + function accept() { return true; } @@ -419,7 +423,7 @@ define( "rejected by the filter", function () { copyService.perform(object, newParent, reject) .then(copyFinished); - expect(copyFinished.mostRecentCall.args[0]) + expect(copyFinished.calls.mostRecent().args[0]) .toBe(object); }); @@ -427,7 +431,7 @@ define( "accepted by the filter", function () { copyService.perform(object, newParent, accept) .then(copyFinished); - expect(copyFinished.mostRecentCall.args[0]) + expect(copyFinished.calls.mostRecent().args[0]) .not.toBe(object); }); }); @@ -454,7 +458,7 @@ define( } }); - instantiationCapability.invoke.andReturn(object); + instantiationCapability.invoke.and.returnValue(object); }); it("throws an error", function () { @@ -466,9 +470,9 @@ define( } spyOn(service, "validate"); - service.validate.andReturn(true); + service.validate.and.returnValue(true); expect(perform).not.toThrow(); - service.validate.andReturn(false); + service.validate.and.returnValue(false); expect(perform).toThrow(); }); }); diff --git a/platform/entanglement/test/services/CopyTaskSpec.js b/platform/entanglement/test/services/CopyTaskSpec.js index 7d5429fc83..5cd5c54162 100644 --- a/platform/entanglement/test/services/CopyTaskSpec.js +++ b/platform/entanglement/test/services/CopyTaskSpec.js @@ -74,14 +74,14 @@ define( }); mockCapabilities.persistence.persist - .andReturn(synchronousPromise(true)); - mockCapabilities.composition.add.andCallFake(function (obj) { + .and.returnValue(synchronousPromise(true)); + mockCapabilities.composition.add.and.callFake(function (obj) { return synchronousPromise(obj); }); mockCapabilities.composition.invoke - .andReturn(synchronousPromise(mockChildren)); + .and.returnValue(synchronousPromise(mockChildren)); mockCapabilities.instantiation.invoke - .andCallFake(function (model) { + .and.callFake(function (model) { var id = "some-id-" + counter; cloneIds[model.originalId] = id; counter += 1; @@ -123,11 +123,11 @@ define( ['notify', 'resolve', 'reject'] ); - mockFilter.andReturn(true); + mockFilter.and.returnValue(true); - mockQ.when.andCallFake(synchronousPromise); - mockQ.defer.andReturn(mockDeferred); - mockQ.all.andCallFake(function (promises) { + mockQ.when.and.callFake(synchronousPromise); + mockQ.defer.and.returnValue(mockDeferred); + mockQ.all.and.callFake(function (promises) { return synchronousPromise(promises.map(function (promise) { var value; promise.then(function (v) { @@ -137,7 +137,7 @@ define( })); }); - mockDeferred.resolve.andCallFake(function (value) { + mockDeferred.resolve.and.callFake(function (value) { mockDeferred.promise = synchronousPromise(value); }); @@ -209,7 +209,7 @@ define( model: composingObjectModel }); - mockComposingObject.capabilities.composition.invoke.andReturn([mockDomainObject, mockDomainObjectB]); + mockComposingObject.capabilities.composition.invoke.and.returnValue([mockDomainObject, mockDomainObjectB]); task = new CopyTask( mockComposingObject, mockParentObject, @@ -235,13 +235,13 @@ define( childC_ID = task.clones[3].getId(), childD_ID = task.clones[4].getId(); - expect(domainObjectClone.model.someArr[0]).toNotBe(domainObjectBClone.model.someArr[0]); + expect(domainObjectClone.model.someArr[0]).not.toBe(domainObjectBClone.model.someArr[0]); expect(domainObjectClone.model.someArr[0]).toBe(childA_ID); expect(domainObjectBClone.model.someArr[0]).toBe(childC_ID); - expect(domainObjectClone.model.someArr[1]).toNotBe(domainObjectBClone.model.someArr[1]); + expect(domainObjectClone.model.someArr[1]).not.toBe(domainObjectBClone.model.someArr[1]); expect(domainObjectClone.model.someArr[1]).toBe(childB_ID); expect(domainObjectBClone.model.someArr[1]).toBe(childD_ID); - expect(domainObjectClone.model.someObj.someProperty).toNotBe(domainObjectBClone.model.someObj.someProperty); + expect(domainObjectClone.model.someObj.someProperty).not.toBe(domainObjectBClone.model.someObj.someProperty); expect(domainObjectClone.model.someObj.someProperty).toBe(childB_ID); expect(domainObjectBClone.model.someObj.someProperty).toBe(childD_ID); diff --git a/platform/entanglement/test/services/LinkServiceSpec.js b/platform/entanglement/test/services/LinkServiceSpec.js index 9fede61be7..d24e4eb576 100644 --- a/platform/entanglement/test/services/LinkServiceSpec.js +++ b/platform/entanglement/test/services/LinkServiceSpec.js @@ -39,7 +39,7 @@ define( 'policyService', ['allow'] ); - mockPolicyService.allow.andReturn(true); + mockPolicyService.allow.and.returnValue(true); linkService = new LinkService(mockPolicyService); }); @@ -92,7 +92,7 @@ define( }); object.id = 'abc'; parentCandidate.id = 'xyz'; - parentCandidate.hasCapability.andCallFake(function (c) { + parentCandidate.hasCapability.and.callFake(function (c) { return c !== 'composition'; }); expect(validate()).toBe(false); @@ -119,13 +119,13 @@ define( }); it("and returns false", function () { - mockPolicyService.allow.andReturn(true); + mockPolicyService.allow.and.returnValue(true); expect(validate()).toBe(true); expect(mockPolicyService.allow).toHaveBeenCalled(); }); it("and returns true", function () { - mockPolicyService.allow.andReturn(false); + mockPolicyService.allow.and.returnValue(false); expect(validate()).toBe(false); expect(mockPolicyService.allow).toHaveBeenCalled(); }); @@ -149,8 +149,8 @@ define( 'compositionCapability', ['invoke', 'add'] ); - compositionCapability.invoke.andReturn(compositionPromise); - compositionCapability.add.andReturn(addPromise); + compositionCapability.invoke.and.returnValue(compositionPromise); + compositionCapability.add.and.returnValue(addPromise); parentModel = { composition: [] }; @@ -205,9 +205,9 @@ define( } spyOn(linkService, 'validate'); - linkService.validate.andReturn(true); + linkService.validate.and.returnValue(true); expect(perform).not.toThrow(); - linkService.validate.andReturn(false); + linkService.validate.and.returnValue(false); expect(perform).toThrow(); }); }); diff --git a/platform/entanglement/test/services/LocatingCreationDecoratorSpec.js b/platform/entanglement/test/services/LocatingCreationDecoratorSpec.js index 957eb4f8bb..0b5023ea8b 100644 --- a/platform/entanglement/test/services/LocatingCreationDecoratorSpec.js +++ b/platform/entanglement/test/services/LocatingCreationDecoratorSpec.js @@ -46,8 +46,8 @@ define( 'domainObject', ['getCapability', 'getId', 'getModel', 'hasCapability', 'useCapability'] ); - mockCreationService.createObject.andReturn(mockPromise); - mockParent.getId.andReturn('test-id'); + mockCreationService.createObject.and.returnValue(mockPromise); + mockParent.getId.and.returnValue('test-id'); decorator = new LocatingCreationDecorator(mockCreationService); }); diff --git a/platform/entanglement/test/services/LocatingObjectDecoratorSpec.js b/platform/entanglement/test/services/LocatingObjectDecoratorSpec.js index d4df716193..bbaceee3ac 100644 --- a/platform/entanglement/test/services/LocatingObjectDecoratorSpec.js +++ b/platform/entanglement/test/services/LocatingObjectDecoratorSpec.js @@ -63,8 +63,8 @@ define( mockObjectService = jasmine.createSpyObj("objectService", ["getObjects"]); - mockQ.when.andCallFake(testPromise); - mockQ.all.andCallFake(function (promises) { + mockQ.when.and.callFake(testPromise); + mockQ.all.and.callFake(function (promises) { var result = {}; Object.keys(promises).forEach(function (k) { promises[k].then(function (v) { @@ -74,7 +74,7 @@ define( return testPromise(result); }); - mockObjectService.getObjects.andReturn(testPromise(testObjects)); + mockObjectService.getObjects.and.returnValue(testPromise(testObjects)); mockCallback = jasmine.createSpy("callback"); @@ -83,8 +83,8 @@ define( "domainObject-" + id, ["getId", "getModel", "getCapability"] ); - testObjects[id].getId.andReturn(id); - testObjects[id].getModel.andReturn(testModels[id]); + testObjects[id].getId.and.returnValue(id); + testObjects[id].getModel.and.returnValue(testModels[id]); }); decorator = new LocatingObjectDecorator( @@ -98,7 +98,7 @@ define( decorator.getObjects(['b', 'c']).then(mockCallback); expect(mockCallback).toHaveBeenCalled(); - var callbackObj = mockCallback.mostRecentCall.args[0]; + var callbackObj = mockCallback.calls.mostRecent().args[0]; expect(testObjects.b.getCapability('context')).not.toBeDefined(); expect(testObjects.c.getCapability('context')).not.toBeDefined(); expect(callbackObj.b.getCapability('context')).toBeDefined(); diff --git a/platform/entanglement/test/services/LocationServiceSpec.js b/platform/entanglement/test/services/LocationServiceSpec.js index ce35103825..47ae9e30c9 100644 --- a/platform/entanglement/test/services/LocationServiceSpec.js +++ b/platform/entanglement/test/services/LocationServiceSpec.js @@ -46,8 +46,8 @@ define( 'chainedPromise', ['then'] ); - dialogServicePromise.then.andReturn(chainedPromise); - dialogService.getUserInput.andReturn(dialogServicePromise); + dialogServicePromise.then.and.returnValue(chainedPromise); + dialogService.getUserInput.and.returnValue(dialogServicePromise); locationService = new LocationService(dialogService); }); @@ -75,11 +75,11 @@ define( ); formStructure = dialogService .getUserInput - .mostRecentCall + .calls.mostRecent() .args[0]; formState = dialogService .getUserInput - .mostRecentCall + .calls.mostRecent() .args[1]; }); @@ -131,7 +131,7 @@ define( beforeEach(function () { resolver = - dialogServicePromise.then.mostRecentCall.args[0]; + dialogServicePromise.then.calls.mostRecent().args[0]; selectedLocation = { key: "i'm a location key" }; dialogResult = { diff --git a/platform/entanglement/test/services/MockCopyService.js b/platform/entanglement/test/services/MockCopyService.js index d61d8ae51d..1a7aaaf0df 100644 --- a/platform/entanglement/test/services/MockCopyService.js +++ b/platform/entanglement/test/services/MockCopyService.js @@ -37,7 +37,7 @@ define( * var copyService = new MockCopyService(); * * // validate is a standard jasmine spy. - * copyService.validate.andReturn(true); + * copyService.validate.and.returnValue(true); * var isValid = copyService.validate(object, parentCandidate); * expect(isValid).toBe(true); * @@ -45,7 +45,7 @@ define( * var whenCopied = jasmine.createSpy('whenCopied'); * copyService.perform(object, parentObject).then(whenCopied); * expect(whenCopied).not.toHaveBeenCalled(); - * copyService.perform.mostRecentCall.resolve('someArg'); + * copyService.perform.calls.mostRecent().resolve('someArg'); * expect(whenCopied).toHaveBeenCalledWith('someArg'); * ``` */ @@ -60,7 +60,7 @@ define( ] ); - mockCopyService.perform.andCallFake(function () { + mockCopyService.perform.and.callFake(function () { var performPromise, callExtensions, spy; @@ -73,7 +73,7 @@ define( callExtensions = { promise: performPromise, resolve: function (resolveWith) { - performPromise.then.calls.forEach(function (call) { + performPromise.then.calls.all().forEach(function (call) { call.args[0](resolveWith); }); } @@ -82,8 +82,8 @@ define( spy = this.perform; Object.keys(callExtensions).forEach(function (key) { - spy.mostRecentCall[key] = callExtensions[key]; - spy.calls[spy.calls.length - 1][key] = callExtensions[key]; + spy.calls.mostRecent()[key] = callExtensions[key]; + spy.calls.all()[spy.calls.count() - 1][key] = callExtensions[key]; }); return performPromise; diff --git a/platform/entanglement/test/services/MockLinkService.js b/platform/entanglement/test/services/MockLinkService.js index 2ee1eed416..7811d2d2d3 100644 --- a/platform/entanglement/test/services/MockLinkService.js +++ b/platform/entanglement/test/services/MockLinkService.js @@ -40,7 +40,7 @@ define( * var linkService = new MockLinkService(); * * // validate is a standard jasmine spy. - * linkService.validate.andReturn(true); + * linkService.validate.and.returnValue(true); * var isValid = linkService.validate(object, parentObject); * expect(isValid).toBe(true); * @@ -48,7 +48,7 @@ define( * var whenLinked = jasmine.createSpy('whenLinked'); * linkService.perform(object, parentObject).then(whenLinked); * expect(whenLinked).not.toHaveBeenCalled(); - * linkService.perform.mostRecentCall.promise.resolve('someArg'); + * linkService.perform.calls.mostRecent().promise.resolve('someArg'); * expect(whenLinked).toHaveBeenCalledWith('someArg'); * ``` */ @@ -63,11 +63,11 @@ define( ] ); - mockLinkService.perform.andCallFake(function (object) { + mockLinkService.perform.and.callFake(function (object) { var performPromise = new ControlledPromise(); - this.perform.mostRecentCall.promise = performPromise; - this.perform.calls[this.perform.calls.length - 1].promise = + this.perform.calls.mostRecent().promise = performPromise; + this.perform.calls.all()[this.perform.calls.count() - 1].promise = performPromise; return performPromise.then(function (overrideObject) { diff --git a/platform/entanglement/test/services/MockMoveService.js b/platform/entanglement/test/services/MockMoveService.js index 92af19ab23..38f2059ae9 100644 --- a/platform/entanglement/test/services/MockMoveService.js +++ b/platform/entanglement/test/services/MockMoveService.js @@ -37,7 +37,7 @@ define( * var moveService = new MockMoveService(); * * // validate is a standard jasmine spy. - * moveService.validate.andReturn(true); + * moveService.validate.and.returnValue(true); * var isValid = moveService.validate(object, parentCandidate); * expect(isValid).toBe(true); * @@ -45,7 +45,7 @@ define( * var whenCopied = jasmine.createSpy('whenCopied'); * moveService.perform(object, parentObject).then(whenCopied); * expect(whenCopied).not.toHaveBeenCalled(); - * moveService.perform.mostRecentCall.resolve('someArg'); + * moveService.perform.calls.mostRecent().resolve('someArg'); * expect(whenCopied).toHaveBeenCalledWith('someArg'); * ``` */ @@ -60,7 +60,7 @@ define( ] ); - mockMoveService.perform.andCallFake(function () { + mockMoveService.perform.and.callFake(function () { var performPromise, callExtensions, spy; @@ -73,7 +73,7 @@ define( callExtensions = { promise: performPromise, resolve: function (resolveWith) { - performPromise.then.calls.forEach(function (call) { + performPromise.then.calls.all().forEach(function (call) { call.args[0](resolveWith); }); } @@ -82,8 +82,8 @@ define( spy = this.perform; Object.keys(callExtensions).forEach(function (key) { - spy.mostRecentCall[key] = callExtensions[key]; - spy.calls[spy.calls.length - 1][key] = callExtensions[key]; + spy.calls.mostRecent()[key] = callExtensions[key]; + spy.calls.all()[spy.calls.count() - 1][key] = callExtensions[key]; }); return performPromise; diff --git a/platform/entanglement/test/services/MoveServiceSpec.js b/platform/entanglement/test/services/MoveServiceSpec.js index b1e5d5761d..7e1cdb1905 100644 --- a/platform/entanglement/test/services/MoveServiceSpec.js +++ b/platform/entanglement/test/services/MoveServiceSpec.js @@ -66,7 +66,7 @@ define( id: 'b' }); - objectContextCapability.getParent.andReturn(currentParent); + objectContextCapability.getParent.and.returnValue(currentParent); parentCandidate = domainObjectFactory({ name: 'parentCandidate', @@ -81,7 +81,7 @@ define( ['allow'] ); linkService = new MockLinkService(); - policyService.allow.andReturn(true); + policyService.allow.and.returnValue(true); moveService = new MoveService(policyService, linkService); }); @@ -129,12 +129,12 @@ define( }); it("and returns false", function () { - policyService.allow.andReturn(false); + policyService.allow.and.returnValue(false); expect(validate()).toBe(false); }); it("and returns true", function () { - policyService.allow.andReturn(true); + policyService.allow.and.returnValue(true); expect(validate()).toBe(true); }); }); @@ -167,7 +167,7 @@ define( locationPromise = new ControlledPromise(); locationCapability.setPrimaryLocation - .andReturn(locationPromise); + .and.returnValue(locationPromise); object = domainObjectFactory({ name: 'object', @@ -190,7 +190,7 @@ define( }); it("waits for result of link", function () { - expect(linkService.perform.mostRecentCall.promise.then) + expect(linkService.perform.calls.mostRecent().promise.then) .toHaveBeenCalledWith(jasmine.any(Function)); }); @@ -200,18 +200,18 @@ define( } spyOn(moveService, "validate"); - moveService.validate.andReturn(true); + moveService.validate.and.returnValue(true); expect(perform).not.toThrow(); - moveService.validate.andReturn(false); + moveService.validate.and.returnValue(false); expect(perform).toThrow(); }); describe("when moving an original", function () { beforeEach(function () { locationCapability.getContextualLocation - .andReturn('new-location'); - locationCapability.isOriginal.andReturn(true); - linkService.perform.mostRecentCall.promise.resolve(); + .and.returnValue('new-location'); + locationCapability.isOriginal.and.returnValue(true); + linkService.perform.calls.mostRecent().promise.resolve(); }); it("updates location", function () { @@ -234,8 +234,8 @@ define( describe("when moving a link", function () { beforeEach(function () { - locationCapability.isOriginal.andReturn(false); - linkService.perform.mostRecentCall.promise.resolve(); + locationCapability.isOriginal.and.returnValue(false); + linkService.perform.calls.mostRecent().promise.resolve(); }); it("does not update location", function () { diff --git a/platform/execution/test/WorkerServiceSpec.js b/platform/execution/test/WorkerServiceSpec.js index a6ab49fb8b..380d366ebf 100644 --- a/platform/execution/test/WorkerServiceSpec.js +++ b/platform/execution/test/WorkerServiceSpec.js @@ -62,8 +62,8 @@ define( mockWorker = {}; mockSharedWorker = {}; - mockWindow.Worker.andReturn(mockWorker); - mockWindow.SharedWorker.andReturn(mockSharedWorker); + mockWindow.Worker.and.returnValue(mockWorker); + mockWindow.SharedWorker.and.returnValue(mockSharedWorker); service = new WorkerService(mockWindow, testWorkers); }); diff --git a/platform/exporters/ExportServiceSpec.js b/platform/exporters/ExportServiceSpec.js index 18af713e2e..000b53a9c3 100644 --- a/platform/exporters/ExportServiceSpec.js +++ b/platform/exporters/ExportServiceSpec.js @@ -28,13 +28,11 @@ define( var mockSaveAs, testRows, csvContents, + readCSVPromise, exportService; - function finishedReadingCSV() { - return !!csvContents; - } - beforeEach(function () { + var resolveFunction; csvContents = undefined; testRows = [ { a: 1, b: 2, c: 3 }, @@ -42,10 +40,14 @@ define( { a: 7, b: 8, c: 9 } ]; mockSaveAs = jasmine.createSpy('saveAs'); - mockSaveAs.andCallFake(function (blob) { + readCSVPromise = new Promise(function (resolve) { + resolveFunction = resolve; + }); + mockSaveAs.and.callFake(function (blob) { var reader = new FileReader(); reader.onloadend = function () { csvContents = new CSV(reader.result).parse(); + resolveFunction(); }; reader.readAsText(blob); }); @@ -55,7 +57,7 @@ define( describe("#exportCSV(rows)", function () { beforeEach(function () { exportService.exportCSV(testRows); - waitsFor(finishedReadingCSV); + return readCSVPromise; }); it("triggers saving of a file", function () { @@ -89,7 +91,8 @@ define( testHeaders = ['a', 'b']; exportService .exportCSV(testRows, { headers: testHeaders }); - waitsFor(finishedReadingCSV); + + return readCSVPromise; }); it("triggers saving of a file", function () { @@ -124,7 +127,7 @@ define( testFilename = "some-test-filename.csv"; exportService .exportCSV(testRows, { filename: testFilename }); - waitsFor(finishedReadingCSV); + return readCSVPromise; }); it("saves a file with the specified name", function () { diff --git a/platform/features/clock/test/actions/FollowTimerActionSpec.js b/platform/features/clock/test/actions/FollowTimerActionSpec.js index f4b4147adb..d0671f9925 100644 --- a/platform/features/clock/test/actions/FollowTimerActionSpec.js +++ b/platform/features/clock/test/actions/FollowTimerActionSpec.js @@ -38,8 +38,8 @@ define([ 'useCapability' ]) }; testAdaptedObject = { foo: 'bar' }; - testContext.domainObject.getModel.andReturn(testModel); - testContext.domainObject.useCapability.andCallFake(function (c) { + testContext.domainObject.getModel.and.returnValue(testModel); + testContext.domainObject.useCapability.and.callFake(function (c) { return c === 'adapter' && testAdaptedObject; }); }); diff --git a/platform/features/clock/test/actions/PauseTimerActionSpec.js b/platform/features/clock/test/actions/PauseTimerActionSpec.js index 098e29c634..f68b0c461d 100644 --- a/platform/features/clock/test/actions/PauseTimerActionSpec.js +++ b/platform/features/clock/test/actions/PauseTimerActionSpec.js @@ -58,13 +58,13 @@ define( ['getCapability', 'useCapability', 'getModel'] ); - mockDomainObject.useCapability.andCallFake(function (c, v) { + mockDomainObject.useCapability.and.callFake(function (c, v) { if (c === 'mutation') { testModel = v(testModel) || testModel; return asPromise(true); } }); - mockDomainObject.getModel.andCallFake(function () { + mockDomainObject.getModel.and.callFake(function () { return testModel; }); @@ -82,7 +82,7 @@ define( it("updates the model with a pausedTime", function () { testModel.pausedTime = undefined; - mockNow.andReturn(12000); + mockNow.and.returnValue(12000); action.perform(); expect(testModel.pausedTime).toEqual(12000); }); diff --git a/platform/features/clock/test/actions/RestartTimerActionSpec.js b/platform/features/clock/test/actions/RestartTimerActionSpec.js index fc1978322f..a3e05d2d81 100644 --- a/platform/features/clock/test/actions/RestartTimerActionSpec.js +++ b/platform/features/clock/test/actions/RestartTimerActionSpec.js @@ -58,13 +58,13 @@ define( ['getCapability', 'useCapability', 'getModel'] ); - mockDomainObject.useCapability.andCallFake(function (c, v) { + mockDomainObject.useCapability.and.callFake(function (c, v) { if (c === 'mutation') { testModel = v(testModel) || testModel; return asPromise(true); } }); - mockDomainObject.getModel.andCallFake(function () { + mockDomainObject.getModel.and.callFake(function () { return testModel; }); @@ -76,7 +76,7 @@ define( it("updates the model with a timestamp", function () { testModel.pausedTime = 12000; - mockNow.andReturn(12000); + mockNow.and.returnValue(12000); action.perform(); expect(testModel.timestamp).toEqual(12000); }); diff --git a/platform/features/clock/test/actions/StartTimerActionSpec.js b/platform/features/clock/test/actions/StartTimerActionSpec.js index 1506c79738..23da7e5434 100644 --- a/platform/features/clock/test/actions/StartTimerActionSpec.js +++ b/platform/features/clock/test/actions/StartTimerActionSpec.js @@ -58,13 +58,13 @@ define( ['getCapability', 'useCapability', 'getModel'] ); - mockDomainObject.useCapability.andCallFake(function (c, v) { + mockDomainObject.useCapability.and.callFake(function (c, v) { if (c === 'mutation') { testModel = v(testModel) || testModel; return asPromise(true); } }); - mockDomainObject.getModel.andCallFake(function () { + mockDomainObject.getModel.and.callFake(function () { return testModel; }); @@ -75,7 +75,7 @@ define( }); it("updates the model with a timestamp", function () { - mockNow.andReturn(12000); + mockNow.and.returnValue(12000); action.perform(); expect(testModel.timestamp).toEqual(12000); }); diff --git a/platform/features/clock/test/actions/StopTimerActionSpec.js b/platform/features/clock/test/actions/StopTimerActionSpec.js index a4c27ad921..1dcfd58d11 100644 --- a/platform/features/clock/test/actions/StopTimerActionSpec.js +++ b/platform/features/clock/test/actions/StopTimerActionSpec.js @@ -58,13 +58,13 @@ define( ['getCapability', 'useCapability', 'getModel'] ); - mockDomainObject.useCapability.andCallFake(function (c, v) { + mockDomainObject.useCapability.and.callFake(function (c, v) { if (c === 'mutation') { testModel = v(testModel) || testModel; return asPromise(true); } }); - mockDomainObject.getModel.andCallFake(function () { + mockDomainObject.getModel.and.callFake(function () { return testModel; }); @@ -75,7 +75,7 @@ define( }); it("updates the model with a timestamp", function () { - mockNow.andReturn(12000); + mockNow.and.returnValue(12000); action.perform(); expect(testModel.timestamp).toEqual(undefined); }); diff --git a/platform/features/clock/test/controllers/ClockControllerSpec.js b/platform/features/clock/test/controllers/ClockControllerSpec.js index 8774333d14..d53987a632 100644 --- a/platform/features/clock/test/controllers/ClockControllerSpec.js +++ b/platform/features/clock/test/controllers/ClockControllerSpec.js @@ -38,7 +38,7 @@ define( mockTicker = jasmine.createSpyObj('ticker', ['listen']); mockUnticker = jasmine.createSpy('unticker'); - mockTicker.listen.andReturn(mockUnticker); + mockTicker.listen.and.returnValue(mockUnticker); controller = new ClockController(mockScope, mockTicker); }); @@ -57,17 +57,17 @@ define( it("unsubscribes to ticks when destroyed", function () { // Make sure $destroy is being listened for... - expect(mockScope.$on.mostRecentCall.args[0]).toEqual('$destroy'); + expect(mockScope.$on.calls.mostRecent().args[0]).toEqual('$destroy'); expect(mockUnticker).not.toHaveBeenCalled(); // ...and makes sure that its listener unsubscribes from ticker - mockScope.$on.mostRecentCall.args[1](); + mockScope.$on.calls.mostRecent().args[1](); expect(mockUnticker).toHaveBeenCalled(); }); it("formats using the format string from the model", function () { - mockTicker.listen.mostRecentCall.args[0](TEST_TIMESTAMP); - mockScope.$watch.mostRecentCall.args[1]({ + mockTicker.listen.calls.mostRecent().args[0](TEST_TIMESTAMP); + mockScope.$watch.calls.mostRecent().args[1]({ "clockFormat": [ "YYYY-DDD hh:mm:ss", "clock24" @@ -81,8 +81,8 @@ define( }); it("formats 12-hour time", function () { - mockTicker.listen.mostRecentCall.args[0](TEST_TIMESTAMP); - mockScope.$watch.mostRecentCall.args[1]({ + mockTicker.listen.calls.mostRecent().args[0](TEST_TIMESTAMP); + mockScope.$watch.calls.mostRecent().args[1]({ "clockFormat": [ "YYYY-DDD hh:mm:ss", "clock12" @@ -96,9 +96,9 @@ define( }); it("does not throw exceptions when model is undefined", function () { - mockTicker.listen.mostRecentCall.args[0](TEST_TIMESTAMP); + mockTicker.listen.calls.mostRecent().args[0](TEST_TIMESTAMP); expect(function () { - mockScope.$watch.mostRecentCall.args[1](undefined); + mockScope.$watch.calls.mostRecent().args[1](undefined); }).not.toThrow(); }); diff --git a/platform/features/clock/test/controllers/RefreshingControllerSpec.js b/platform/features/clock/test/controllers/RefreshingControllerSpec.js index 75bfaf0843..4e0577aaae 100644 --- a/platform/features/clock/test/controllers/RefreshingControllerSpec.js +++ b/platform/features/clock/test/controllers/RefreshingControllerSpec.js @@ -37,7 +37,7 @@ define( mockTicker = jasmine.createSpyObj('ticker', ['listen']); mockUnticker = jasmine.createSpy('unticker'); - mockTicker.listen.andReturn(mockUnticker); + mockTicker.listen.and.returnValue(mockUnticker); controller = new RefreshingController(mockScope, mockTicker); }); @@ -52,13 +52,13 @@ define( ['persist', 'refresh'] ); - mockDomainObject.getCapability.andCallFake(function (c) { + mockDomainObject.getCapability.and.callFake(function (c) { return (c === 'persistence') && mockPersistence; }); mockScope.domainObject = mockDomainObject; - mockTicker.listen.mostRecentCall.args[0](12321); + mockTicker.listen.calls.mostRecent().args[0](12321); expect(mockPersistence.refresh).toHaveBeenCalled(); expect(mockPersistence.persist).not.toHaveBeenCalled(); }); @@ -70,11 +70,11 @@ define( it("unsubscribes to ticks when destroyed", function () { // Make sure $destroy is being listened for... - expect(mockScope.$on.mostRecentCall.args[0]).toEqual('$destroy'); + expect(mockScope.$on.calls.mostRecent().args[0]).toEqual('$destroy'); expect(mockUnticker).not.toHaveBeenCalled(); // ...and makes sure that its listener unsubscribes from ticker - mockScope.$on.mostRecentCall.args[1](); + mockScope.$on.calls.mostRecent().args[1](); expect(mockUnticker).toHaveBeenCalled(); }); }); diff --git a/platform/features/clock/test/controllers/TimerControllerSpec.js b/platform/features/clock/test/controllers/TimerControllerSpec.js index ee8c7ca8d7..3f97c4bc80 100644 --- a/platform/features/clock/test/controllers/TimerControllerSpec.js +++ b/platform/features/clock/test/controllers/TimerControllerSpec.js @@ -40,7 +40,7 @@ define( controller; function invokeWatch(expr, value) { - mockScope.$watch.calls.forEach(function (call) { + mockScope.$watch.calls.all().forEach(function (call) { if (call.args[0] === expr) { call.args[1](value); } @@ -78,13 +78,13 @@ define( ); mockNow = jasmine.createSpy('now'); - mockDomainObject.getCapability.andCallFake(function (c) { + mockDomainObject.getCapability.and.callFake(function (c) { return (c === 'action') && mockActionCapability; }); - mockDomainObject.getModel.andCallFake(function () { + mockDomainObject.getModel.and.callFake(function () { return testModel; }); - mockActionCapability.getActions.andCallFake(function (k) { + mockActionCapability.getActions.and.callFake(function (k) { return [{ 'timer.start': mockStart, 'timer.pause': mockPause, @@ -92,9 +92,9 @@ define( }[k]]; }); - mockStart.getMetadata.andReturn({cssClass: "icon-play", name: "Start"}); - mockPause.getMetadata.andReturn({cssClass: "icon-pause", name: "Pause"}); - mockStop.getMetadata.andReturn({cssClass: "icon-box", name: "Stop"}); + mockStart.getMetadata.and.returnValue({cssClass: "icon-play", name: "Start"}); + mockPause.getMetadata.and.returnValue({cssClass: "icon-pause", name: "Pause"}); + mockStop.getMetadata.and.returnValue({cssClass: "icon-box", name: "Stop"}); mockScope.domainObject = mockDomainObject; testModel = {}; @@ -124,8 +124,8 @@ define( it("displays nothing when there is no target", function () { // Notify that domain object is available via scope invokeWatch('domainObject', mockDomainObject); - mockNow.andReturn(TEST_TIMESTAMP); - mockWindow.requestAnimationFrame.mostRecentCall.args[0](); + mockNow.and.returnValue(TEST_TIMESTAMP); + mockWindow.requestAnimationFrame.calls.mostRecent().args[0](); expect(controller.sign()).toEqual(""); expect(controller.signClass()).toEqual(""); expect(controller.text()).toEqual(""); @@ -137,20 +137,20 @@ define( // Notify that domain object is available via scope invokeWatch('domainObject', mockDomainObject); - mockNow.andReturn(TEST_TIMESTAMP + 121000); - mockWindow.requestAnimationFrame.mostRecentCall.args[0](); + mockNow.and.returnValue(TEST_TIMESTAMP + 121000); + mockWindow.requestAnimationFrame.calls.mostRecent().args[0](); expect(controller.sign()).toEqual("+"); expect(controller.signClass()).toEqual("icon-plus"); expect(controller.text()).toEqual("0D 00:02:01"); - mockNow.andReturn(TEST_TIMESTAMP - 121000); - mockWindow.requestAnimationFrame.mostRecentCall.args[0](); + mockNow.and.returnValue(TEST_TIMESTAMP - 121000); + mockWindow.requestAnimationFrame.calls.mostRecent().args[0](); expect(controller.sign()).toEqual("-"); expect(controller.signClass()).toEqual("icon-minus"); expect(controller.text()).toEqual("0D 00:02:01"); - mockNow.andReturn(TEST_TIMESTAMP); - mockWindow.requestAnimationFrame.mostRecentCall.args[0](); + mockNow.and.returnValue(TEST_TIMESTAMP); + mockWindow.requestAnimationFrame.calls.mostRecent().args[0](); expect(controller.sign()).toEqual(""); expect(controller.signClass()).toEqual(""); expect(controller.text()).toEqual("0D 00:00:00"); @@ -190,27 +190,27 @@ define( }); it("stops requesting animation frames when destroyed", function () { - var initialCount = mockWindow.requestAnimationFrame.calls.length; + var initialCount = mockWindow.requestAnimationFrame.calls.count(); // First, check that normally new frames keep getting requested - mockWindow.requestAnimationFrame.mostRecentCall.args[0](); - expect(mockWindow.requestAnimationFrame.calls.length) + mockWindow.requestAnimationFrame.calls.mostRecent().args[0](); + expect(mockWindow.requestAnimationFrame.calls.count()) .toEqual(initialCount + 1); - mockWindow.requestAnimationFrame.mostRecentCall.args[0](); - expect(mockWindow.requestAnimationFrame.calls.length) + mockWindow.requestAnimationFrame.calls.mostRecent().args[0](); + expect(mockWindow.requestAnimationFrame.calls.count()) .toEqual(initialCount + 2); // Now, verify that it stops after $destroy - expect(mockScope.$on.mostRecentCall.args[0]) + expect(mockScope.$on.calls.mostRecent().args[0]) .toEqual('$destroy'); - mockScope.$on.mostRecentCall.args[1](); + mockScope.$on.calls.mostRecent().args[1](); // Frames should no longer get requested - mockWindow.requestAnimationFrame.mostRecentCall.args[0](); - expect(mockWindow.requestAnimationFrame.calls.length) + mockWindow.requestAnimationFrame.calls.mostRecent().args[0](); + expect(mockWindow.requestAnimationFrame.calls.count()) .toEqual(initialCount + 2); - mockWindow.requestAnimationFrame.mostRecentCall.args[0](); - expect(mockWindow.requestAnimationFrame.calls.length) + mockWindow.requestAnimationFrame.calls.mostRecent().args[0](); + expect(mockWindow.requestAnimationFrame.calls.count()) .toEqual(initialCount + 2); }); }); diff --git a/platform/features/clock/test/indicators/ClockIndicatorSpec.js b/platform/features/clock/test/indicators/ClockIndicatorSpec.js index 6c9a8c2977..68d7397795 100644 --- a/platform/features/clock/test/indicators/ClockIndicatorSpec.js +++ b/platform/features/clock/test/indicators/ClockIndicatorSpec.js @@ -37,13 +37,13 @@ define( mockTicker = jasmine.createSpyObj('ticker', ['listen']); mockUnticker = jasmine.createSpy('unticker'); - mockTicker.listen.andReturn(mockUnticker); + mockTicker.listen.and.returnValue(mockUnticker); indicator = new ClockIndicator(mockTicker, TEST_FORMAT); }); it("displays the current time", function () { - mockTicker.listen.mostRecentCall.args[0](TEST_TIMESTAMP); + mockTicker.listen.calls.mostRecent().args[0](TEST_TIMESTAMP); expect(indicator.getText()).toEqual("2015-154 17:56:14 UTC"); }); diff --git a/platform/features/clock/test/indicators/FollowIndicatorSpec.js b/platform/features/clock/test/indicators/FollowIndicatorSpec.js index 0e4f4c6a01..0bcc13397c 100644 --- a/platform/features/clock/test/indicators/FollowIndicatorSpec.js +++ b/platform/features/clock/test/indicators/FollowIndicatorSpec.js @@ -46,7 +46,7 @@ define(["../../src/indicators/FollowIndicator"], function (FollowIndicator) { beforeEach(function () { testObject = { name: "some timer!" }; - mockTimerService.getTimer.andReturn(testObject); + mockTimerService.getTimer.and.returnValue(testObject); }); it("displays the timer's name", function () { diff --git a/platform/features/clock/test/services/TickerServiceSpec.js b/platform/features/clock/test/services/TickerServiceSpec.js index 9331f49dbe..a7fb257fb7 100644 --- a/platform/features/clock/test/services/TickerServiceSpec.js +++ b/platform/features/clock/test/services/TickerServiceSpec.js @@ -37,23 +37,23 @@ define( mockNow = jasmine.createSpy('now'); mockCallback = jasmine.createSpy('callback'); - mockNow.andReturn(TEST_TIMESTAMP); + mockNow.and.returnValue(TEST_TIMESTAMP); tickerService = new TickerService(mockTimeout, mockNow); }); it("notifies listeners of clock ticks", function () { tickerService.listen(mockCallback); - mockNow.andReturn(TEST_TIMESTAMP + 12321); - mockTimeout.mostRecentCall.args[0](); + mockNow.and.returnValue(TEST_TIMESTAMP + 12321); + mockTimeout.calls.mostRecent().args[0](); expect(mockCallback) .toHaveBeenCalledWith(TEST_TIMESTAMP + 12321); }); it("allows listeners to unregister", function () { tickerService.listen(mockCallback)(); // Unregister immediately - mockNow.andReturn(TEST_TIMESTAMP + 12321); - mockTimeout.mostRecentCall.args[0](); + mockNow.and.returnValue(TEST_TIMESTAMP + 12321); + mockTimeout.calls.mostRecent().args[0](); expect(mockCallback).not .toHaveBeenCalledWith(TEST_TIMESTAMP + 12321); }); diff --git a/platform/features/clock/test/services/TimerServiceSpec.js b/platform/features/clock/test/services/TimerServiceSpec.js index 08f05c83fd..3c57ba2e2e 100644 --- a/platform/features/clock/test/services/TimerServiceSpec.js +++ b/platform/features/clock/test/services/TimerServiceSpec.js @@ -69,7 +69,7 @@ define([ '*', jasmine.any(Function) ); - mockmct.objects.observe.mostRecentCall.args[2](newTimer); + mockmct.objects.observe.calls.mostRecent().args[2](newTimer); expect(timerService.getTimer()).toBe(newTimer); }); }); diff --git a/platform/features/conductor/core/src/ui/ConductorAxisControllerSpec.js b/platform/features/conductor/core/src/ui/ConductorAxisControllerSpec.js index 3f87490341..f1a3d0df70 100644 --- a/platform/features/conductor/core/src/ui/ConductorAxisControllerSpec.js +++ b/platform/features/conductor/core/src/ui/ConductorAxisControllerSpec.js @@ -45,7 +45,7 @@ define([ mockFormat; function getCallback(target, name) { - return target.calls.filter(function (call) { + return target.calls.all().filter(function (call) { return call.args[0] === name; })[0].args[1]; } @@ -74,7 +74,7 @@ define([ "off", "clock" ]); - mockConductor.bounds.andReturn(mockBounds); + mockConductor.bounds.and.returnValue(mockBounds); mockFormatService = jasmine.createSpyObj("formatService", [ "getFormat" @@ -86,8 +86,8 @@ define([ "emit" ]); - spyOn(d3Scale, 'scaleUtc').andCallThrough(); - spyOn(d3Scale, 'scaleLinear').andCallThrough(); + spyOn(d3Scale, 'scaleUtc').and.callThrough(); + spyOn(d3Scale, 'scaleLinear').and.callThrough(); element = $('