mirror of
https://github.com/nasa/openmct.git
synced 2025-02-09 04:11:56 +00:00
Update test specs to use Jasmine 3 (#2089)
* Updated Karma and Jasmine versions * Added DOMObserver class. Supports promise-based testing of DOM changes Update asynchronous test specs to use promises or done() instead of waitsFor/runs * Modified ActionCapability to duplicate context object properties as own properties for better object equality comparisons * Global find + replace to fix syntax issues * Fixed various issues caused by non-deterministic runtime order of tests in Jasmine 3. Fixed issues caused by changes to determination of object equality * Addressed review comments * Resolved merge conflicts with master * Fixed style errors * Use spy.calls.count() instead of manually tracking
This commit is contained in:
parent
013eba744d
commit
433dee0314
@ -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
|
||||
|
15
package.json
15
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",
|
||||
|
@ -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(
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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 () {
|
||||
|
@ -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 () {
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
|
@ -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");
|
||||
});
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
|
@ -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");
|
||||
});
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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 () {
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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();
|
||||
});
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
});
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
@ -37,7 +37,7 @@ define(
|
||||
mockQ = {};
|
||||
mockTransactionService = {};
|
||||
mockCapabilityService = jasmine.createSpyObj("capabilityService", ["getCapabilities"]);
|
||||
mockCapabilityService.getCapabilities.andReturn({
|
||||
mockCapabilityService.getCapabilities.and.returnValue({
|
||||
persistence: function () {}
|
||||
});
|
||||
|
||||
|
@ -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');
|
||||
});
|
||||
|
||||
|
@ -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 () {
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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];
|
||||
});
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
@ -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;
|
||||
});
|
||||
|
||||
|
@ -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'});
|
||||
|
@ -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'
|
||||
]);
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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();
|
||||
|
@ -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]);
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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 () {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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');
|
||||
});
|
||||
});
|
||||
|
@ -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(
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
));
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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]();
|
||||
}
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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
|
||||
);
|
||||
|
@ -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
|
||||
});
|
||||
|
@ -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');
|
||||
|
@ -41,7 +41,7 @@ define(
|
||||
'remove'
|
||||
]);
|
||||
|
||||
mockDocument.find.andCallFake(function (query) {
|
||||
mockDocument.find.and.callFake(function (query) {
|
||||
return query === 'body' && mockBody;
|
||||
});
|
||||
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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 () {
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
|
@ -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]);
|
||||
});
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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();
|
||||
});
|
||||
|
@ -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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
|
@ -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',
|
||||
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
@ -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');
|
||||
});
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
});
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
|
@ -47,7 +47,7 @@ define(
|
||||
["error", "warn", "info", "debug"]
|
||||
);
|
||||
|
||||
mockActionService.getActions.andReturn([mockAction]);
|
||||
mockActionService.getActions.and.returnValue([mockAction]);
|
||||
|
||||
decorator = new LoggingActionDecorator(
|
||||
mockLog,
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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,
|
||||
|
@ -49,6 +49,8 @@ define(
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
KeylessCapability.key = undefined;
|
||||
|
||||
mockLog = jasmine.createSpyObj(
|
||||
"$log",
|
||||
["error", "warn", "info", "debug"]
|
||||
|
@ -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({
|
||||
|
@ -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);
|
||||
});
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
});
|
||||
|
||||
|
@ -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" });
|
||||
});
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user