mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 09:52:04 +00:00
Merge pull request #927 from nasa/jscs-rebase-142
[Code Style] Enforce code style
This commit is contained in:
commit
25a2321578
4
.jscsrc
4
.jscsrc
@ -1,3 +1,5 @@
|
||||
{
|
||||
"preset": "crockford"
|
||||
"preset": "crockford",
|
||||
"requireMultipleVarDecl": false,
|
||||
"requireVarDeclFirst": false
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
"eqeqeq": true,
|
||||
"forin": true,
|
||||
"freeze": true,
|
||||
"funcscope": true,
|
||||
"funcscope": false,
|
||||
"futurehostile": true,
|
||||
"latedef": true,
|
||||
"noarg": true,
|
||||
@ -16,6 +16,7 @@
|
||||
"define",
|
||||
"Promise"
|
||||
],
|
||||
"shadow": "outer",
|
||||
"strict": "implied",
|
||||
"undef": true,
|
||||
"unused": "vars"
|
||||
|
@ -147,6 +147,6 @@ gulp.task('develop', ['serve', 'stylesheets', 'watch']);
|
||||
|
||||
gulp.task('install', [ 'static', 'scripts' ]);
|
||||
|
||||
gulp.task('verify', [ 'lint', 'test' ]);
|
||||
gulp.task('verify', [ 'lint', 'test', 'checkstyle' ]);
|
||||
|
||||
gulp.task('build', [ 'verify', 'install' ]);
|
||||
|
@ -152,7 +152,7 @@ define(
|
||||
});
|
||||
|
||||
it("validates selection types using policy", function () {
|
||||
var mockDomainObject = jasmine.createSpyObj(
|
||||
var mockDomainObj = jasmine.createSpyObj(
|
||||
'domainObject',
|
||||
['getCapability']
|
||||
),
|
||||
@ -166,8 +166,8 @@ define(
|
||||
rows = structure.sections[sections.length - 1].rows,
|
||||
locationRow = rows[rows.length - 1];
|
||||
|
||||
mockDomainObject.getCapability.andReturn(mockOtherType);
|
||||
locationRow.validate(mockDomainObject);
|
||||
mockDomainObj.getCapability.andReturn(mockOtherType);
|
||||
locationRow.validate(mockDomainObj);
|
||||
|
||||
// Should check policy to see if the user-selected location
|
||||
// can actually contain objects of this type
|
||||
|
@ -316,7 +316,7 @@ define([
|
||||
"transactionService"
|
||||
]
|
||||
}
|
||||
],
|
||||
]
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -63,10 +63,10 @@ define(
|
||||
});
|
||||
}
|
||||
|
||||
function showDialog(type) {
|
||||
function showDialog(objType) {
|
||||
// Create a dialog object to generate the form structure, etc.
|
||||
var dialog =
|
||||
new PropertiesDialog(type, domainObject.getModel());
|
||||
new PropertiesDialog(objType, domainObject.getModel());
|
||||
|
||||
// Show the dialog
|
||||
return dialogService.getUserInput(
|
||||
|
@ -75,8 +75,8 @@ define(
|
||||
* Invoke persistence on a domain object. This will be called upon
|
||||
* the removed object's parent (as its composition will have changed.)
|
||||
*/
|
||||
function doPersist(domainObject) {
|
||||
var persistence = domainObject.getCapability('persistence');
|
||||
function doPersist(domainObj) {
|
||||
var persistence = domainObj.getCapability('persistence');
|
||||
return persistence && persistence.persist();
|
||||
}
|
||||
|
||||
|
@ -24,8 +24,12 @@ define(
|
||||
function () {
|
||||
|
||||
// Utility functions for reducing truth arrays
|
||||
function and(a, b) { return a && b; }
|
||||
function or(a, b) { return a || b; }
|
||||
function and(a, b) {
|
||||
return a && b;
|
||||
}
|
||||
function or(a, b) {
|
||||
return a || b;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -219,7 +223,7 @@ define(
|
||||
|
||||
// Update value for this property in all elements of the
|
||||
// selection which have this property.
|
||||
function updateProperties(property, value) {
|
||||
function updateProperties(property, val) {
|
||||
var changed = false;
|
||||
|
||||
// Update property in a selected element
|
||||
@ -229,12 +233,12 @@ define(
|
||||
// Check if this is a setter, or just assignable
|
||||
if (typeof selected[property] === 'function') {
|
||||
changed =
|
||||
changed || (selected[property]() !== value);
|
||||
selected[property](value);
|
||||
changed || (selected[property]() !== val);
|
||||
selected[property](val);
|
||||
} else {
|
||||
changed =
|
||||
changed || (selected[property] !== value);
|
||||
selected[property] = value;
|
||||
changed || (selected[property] !== val);
|
||||
selected[property] = val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -133,11 +133,11 @@ define(
|
||||
self = this;
|
||||
|
||||
// Initialize toolbar (expose object to parent scope)
|
||||
function initialize(definition) {
|
||||
function initialize(def) {
|
||||
// If we have been asked to expose toolbar state...
|
||||
if (self.attrs.toolbar) {
|
||||
// Initialize toolbar object
|
||||
self.toolbar = new EditToolbar(definition, self.commit);
|
||||
self.toolbar = new EditToolbar(def, self.commit);
|
||||
// Ensure toolbar state is exposed
|
||||
self.exposeToolbar();
|
||||
}
|
||||
|
@ -38,7 +38,9 @@ define(
|
||||
beforeEach(function () {
|
||||
capabilities = {
|
||||
type: {
|
||||
getProperties: function () { return []; },
|
||||
getProperties: function () {
|
||||
return [];
|
||||
},
|
||||
hasFeature: jasmine.createSpy('hasFeature')
|
||||
},
|
||||
persistence: jasmine.createSpyObj("persistence", ["persist"]),
|
||||
@ -47,11 +49,21 @@ define(
|
||||
model = {};
|
||||
input = {};
|
||||
object = {
|
||||
getId: function () { return 'test-id'; },
|
||||
getCapability: function (k) { return capabilities[k]; },
|
||||
getModel: function () { return model; },
|
||||
useCapability: function (k, v) { return capabilities[k](v); },
|
||||
hasCapability: function () { return true; }
|
||||
getId: function () {
|
||||
return 'test-id';
|
||||
},
|
||||
getCapability: function (k) {
|
||||
return capabilities[k];
|
||||
},
|
||||
getModel: function () {
|
||||
return model;
|
||||
},
|
||||
useCapability: function (k, v) {
|
||||
return capabilities[k](v);
|
||||
},
|
||||
hasCapability: function () {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
context = { someKey: "some value", domainObject: object };
|
||||
dialogService = {
|
||||
|
@ -30,14 +30,22 @@ define(
|
||||
|
||||
beforeEach(function () {
|
||||
type = {
|
||||
getProperties: function () { return properties; }
|
||||
getProperties: function () {
|
||||
return properties;
|
||||
}
|
||||
};
|
||||
model = { x: "initial value" };
|
||||
properties = ["x", "y", "z"].map(function (k) {
|
||||
return {
|
||||
getValue: function (model) { return model[k]; },
|
||||
setValue: function (model, v) { model[k] = v; },
|
||||
getDefinition: function () { return { control: 'textfield '}; }
|
||||
getValue: function (m) {
|
||||
return m[k];
|
||||
},
|
||||
setValue: function (m, v) {
|
||||
m[k] = v;
|
||||
},
|
||||
getDefinition: function () {
|
||||
return { control: 'textfield '};
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
|
@ -126,7 +126,9 @@ define(
|
||||
it("reads properties from getters", function () {
|
||||
var structure, state;
|
||||
|
||||
testABC.a = function () { return "from a getter!"; };
|
||||
testABC.a = function () {
|
||||
return "from a getter!";
|
||||
};
|
||||
|
||||
toolbar.setSelection([testABC]);
|
||||
structure = toolbar.getStructure();
|
||||
|
@ -40,7 +40,9 @@ define(
|
||||
});
|
||||
// Return constructors
|
||||
mockFormats = KEYS.map(function (k, i) {
|
||||
function MockFormat() { return mockFormatInstances[i]; }
|
||||
function MockFormat() {
|
||||
return mockFormatInstances[i];
|
||||
}
|
||||
MockFormat.key = k;
|
||||
return MockFormat;
|
||||
});
|
||||
|
@ -69,7 +69,9 @@ define(
|
||||
function updateList(ids) {
|
||||
function updateSelectedObjects(objects) {
|
||||
// Look up from the
|
||||
function getObject(id) { return objects[id]; }
|
||||
function getObject(id) {
|
||||
return objects[id];
|
||||
}
|
||||
self.selectedObjects =
|
||||
ids.filter(getObject).map(getObject);
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ define(
|
||||
var context = domainObject &&
|
||||
domainObject.getCapability('context'),
|
||||
objectPath = context ? context.getPath() : [],
|
||||
ids = objectPath.map(function (domainObject) {
|
||||
return domainObject.getId();
|
||||
ids = objectPath.map(function (domainObj) {
|
||||
return domainObj.getId();
|
||||
});
|
||||
|
||||
// Parses the path together. Starts with the
|
||||
|
@ -105,8 +105,8 @@ define([
|
||||
function getIdPath(domainObject) {
|
||||
var context = domainObject && domainObject.getCapability('context');
|
||||
|
||||
function getId(domainObject) {
|
||||
return domainObject.getId();
|
||||
function getId(domainObj) {
|
||||
return domainObj.getId();
|
||||
}
|
||||
|
||||
return context ? context.getPath().map(getId) : [];
|
||||
|
@ -62,8 +62,8 @@ define([
|
||||
var self = this,
|
||||
domainObject = this.activeObject;
|
||||
|
||||
function addNode(domainObject, index) {
|
||||
self.nodeViews[index].model(domainObject);
|
||||
function addNode(domainObj, index) {
|
||||
self.nodeViews[index].model(domainObj);
|
||||
}
|
||||
|
||||
function addNodes(domainObjects) {
|
||||
|
@ -39,7 +39,9 @@ define(
|
||||
);
|
||||
|
||||
testIndicatorA = {};
|
||||
testIndicatorB = function () { return mockIndicator; };
|
||||
testIndicatorB = function () {
|
||||
return mockIndicator;
|
||||
};
|
||||
testIndicatorC = { template: "someTemplate" };
|
||||
|
||||
testIndicators = [
|
||||
|
@ -32,7 +32,9 @@ define(
|
||||
|
||||
function TestObject(id, context) {
|
||||
return {
|
||||
getId: function () { return id; },
|
||||
getId: function () {
|
||||
return id;
|
||||
},
|
||||
getCapability: function (key) {
|
||||
return key === 'context' ? context : undefined;
|
||||
}
|
||||
|
@ -35,7 +35,9 @@ define(
|
||||
beforeEach(function () {
|
||||
mockScope = jasmine.createSpyObj("$scope", ["$watch"]);
|
||||
mockTimeout = jasmine.createSpy("$timeout");
|
||||
mockTimeout.andCallFake(function (cb) { cb(); });
|
||||
mockTimeout.andCallFake(function (cb) {
|
||||
cb();
|
||||
});
|
||||
mockScope.ngModel = {};
|
||||
controller = new ViewSwitcherController(mockScope, mockTimeout);
|
||||
});
|
||||
|
@ -36,7 +36,7 @@ define([
|
||||
treeView;
|
||||
|
||||
function makeMockDomainObject(id, model, capabilities) {
|
||||
var mockDomainObject = jasmine.createSpyObj(
|
||||
var mockDomainObj = jasmine.createSpyObj(
|
||||
'domainObject-' + id,
|
||||
[
|
||||
'getId',
|
||||
@ -46,18 +46,18 @@ define([
|
||||
'useCapability'
|
||||
]
|
||||
);
|
||||
mockDomainObject.getId.andReturn(id);
|
||||
mockDomainObject.getModel.andReturn(model);
|
||||
mockDomainObject.hasCapability.andCallFake(function (c) {
|
||||
mockDomainObj.getId.andReturn(id);
|
||||
mockDomainObj.getModel.andReturn(model);
|
||||
mockDomainObj.hasCapability.andCallFake(function (c) {
|
||||
return !!(capabilities[c]);
|
||||
});
|
||||
mockDomainObject.getCapability.andCallFake(function (c) {
|
||||
mockDomainObj.getCapability.andCallFake(function (c) {
|
||||
return capabilities[c];
|
||||
});
|
||||
mockDomainObject.useCapability.andCallFake(function (c) {
|
||||
mockDomainObj.useCapability.andCallFake(function (c) {
|
||||
return capabilities[c] && capabilities[c].invoke();
|
||||
});
|
||||
return mockDomainObject;
|
||||
return mockDomainObj;
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
@ -99,24 +99,16 @@ define([
|
||||
var mockComposition;
|
||||
|
||||
function makeGenericCapabilities() {
|
||||
var mockContext =
|
||||
jasmine.createSpyObj('context', [ 'getPath' ]),
|
||||
mockType =
|
||||
jasmine.createSpyObj('type', [ 'getGlyph' ]),
|
||||
mockLocation =
|
||||
jasmine.createSpyObj('location', [ 'isLink' ]),
|
||||
mockMutation =
|
||||
jasmine.createSpyObj('mutation', [ 'listen' ]),
|
||||
mockStatus =
|
||||
var mockStatus =
|
||||
jasmine.createSpyObj('status', ['listen', 'list']);
|
||||
|
||||
mockStatus.list.andReturn([]);
|
||||
|
||||
return {
|
||||
context: mockContext,
|
||||
type: mockType,
|
||||
mutation: mockMutation,
|
||||
location: mockLocation,
|
||||
context: jasmine.createSpyObj('context', ['getPath']),
|
||||
type: jasmine.createSpyObj('type', ['getGlyph']),
|
||||
location: jasmine.createSpyObj('location', ['isLink']),
|
||||
mutation: jasmine.createSpyObj('mutation', ['listen']),
|
||||
status: mockStatus
|
||||
};
|
||||
}
|
||||
@ -133,11 +125,11 @@ define([
|
||||
|
||||
beforeEach(function () {
|
||||
mockComposition = ['a', 'b', 'c'].map(function (id) {
|
||||
var testCapabilities = makeGenericCapabilities(),
|
||||
var testCaps = makeGenericCapabilities(),
|
||||
mockChild =
|
||||
makeMockDomainObject(id, {}, testCapabilities);
|
||||
makeMockDomainObject(id, {}, testCaps);
|
||||
|
||||
testCapabilities.context.getPath
|
||||
testCaps.context.getPath
|
||||
.andReturn([mockDomainObject, mockChild]);
|
||||
|
||||
return mockChild;
|
||||
@ -207,11 +199,11 @@ define([
|
||||
|
||||
describe("when a context-less object is selected", function () {
|
||||
beforeEach(function () {
|
||||
var testCapabilities = makeGenericCapabilities(),
|
||||
mockDomainObject =
|
||||
makeMockDomainObject('xyz', {}, testCapabilities);
|
||||
delete testCapabilities.context;
|
||||
treeView.value(mockDomainObject);
|
||||
var testCaps = makeGenericCapabilities(),
|
||||
mockDomainObj =
|
||||
makeMockDomainObject('xyz', {}, testCaps);
|
||||
delete testCaps.context;
|
||||
treeView.value(mockDomainObj);
|
||||
});
|
||||
|
||||
it("clears all selection state", function () {
|
||||
|
@ -79,8 +79,8 @@ define(
|
||||
// On any touch on the body, default body touches/events
|
||||
// are prevented, the bubble is dismissed, and the touchstart
|
||||
// body event is unbound, reallowing gestures
|
||||
body.on('touchstart', function (event) {
|
||||
event.preventDefault();
|
||||
body.on('touchstart', function (evt) {
|
||||
evt.preventDefault();
|
||||
hideBubble();
|
||||
body.unbind('touchstart');
|
||||
});
|
||||
|
@ -69,7 +69,7 @@ define(
|
||||
});
|
||||
|
||||
it("detects display orientation", function () {
|
||||
var agentService = new AgentService(testWindow);
|
||||
agentService = new AgentService(testWindow);
|
||||
testWindow.innerWidth = 1024;
|
||||
testWindow.innerHeight = 400;
|
||||
expect(agentService.isPortrait()).toBeFalsy();
|
||||
|
@ -81,8 +81,8 @@ define(
|
||||
// additionally fills in the action's getMetadata method
|
||||
// with the extension definition (if no getMetadata
|
||||
// method was supplied.)
|
||||
function instantiateAction(Action, context) {
|
||||
var action = new Action(context),
|
||||
function instantiateAction(Action, ctxt) {
|
||||
var action = new Action(ctxt),
|
||||
metadata;
|
||||
|
||||
// Provide a getMetadata method that echos
|
||||
@ -90,7 +90,7 @@ define(
|
||||
// unless the action has defined its own.
|
||||
if (!action.getMetadata) {
|
||||
metadata = Object.create(Action.definition || {});
|
||||
metadata.context = context;
|
||||
metadata.context = ctxt;
|
||||
action.getMetadata = function () {
|
||||
return metadata;
|
||||
};
|
||||
@ -103,14 +103,14 @@ define(
|
||||
// applicable in a given context, according to the static
|
||||
// appliesTo method of given actions (if defined), and
|
||||
// instantiate those applicable actions.
|
||||
function createIfApplicable(actions, context) {
|
||||
function createIfApplicable(actions, ctxt) {
|
||||
function isApplicable(Action) {
|
||||
return Action.appliesTo ? Action.appliesTo(context) : true;
|
||||
return Action.appliesTo ? Action.appliesTo(ctxt) : true;
|
||||
}
|
||||
|
||||
function instantiate(Action) {
|
||||
try {
|
||||
return instantiateAction(Action, context);
|
||||
return instantiateAction(Action, ctxt);
|
||||
} catch (e) {
|
||||
$log.error([
|
||||
"Could not instantiate action",
|
||||
|
@ -82,7 +82,7 @@ define(
|
||||
return mutationResult && self.invoke().then(findObject);
|
||||
}
|
||||
|
||||
function addIdToModel(model) {
|
||||
function addIdToModel(objModel) {
|
||||
// Pick a specific index if needed.
|
||||
index = isNaN(index) ? composition.length : index;
|
||||
// Also, don't put past the end of the array
|
||||
@ -90,11 +90,11 @@ define(
|
||||
|
||||
// Remove the existing instance of the id
|
||||
if (oldIndex !== -1) {
|
||||
model.composition.splice(oldIndex, 1);
|
||||
objModel.composition.splice(oldIndex, 1);
|
||||
}
|
||||
|
||||
// ...and add it back at the appropriate index.
|
||||
model.composition.splice(index, 0, id);
|
||||
objModel.composition.splice(index, 0, id);
|
||||
}
|
||||
|
||||
// If no index has been specified already and the id is already
|
||||
|
@ -62,9 +62,9 @@ define(
|
||||
}
|
||||
|
||||
// Package capabilities as key-value pairs
|
||||
function packageCapabilities(capabilities) {
|
||||
function packageCapabilities(caps) {
|
||||
var result = {};
|
||||
capabilities.forEach(function (capability) {
|
||||
caps.forEach(function (capability) {
|
||||
if (capability.key) {
|
||||
result[capability.key] =
|
||||
result[capability.key] || capability;
|
||||
|
@ -124,9 +124,9 @@ define(
|
||||
clone = JSON.parse(JSON.stringify(model)),
|
||||
useTimestamp = arguments.length > 1;
|
||||
|
||||
function notifyListeners(model) {
|
||||
function notifyListeners(newModel) {
|
||||
generalTopic.notify(domainObject);
|
||||
specificTopic.notify(model);
|
||||
specificTopic.notify(newModel);
|
||||
}
|
||||
|
||||
// Function to handle copying values to the actual
|
||||
|
@ -124,8 +124,8 @@ define(
|
||||
this.persistenceService.createObject;
|
||||
|
||||
// Update persistence timestamp...
|
||||
domainObject.useCapability("mutation", function (model) {
|
||||
model.persisted = modified;
|
||||
domainObject.useCapability("mutation", function (m) {
|
||||
m.persisted = modified;
|
||||
}, modified);
|
||||
|
||||
// ...and persist
|
||||
|
@ -82,9 +82,9 @@ define(
|
||||
}
|
||||
|
||||
// Package the result as id->model
|
||||
function packageResult(parsedIds, models) {
|
||||
function packageResult(parsedIdsToPackage, models) {
|
||||
var result = {};
|
||||
parsedIds.forEach(function (parsedId, index) {
|
||||
parsedIdsToPackage.forEach(function (parsedId, index) {
|
||||
var id = parsedId.id;
|
||||
if (models[index]) {
|
||||
result[id] = models[index];
|
||||
@ -93,11 +93,11 @@ define(
|
||||
return result;
|
||||
}
|
||||
|
||||
function loadModels(parsedIds) {
|
||||
return $q.all(parsedIds.map(loadModel))
|
||||
function loadModels(parsedIdsToLoad) {
|
||||
return $q.all(parsedIdsToLoad.map(loadModel))
|
||||
.then(function (models) {
|
||||
return packageResult(
|
||||
parsedIds,
|
||||
parsedIdsToLoad,
|
||||
models.map(addPersistedTimestamp)
|
||||
);
|
||||
});
|
||||
|
@ -46,7 +46,9 @@ define(
|
||||
*/
|
||||
function RootModelProvider(roots, $q, $log) {
|
||||
// Pull out identifiers to used as ROOT's
|
||||
var ids = roots.map(function (root) { return root.id; });
|
||||
var ids = roots.map(function (root) {
|
||||
return root.id;
|
||||
});
|
||||
|
||||
// Assign an initial location to root models
|
||||
roots.forEach(function (root) {
|
||||
|
@ -58,14 +58,14 @@ define(
|
||||
* corresponding keys in the recursive step.
|
||||
*
|
||||
*
|
||||
* @param a the first object to be merged
|
||||
* @param b the second object to be merged
|
||||
* @param modelA the first object to be merged
|
||||
* @param modelB the second object to be merged
|
||||
* @param merger the merger, as described above
|
||||
* @returns {*} the result of merging `a` and `b`
|
||||
* @returns {*} the result of merging `modelA` and `modelB`
|
||||
* @constructor
|
||||
* @memberof platform/core
|
||||
*/
|
||||
function mergeModels(a, b, merger) {
|
||||
function mergeModels(modelA, modelB, merger) {
|
||||
var mergeFunction;
|
||||
|
||||
function mergeArrays(a, b) {
|
||||
@ -93,11 +93,11 @@ define(
|
||||
}
|
||||
|
||||
mergeFunction = (merger && Function.isFunction(merger)) ? merger :
|
||||
(Array.isArray(a) && Array.isArray(b)) ? mergeArrays :
|
||||
(a instanceof Object && b instanceof Object) ? mergeObjects :
|
||||
(Array.isArray(modelA) && Array.isArray(modelB)) ? mergeArrays :
|
||||
(modelA instanceof Object && modelB instanceof Object) ? mergeObjects :
|
||||
mergeOther;
|
||||
|
||||
return mergeFunction(a, b);
|
||||
return mergeFunction(modelA, modelB);
|
||||
}
|
||||
|
||||
return mergeModels;
|
||||
|
@ -33,8 +33,12 @@ define(
|
||||
}
|
||||
},
|
||||
identity: {
|
||||
toModelValue: function (v) { return v; },
|
||||
toFormValue: function (v) { return v; }
|
||||
toModelValue: function (v) {
|
||||
return v;
|
||||
},
|
||||
toFormValue: function (v) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
},
|
||||
ARRAY_SUFFIX = '[]';
|
||||
|
@ -159,8 +159,8 @@ define(
|
||||
}
|
||||
|
||||
function lookupTypeDef(typeKey) {
|
||||
function buildTypeDef(typeKey) {
|
||||
var typeDefs = typeDefinitions[typeKey] || [],
|
||||
function buildTypeDef(typeKeyToBuild) {
|
||||
var typeDefs = typeDefinitions[typeKeyToBuild] || [],
|
||||
inherits = typeDefs.map(function (typeDef) {
|
||||
return asArray(typeDef.inherits || []);
|
||||
}).reduce(function (a, b) {
|
||||
|
@ -105,15 +105,15 @@ define(
|
||||
// Check if an object has all capabilities designated as `needs`
|
||||
// for a view. Exposing a capability via delegation is taken to
|
||||
// satisfy this filter if `allowDelegation` is true.
|
||||
function capabilitiesMatch(domainObject, capabilities, allowDelegation) {
|
||||
var delegation = domainObject.getCapability("delegation");
|
||||
function capabilitiesMatch(domainObj, capabilities, allowDelegation) {
|
||||
var delegation = domainObj.getCapability("delegation");
|
||||
|
||||
allowDelegation = allowDelegation && (delegation !== undefined);
|
||||
|
||||
// Check if an object has (or delegates, if allowed) a
|
||||
// capability.
|
||||
function hasCapability(c) {
|
||||
return domainObject.hasCapability(c) ||
|
||||
return domainObj.hasCapability(c) ||
|
||||
(allowDelegation && delegation.doesDelegateCapability(c));
|
||||
}
|
||||
|
||||
@ -128,13 +128,13 @@ define(
|
||||
|
||||
// Check if a view and domain object type can be paired;
|
||||
// both can restrict the others they accept.
|
||||
function viewMatchesType(view, type) {
|
||||
var views = type && (type.getDefinition() || {}).views,
|
||||
function viewMatchesType(view, objType) {
|
||||
var views = objType && (objType.getDefinition() || {}).views,
|
||||
matches = true;
|
||||
|
||||
// View is restricted to a certain type
|
||||
if (view.type) {
|
||||
matches = matches && type && type.instanceOf(view.type);
|
||||
matches = matches && objType && objType.instanceOf(view.type);
|
||||
}
|
||||
|
||||
// Type wishes to restrict its specific views
|
||||
|
@ -33,29 +33,41 @@ define(
|
||||
actionProvider;
|
||||
|
||||
function SimpleAction() {
|
||||
return { perform: function () { return "simple"; } };
|
||||
return { perform: function () {
|
||||
return "simple";
|
||||
} };
|
||||
}
|
||||
|
||||
function CategorizedAction() {
|
||||
return { perform: function () { return "categorized"; } };
|
||||
return { perform: function () {
|
||||
return "categorized";
|
||||
} };
|
||||
}
|
||||
CategorizedAction.category = "someCategory";
|
||||
|
||||
function KeyedAction() {
|
||||
return { perform: function () { return "keyed"; } };
|
||||
return { perform: function () {
|
||||
return "keyed";
|
||||
} };
|
||||
}
|
||||
KeyedAction.key = "someKey";
|
||||
|
||||
function CategorizedKeyedAction() {
|
||||
return { perform: function () { return "both"; } };
|
||||
return { perform: function () {
|
||||
return "both";
|
||||
} };
|
||||
}
|
||||
CategorizedKeyedAction.key = "someKey";
|
||||
CategorizedKeyedAction.category = "someCategory";
|
||||
|
||||
function MetadataAction() {
|
||||
return {
|
||||
perform: function () { return "metadata"; },
|
||||
getMetadata: function () { return "custom metadata"; }
|
||||
perform: function () {
|
||||
return "metadata";
|
||||
},
|
||||
getMetadata: function () {
|
||||
return "custom metadata";
|
||||
}
|
||||
};
|
||||
}
|
||||
MetadataAction.key = "metadata";
|
||||
|
@ -114,7 +114,9 @@ define(
|
||||
mockObjectService.getObjects.andReturn(mockPromise({x: mockChild}));
|
||||
mockChild.getCapability.andReturn(undefined);
|
||||
|
||||
composition.invoke().then(function (c) { result = c; });
|
||||
composition.invoke().then(function (c) {
|
||||
result = c;
|
||||
});
|
||||
|
||||
// Should have been added by a wrapper
|
||||
expect(result[0].getCapability('context')).toBeDefined();
|
||||
|
@ -31,16 +31,22 @@ define(
|
||||
var mockLog,
|
||||
provider;
|
||||
|
||||
function BasicCapability() { return; }
|
||||
function BasicCapability() {
|
||||
return;
|
||||
}
|
||||
BasicCapability.key = "basic";
|
||||
|
||||
function ApplicableCapability() { return; }
|
||||
function ApplicableCapability() {
|
||||
return;
|
||||
}
|
||||
ApplicableCapability.key = "applicable";
|
||||
ApplicableCapability.appliesTo = function (model) {
|
||||
return !model.isNotApplicable;
|
||||
};
|
||||
|
||||
function KeylessCapability() { return; }
|
||||
function KeylessCapability() {
|
||||
return;
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
mockLog = jasmine.createSpyObj(
|
||||
|
@ -36,7 +36,11 @@ define(
|
||||
object = {},
|
||||
delegation;
|
||||
|
||||
function capture(k) { return function (v) { captured[k] = v; }; }
|
||||
function capture(k) {
|
||||
return function (v) {
|
||||
captured[k] = v;
|
||||
};
|
||||
}
|
||||
function TestDomainObject(caps, id) {
|
||||
return {
|
||||
getId: function () {
|
||||
@ -68,11 +72,15 @@ define(
|
||||
captured = {};
|
||||
typeDef = {};
|
||||
typeDef.delegates = ["foo"];
|
||||
type = { getDefinition: function () { return typeDef; } };
|
||||
type = { getDefinition: function () {
|
||||
return typeDef;
|
||||
} };
|
||||
children = [];
|
||||
capabilities = {
|
||||
type: type,
|
||||
composition: { invoke: function () { return mockPromise(children); } }
|
||||
composition: { invoke: function () {
|
||||
return mockPromise(children);
|
||||
} }
|
||||
};
|
||||
object = new TestDomainObject(capabilities);
|
||||
|
||||
|
@ -73,16 +73,16 @@ define(
|
||||
});
|
||||
|
||||
it("uses the instantiate service to create domain objects", function () {
|
||||
var mockDomainObject = jasmine.createSpyObj('domainObject', [
|
||||
var mockDomainObj = jasmine.createSpyObj('domainObject', [
|
||||
'getId',
|
||||
'getModel',
|
||||
'getCapability',
|
||||
'useCapability',
|
||||
'hasCapability'
|
||||
]), testModel = { someKey: "some value" };
|
||||
mockInstantiate.andReturn(mockDomainObject);
|
||||
mockInstantiate.andReturn(mockDomainObj);
|
||||
expect(instantiation.instantiate(testModel))
|
||||
.toBe(mockDomainObject);
|
||||
.toBe(mockDomainObj);
|
||||
expect(mockInstantiate)
|
||||
.toHaveBeenCalledWith({
|
||||
someKey: "some value",
|
||||
|
@ -35,8 +35,12 @@ define(
|
||||
topic,
|
||||
mockNow,
|
||||
domainObject = {
|
||||
getId: function () { return "test-id"; },
|
||||
getModel: function () { return testModel; }
|
||||
getId: function () {
|
||||
return "test-id";
|
||||
},
|
||||
getModel: function () {
|
||||
return testModel;
|
||||
}
|
||||
},
|
||||
mutation;
|
||||
|
||||
|
@ -85,8 +85,12 @@ define(
|
||||
);
|
||||
|
||||
mockDomainObject = {
|
||||
getId: function () { return id; },
|
||||
getModel: function () { return model; },
|
||||
getId: function () {
|
||||
return id;
|
||||
},
|
||||
getModel: function () {
|
||||
return model;
|
||||
},
|
||||
useCapability: jasmine.createSpy()
|
||||
};
|
||||
// Simulate mutation capability
|
||||
|
@ -99,7 +99,7 @@ define(
|
||||
});
|
||||
|
||||
it("ensures a single object instance, even for multiple concurrent calls", function () {
|
||||
var promiseA, promiseB, mockCallback = jasmine.createSpy();
|
||||
var promiseA, promiseB;
|
||||
|
||||
promiseA = fakePromise();
|
||||
promiseB = fakePromise();
|
||||
@ -126,7 +126,7 @@ define(
|
||||
});
|
||||
|
||||
it("is robust against updating with undefined values", function () {
|
||||
var promiseA, promiseB, mockCallback = jasmine.createSpy();
|
||||
var promiseA, promiseB;
|
||||
|
||||
promiseA = fakePromise();
|
||||
promiseB = fakePromise();
|
||||
|
@ -61,14 +61,18 @@ define(
|
||||
it("provides models for any IDs which are missing", function () {
|
||||
var models;
|
||||
decorator.getModels(['testId', 'otherId'])
|
||||
.then(function (m) { models = m; });
|
||||
.then(function (m) {
|
||||
models = m;
|
||||
});
|
||||
expect(models.otherId).toBeDefined();
|
||||
});
|
||||
|
||||
it("does not overwrite existing models", function () {
|
||||
var models;
|
||||
decorator.getModels(['testId', 'otherId'])
|
||||
.then(function (m) { models = m; });
|
||||
.then(function (m) {
|
||||
models = m;
|
||||
});
|
||||
expect(models.testId).toEqual({ someKey: "some value" });
|
||||
});
|
||||
|
||||
|
@ -48,7 +48,9 @@ define(
|
||||
});
|
||||
|
||||
mockQ.all.andReturn({
|
||||
then: function (c) { return c(modelList); }
|
||||
then: function (c) {
|
||||
return c(modelList);
|
||||
}
|
||||
});
|
||||
|
||||
aggregator = new ModelAggregator(mockQ, mockProviders);
|
||||
|
@ -57,7 +57,9 @@ define(
|
||||
};
|
||||
}
|
||||
|
||||
function capture(value) { captured = value; }
|
||||
function capture(value) {
|
||||
captured = value;
|
||||
}
|
||||
|
||||
|
||||
beforeEach(function () {
|
||||
|
@ -55,7 +55,9 @@ define(
|
||||
});
|
||||
|
||||
it("provides models from extension declarations", function () {
|
||||
var mockPromise = { then: function () { return; } };
|
||||
var mockPromise = { then: function () {
|
||||
return;
|
||||
} };
|
||||
mockQ.when.andReturn(mockPromise);
|
||||
|
||||
// Verify that we got the promise as the return value
|
||||
|
@ -74,10 +74,14 @@ define(
|
||||
|
||||
it("supports instance-of checks by type object", function () {
|
||||
expect(type.instanceOf({
|
||||
getKey: function () { return 'test-parent-1'; }
|
||||
getKey: function () {
|
||||
return 'test-parent-1';
|
||||
}
|
||||
})).toBeTruthy();
|
||||
expect(type.instanceOf({
|
||||
getKey: function () { return 'some-other-type'; }
|
||||
getKey: function () {
|
||||
return 'some-other-type';
|
||||
}
|
||||
})).toBeFalsy();
|
||||
});
|
||||
|
||||
|
@ -109,7 +109,7 @@ define(
|
||||
it("restricts typed views to matching types", function () {
|
||||
var testType = "testType",
|
||||
testView = { key: "x", type: testType },
|
||||
provider = new ViewProvider([testView], mockLog);
|
||||
viewProvider = new ViewProvider([testView], mockLog);
|
||||
|
||||
// Include a "type" capability
|
||||
capabilities.type = jasmine.createSpyObj(
|
||||
@ -120,21 +120,21 @@ define(
|
||||
|
||||
// Should be included when types match
|
||||
capabilities.type.instanceOf.andReturn(true);
|
||||
expect(provider.getViews(mockDomainObject))
|
||||
expect(viewProvider.getViews(mockDomainObject))
|
||||
.toEqual([testView]);
|
||||
expect(capabilities.type.instanceOf)
|
||||
.toHaveBeenCalledWith(testType);
|
||||
|
||||
// ...but not when they don't
|
||||
capabilities.type.instanceOf.andReturn(false);
|
||||
expect(provider.getViews(mockDomainObject))
|
||||
expect(viewProvider.getViews(mockDomainObject))
|
||||
.toEqual([]);
|
||||
|
||||
});
|
||||
|
||||
it("enforces view restrictions from types", function () {
|
||||
var testView = { key: "x" },
|
||||
provider = new ViewProvider([testView], mockLog);
|
||||
viewProvider = new ViewProvider([testView], mockLog);
|
||||
|
||||
// Include a "type" capability
|
||||
capabilities.type = jasmine.createSpyObj(
|
||||
@ -146,13 +146,13 @@ define(
|
||||
// Should be included when view keys match
|
||||
capabilities.type.getDefinition
|
||||
.andReturn({ views: [testView.key]});
|
||||
expect(provider.getViews(mockDomainObject))
|
||||
expect(viewProvider.getViews(mockDomainObject))
|
||||
.toEqual([testView]);
|
||||
|
||||
// ...but not when they don't
|
||||
capabilities.type.getDefinition
|
||||
.andReturn({ views: ["somethingElse"]});
|
||||
expect(provider.getViews(mockDomainObject))
|
||||
expect(viewProvider.getViews(mockDomainObject))
|
||||
.toEqual([]);
|
||||
});
|
||||
|
||||
|
@ -126,11 +126,11 @@ define(
|
||||
|
||||
label = this.verb + " To";
|
||||
|
||||
validateLocation = function (newParent) {
|
||||
validateLocation = function (newParentObj) {
|
||||
var newContext = self.cloneContext();
|
||||
newContext.selectedObject = object;
|
||||
newContext.domainObject = newParent;
|
||||
return composeService.validate(object, newParent) &&
|
||||
newContext.domainObject = newParentObj;
|
||||
return composeService.validate(object, newParentObj) &&
|
||||
self.policyService.allow("action", self, newContext);
|
||||
};
|
||||
|
||||
@ -139,8 +139,8 @@ define(
|
||||
label,
|
||||
validateLocation,
|
||||
currentParent
|
||||
).then(function (newParent) {
|
||||
return composeService.perform(object, newParent);
|
||||
).then(function (newParentObj) {
|
||||
return composeService.perform(object, newParentObj);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -83,11 +83,11 @@ define(
|
||||
|
||||
// Combines caller-provided filter (if any) with the
|
||||
// baseline behavior of respecting creation policy.
|
||||
function filterWithPolicy(domainObject) {
|
||||
return (!filter || filter(domainObject)) &&
|
||||
function filterWithPolicy(domainObj) {
|
||||
return (!filter || filter(domainObj)) &&
|
||||
policyService.allow(
|
||||
"creation",
|
||||
domainObject.getCapability("type")
|
||||
domainObj.getCapability("type")
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,8 @@ define(
|
||||
// set, however linked objects will not.
|
||||
return composeChild(clonedComposee, clonedParent, clonedComposee !== originalComposee);
|
||||
});
|
||||
});}, self.$q.when(undefined)
|
||||
});
|
||||
}, self.$q.when(undefined)
|
||||
).then(function () {
|
||||
//Replace any references in the cloned parent to
|
||||
// contained objects that have been composed with the
|
||||
|
@ -67,7 +67,9 @@ define(
|
||||
.then(function (objectInNewContext) {
|
||||
return parentObject.getCapability('persistence')
|
||||
.persist()
|
||||
.then(function () { return objectInNewContext; });
|
||||
.then(function () {
|
||||
return objectInNewContext;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -77,8 +77,8 @@ define(
|
||||
|
||||
return dialogService
|
||||
.getUserInput(formStructure, formState)
|
||||
.then(function (formState) {
|
||||
return formState.location;
|
||||
.then(function (userFormState) {
|
||||
return userFormState.location;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -171,7 +171,9 @@ define(
|
||||
['notify', 'resolve', 'reject']
|
||||
);
|
||||
mockDeferred.notify.andCallFake(function () {});
|
||||
mockDeferred.resolve.andCallFake(function(value){resolvedValue = value;});
|
||||
mockDeferred.resolve.andCallFake(function (value) {
|
||||
resolvedValue = value;
|
||||
});
|
||||
mockDeferred.promise = {
|
||||
then: function (callback) {
|
||||
return synchronousPromise(callback(resolvedValue));
|
||||
@ -187,7 +189,9 @@ define(
|
||||
mockQ.all.andCallFake(function (promises) {
|
||||
var result = {};
|
||||
Object.keys(promises).forEach(function (k) {
|
||||
promises[k].then(function (v) { result[k] = v; });
|
||||
promises[k].then(function (v) {
|
||||
result[k] = v;
|
||||
});
|
||||
});
|
||||
return synchronousPromise(result);
|
||||
});
|
||||
@ -454,17 +458,17 @@ define(
|
||||
});
|
||||
|
||||
it("throws an error", function () {
|
||||
var copyService =
|
||||
var service =
|
||||
new CopyService(mockQ, policyService);
|
||||
|
||||
function perform() {
|
||||
copyService.perform(object, newParent);
|
||||
service.perform(object, newParent);
|
||||
}
|
||||
|
||||
spyOn(copyService, "validate");
|
||||
copyService.validate.andReturn(true);
|
||||
spyOn(service, "validate");
|
||||
service.validate.andReturn(true);
|
||||
expect(perform).not.toThrow();
|
||||
copyService.validate.andReturn(false);
|
||||
service.validate.andReturn(false);
|
||||
expect(perform).toThrow();
|
||||
});
|
||||
});
|
||||
|
@ -130,7 +130,9 @@ define(
|
||||
mockQ.all.andCallFake(function (promises) {
|
||||
return synchronousPromise(promises.map(function (promise) {
|
||||
var value;
|
||||
promise.then(function (v) { value = v; });
|
||||
promise.then(function (v) {
|
||||
value = v;
|
||||
});
|
||||
return value;
|
||||
}));
|
||||
});
|
||||
|
@ -76,7 +76,9 @@ define(
|
||||
mockQ.all.andCallFake(function (promises) {
|
||||
var result = {};
|
||||
Object.keys(promises).forEach(function (k) {
|
||||
promises[k].then(function (v) { result[k] = v; });
|
||||
promises[k].then(function (v) {
|
||||
result[k] = v;
|
||||
});
|
||||
});
|
||||
return testPromise(result);
|
||||
});
|
||||
|
@ -63,7 +63,9 @@ define(
|
||||
beforeEach(function () {
|
||||
title = "Get a location to do something";
|
||||
label = "a location";
|
||||
validate = function () { return true; };
|
||||
validate = function () {
|
||||
return true;
|
||||
};
|
||||
initialLocation = { key: "a key" };
|
||||
locationResult = locationService.getLocationFromUser(
|
||||
title,
|
||||
|
@ -27,7 +27,9 @@
|
||||
define(
|
||||
function () {
|
||||
|
||||
function identity(x) { return x; }
|
||||
function identity(x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* The PlotPreparer is responsible for handling data sets and
|
||||
|
@ -96,7 +96,9 @@ define(
|
||||
);
|
||||
|
||||
mockHandler.handle.andReturn(mockHandle);
|
||||
mockThrottle.andCallFake(function (fn) { return fn; });
|
||||
mockThrottle.andCallFake(function (fn) {
|
||||
return fn;
|
||||
});
|
||||
mockHandle.getTelemetryObjects.andReturn([mockDomainObject]);
|
||||
mockHandle.getMetadata.andReturn([{}]);
|
||||
mockHandle.getDomainValue.andReturn(123);
|
||||
|
@ -120,7 +120,7 @@ define(
|
||||
|
||||
it("on changes in form values, updates the object model", function () {
|
||||
var scopeConfiguration = mockScope.configuration,
|
||||
model = mockDomainObject.getModel();
|
||||
objModel = mockDomainObject.getModel();
|
||||
|
||||
scopeConfiguration.plot.yAxis.autoScale = true;
|
||||
scopeConfiguration.plot.yAxis.key = 'eu';
|
||||
@ -130,10 +130,10 @@ define(
|
||||
mockScope.$watchCollection.calls[0].args[1]();
|
||||
expect(mockDomainObject.useCapability).toHaveBeenCalledWith('mutation', jasmine.any(Function));
|
||||
|
||||
mockDomainObject.useCapability.mostRecentCall.args[1](model);
|
||||
expect(model.configuration.plot.yAxis.autoScale).toBe(true);
|
||||
expect(model.configuration.plot.yAxis.key).toBe('eu');
|
||||
expect(model.configuration.plot.xAxis.key).toBe('lst');
|
||||
mockDomainObject.useCapability.mostRecentCall.args[1](objModel);
|
||||
expect(objModel.configuration.plot.yAxis.autoScale).toBe(true);
|
||||
expect(objModel.configuration.plot.yAxis.key).toBe('eu');
|
||||
expect(objModel.configuration.plot.xAxis.key).toBe('lst');
|
||||
|
||||
});
|
||||
|
||||
|
@ -32,15 +32,15 @@ define(
|
||||
/**
|
||||
* Set default values for optional parameters on a given scope
|
||||
*/
|
||||
function setDefaults($scope) {
|
||||
if (typeof $scope.enableFilter === 'undefined') {
|
||||
$scope.enableFilter = true;
|
||||
$scope.filters = {};
|
||||
function setDefaults(scope) {
|
||||
if (typeof scope.enableFilter === 'undefined') {
|
||||
scope.enableFilter = true;
|
||||
scope.filters = {};
|
||||
}
|
||||
if (typeof $scope.enableSort === 'undefined') {
|
||||
$scope.enableSort = true;
|
||||
$scope.sortColumn = undefined;
|
||||
$scope.sortDirection = undefined;
|
||||
if (typeof scope.enableSort === 'undefined') {
|
||||
scope.enableSort = true;
|
||||
scope.sortColumn = undefined;
|
||||
scope.sortDirection = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@ -485,13 +485,13 @@ define(
|
||||
/**
|
||||
* Returns true if row matches all filters.
|
||||
*/
|
||||
function matchRow(filters, row) {
|
||||
return Object.keys(filters).every(function (key) {
|
||||
function matchRow(filterMap, row) {
|
||||
return Object.keys(filterMap).every(function (key) {
|
||||
if (!row[key]) {
|
||||
return false;
|
||||
}
|
||||
var testVal = String(row[key].text).toLowerCase();
|
||||
return testVal.indexOf(filters[key]) !== -1;
|
||||
return testVal.indexOf(filterMap[key]) !== -1;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ define(
|
||||
enableFilter: "=?",
|
||||
enableSort: "=?",
|
||||
autoScroll: "=?"
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ define(
|
||||
'column1': true,
|
||||
'column2': true,
|
||||
'column3': false,
|
||||
'column4': true,
|
||||
'column4': true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -52,25 +52,25 @@ define(
|
||||
// Set the start time associated with this object
|
||||
function setStart(value) {
|
||||
var end = getEnd();
|
||||
mutation.mutate(function (model) {
|
||||
model.start.timestamp = Math.max(value, 0);
|
||||
mutation.mutate(function (m) {
|
||||
m.start.timestamp = Math.max(value, 0);
|
||||
// Update duration to keep end time
|
||||
model.duration.timestamp = Math.max(end - value, 0);
|
||||
m.duration.timestamp = Math.max(end - value, 0);
|
||||
}, model.modified);
|
||||
}
|
||||
|
||||
// Set the duration associated with this object
|
||||
function setDuration(value) {
|
||||
mutation.mutate(function (model) {
|
||||
model.duration.timestamp = Math.max(value, 0);
|
||||
mutation.mutate(function (m) {
|
||||
m.duration.timestamp = Math.max(value, 0);
|
||||
}, model.modified);
|
||||
}
|
||||
|
||||
// Set the end time associated with this object
|
||||
function setEnd(value) {
|
||||
var start = getStart();
|
||||
mutation.mutate(function (model) {
|
||||
model.duration.timestamp = Math.max(value - start, 0);
|
||||
mutation.mutate(function (m) {
|
||||
m.duration.timestamp = Math.max(value - start, 0);
|
||||
}, model.modified);
|
||||
}
|
||||
|
||||
|
@ -53,21 +53,21 @@ define(
|
||||
|
||||
// Initialize the data values
|
||||
function initializeValues() {
|
||||
var values = [],
|
||||
var vals = [],
|
||||
slope = 0,
|
||||
i;
|
||||
|
||||
// Add a point (or points, if needed) reaching to the provided
|
||||
// domain and/or range value
|
||||
function addPoint(domain, range) {
|
||||
var previous = values[values.length - 1],
|
||||
var previous = vals[vals.length - 1],
|
||||
delta = domain - previous.domain, // time delta
|
||||
change = delta * slope * rate, // change
|
||||
next = previous.range + change;
|
||||
|
||||
// Crop to minimum boundary...
|
||||
if (next < minimum) {
|
||||
values.push({
|
||||
vals.push({
|
||||
domain: intercept(
|
||||
previous.domain,
|
||||
previous.range,
|
||||
@ -81,7 +81,7 @@ define(
|
||||
|
||||
// ...and maximum boundary
|
||||
if (next > maximum) {
|
||||
values.push({
|
||||
vals.push({
|
||||
domain: intercept(
|
||||
previous.domain,
|
||||
previous.range,
|
||||
@ -95,19 +95,19 @@ define(
|
||||
|
||||
// Add the new data value
|
||||
if (delta > 0) {
|
||||
values.push({ domain: domain, range: next });
|
||||
vals.push({ domain: domain, range: next });
|
||||
}
|
||||
|
||||
slope = range;
|
||||
}
|
||||
|
||||
values.push({ domain: 0, range: initial });
|
||||
vals.push({ domain: 0, range: initial });
|
||||
|
||||
for (i = 0; i < graph.getPointCount(); i += 1) {
|
||||
addPoint(graph.getDomainValue(i), graph.getRangeValue(i));
|
||||
}
|
||||
|
||||
return values;
|
||||
return vals;
|
||||
}
|
||||
|
||||
function convertToPercent(point) {
|
||||
|
@ -72,13 +72,13 @@ define(
|
||||
|
||||
// If there are sequences of points with the same timestamp,
|
||||
// allow only the first and last.
|
||||
function filterPoint(value, index, values) {
|
||||
function filterPoint(value, index, vals) {
|
||||
// Allow the first or last point as a base case; aside from
|
||||
// that, allow only points that have different timestamps
|
||||
// from their predecessor or successor.
|
||||
return (index === 0) || (index === values.length - 1) ||
|
||||
(value.domain !== values[index - 1].domain) ||
|
||||
(value.domain !== values[index + 1].domain);
|
||||
return (index === 0) || (index === vals.length - 1) ||
|
||||
(value.domain !== vals[index - 1].domain) ||
|
||||
(value.domain !== vals[index + 1].domain);
|
||||
}
|
||||
|
||||
// Add a step up or down (Step 3c above)
|
||||
|
@ -57,8 +57,8 @@ define(
|
||||
|
||||
// Set the start time associated with this object
|
||||
function setStart(value) {
|
||||
mutation.mutate(function (model) {
|
||||
model.start.timestamp = Math.max(value, 0);
|
||||
mutation.mutate(function (m) {
|
||||
m.start.timestamp = Math.max(value, 0);
|
||||
}, model.modified);
|
||||
}
|
||||
|
||||
|
@ -120,13 +120,13 @@ define(
|
||||
}
|
||||
|
||||
// Look up a specific object's resource utilization
|
||||
function lookupUtilization(domainObject) {
|
||||
return domainObject.useCapability('utilization');
|
||||
function lookupUtilization(object) {
|
||||
return object.useCapability('utilization');
|
||||
}
|
||||
|
||||
// Look up a specific object's resource utilization keys
|
||||
function lookupUtilizationResources(domainObject) {
|
||||
var utilization = domainObject.getCapability('utilization');
|
||||
function lookupUtilizationResources(object) {
|
||||
var utilization = object.getCapability('utilization');
|
||||
return utilization && utilization.resources();
|
||||
}
|
||||
|
||||
|
@ -47,19 +47,19 @@ define(
|
||||
}
|
||||
|
||||
// Get the timespan associated with this domain object
|
||||
function populateCapabilityMaps(domainObject) {
|
||||
var id = domainObject.getId(),
|
||||
timespanPromise = domainObject.useCapability('timespan');
|
||||
function populateCapabilityMaps(object) {
|
||||
var id = object.getId(),
|
||||
timespanPromise = object.useCapability('timespan');
|
||||
if (timespanPromise) {
|
||||
timespanPromise.then(function (timespan) {
|
||||
// Cache that timespan
|
||||
timespans[id] = timespan;
|
||||
// And its mutation capability
|
||||
mutations[id] = domainObject.getCapability('mutation');
|
||||
mutations[id] = object.getCapability('mutation');
|
||||
// Also cache the persistence capability for later
|
||||
persists[id] = domainObject.getCapability('persistence');
|
||||
persists[id] = object.getCapability('persistence');
|
||||
// And the composition, for bulk moves
|
||||
compositions[id] = domainObject.getModel().composition || [];
|
||||
compositions[id] = object.getModel().composition || [];
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -199,8 +199,8 @@ define(
|
||||
minStart;
|
||||
|
||||
// Update start & end, in that order
|
||||
function updateStartEnd(id) {
|
||||
var timespan = timespans[id], start, end;
|
||||
function updateStartEnd(spanId) {
|
||||
var timespan = timespans[spanId], start, end;
|
||||
if (timespan) {
|
||||
// Get start/end so we don't get fooled by our
|
||||
// own adjustments
|
||||
@ -210,7 +210,7 @@ define(
|
||||
timespan.setStart(start + delta);
|
||||
timespan.setEnd(end + delta);
|
||||
// Mark as dirty for subsequent persistence
|
||||
dirty[toId(id)] = true;
|
||||
dirty[toId(spanId)] = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,12 +228,12 @@ define(
|
||||
}
|
||||
|
||||
// Find the minimum start time
|
||||
minStart = Object.keys(ids).map(function (id) {
|
||||
minStart = Object.keys(ids).map(function (spanId) {
|
||||
// Get the start time; default to +Inf if not
|
||||
// found, since this will not survive a min
|
||||
// test if any real timespans are present
|
||||
return timespans[id] ?
|
||||
timespans[id].getStart() :
|
||||
return timespans[spanId] ?
|
||||
timespans[spanId].getStart() :
|
||||
Number.POSITIVE_INFINITY;
|
||||
}).reduce(function (a, b) {
|
||||
// Reduce with a minimum test
|
||||
|
@ -42,7 +42,9 @@ define(
|
||||
candidates;
|
||||
|
||||
// Filter an id for inclustion
|
||||
function include(id) { return id !== exclude; }
|
||||
function include(id) {
|
||||
return id !== exclude;
|
||||
}
|
||||
|
||||
// Evaluate a candidate timestamp as a snap-to location
|
||||
function evaluate(candidate) {
|
||||
|
@ -75,11 +75,14 @@ define(
|
||||
|
||||
// Look up resources for a domain object
|
||||
function lookupResources(swimlane) {
|
||||
var graphs = swimlane.domainObject.useCapability('graph');
|
||||
var graphPromise =
|
||||
swimlane.domainObject.useCapability('graph');
|
||||
function getKeys(obj) {
|
||||
return Object.keys(obj);
|
||||
}
|
||||
return $q.when(graphs ? (graphs.then(getKeys)) : []);
|
||||
return $q.when(
|
||||
graphPromise ? (graphPromise.then(getKeys)) : []
|
||||
);
|
||||
}
|
||||
|
||||
// Add all graph assignments appropriate for this swimlane
|
||||
|
@ -34,8 +34,8 @@ define(
|
||||
var actionMap = {};
|
||||
|
||||
// Populate available Create actions for this domain object
|
||||
function populateActionMap(domainObject) {
|
||||
var actionCapability = domainObject.getCapability('action'),
|
||||
function populateActionMap(object) {
|
||||
var actionCapability = object.getCapability('action'),
|
||||
actions = actionCapability ?
|
||||
actionCapability.getActions('add') : [];
|
||||
actions.forEach(function (action) {
|
||||
|
@ -47,9 +47,7 @@ define(
|
||||
depth = parent ? (parent.depth + 1) : 0,
|
||||
timespan,
|
||||
path = (!parent || !parent.parent) ? "" : parent.path +
|
||||
//(parent.path.length > 0 ? " / " : "") +
|
||||
parent.domainObject.getModel().name +
|
||||
" > ";
|
||||
parent.domainObject.getModel().name + " > ";
|
||||
|
||||
// Look up timespan for this object
|
||||
domainObject.useCapability('timespan').then(function (t) {
|
||||
|
@ -45,9 +45,9 @@ define(
|
||||
if (arguments.length > 0 && Array.isArray(value)) {
|
||||
if ((model.relationships || {})[ACTIVITY_RELATIONSHIP] !== value) {
|
||||
// Update the relationships
|
||||
mutator.mutate(function (model) {
|
||||
model.relationships = model.relationships || {};
|
||||
model.relationships[ACTIVITY_RELATIONSHIP] = value;
|
||||
mutator.mutate(function (m) {
|
||||
m.relationships = m.relationships || {};
|
||||
m.relationships[ACTIVITY_RELATIONSHIP] = value;
|
||||
}).then(persister.persist);
|
||||
}
|
||||
}
|
||||
@ -61,8 +61,8 @@ define(
|
||||
if (arguments.length > 0 && (typeof value === 'string') &&
|
||||
value !== model.link) {
|
||||
// Update the link
|
||||
mutator.mutate(function (model) {
|
||||
model.link = value;
|
||||
mutator.mutate(function (m) {
|
||||
m.link = value;
|
||||
}).then(persister.persist);
|
||||
}
|
||||
return model.link;
|
||||
|
@ -51,7 +51,7 @@ define(
|
||||
}
|
||||
|
||||
// Check if pathA entirely contains pathB
|
||||
function pathContains(swimlane, id) {
|
||||
function pathContains(swimlaneToCheck, id) {
|
||||
// Check if id at a specific index matches (for map below)
|
||||
function matches(pathId) {
|
||||
return pathId === id;
|
||||
@ -59,18 +59,18 @@ define(
|
||||
|
||||
// Path A contains Path B if it is longer, and all of
|
||||
// B's ids match the ids in A.
|
||||
return swimlane.idPath.map(matches).reduce(or, false);
|
||||
return swimlaneToCheck.idPath.map(matches).reduce(or, false);
|
||||
}
|
||||
|
||||
// Check if a swimlane contains a child with the specified id
|
||||
function contains(swimlane, id) {
|
||||
function contains(swimlaneToCheck, id) {
|
||||
// Check if a child swimlane has a matching domain object id
|
||||
function matches(child) {
|
||||
return child.domainObject.getId() === id;
|
||||
}
|
||||
|
||||
// Find any one child id that matches this id
|
||||
return swimlane.children.map(matches).reduce(or, false);
|
||||
return swimlaneToCheck.children.map(matches).reduce(or, false);
|
||||
}
|
||||
|
||||
// Initiate mutation of a domain object
|
||||
|
@ -61,8 +61,8 @@ define(
|
||||
swimlane;
|
||||
|
||||
// For the recursive step
|
||||
function populate(childSubgraph, index) {
|
||||
populateSwimlanes(childSubgraph, swimlane, index);
|
||||
function populate(childSubgraph, nextIndex) {
|
||||
populateSwimlanes(childSubgraph, swimlane, nextIndex);
|
||||
}
|
||||
|
||||
// Make sure we have a valid object instance...
|
||||
|
@ -41,13 +41,13 @@ define(
|
||||
filter;
|
||||
|
||||
// Check object existence (for criterion-less filtering)
|
||||
function exists(domainObject) {
|
||||
return !!domainObject;
|
||||
function exists(object) {
|
||||
return !!object;
|
||||
}
|
||||
|
||||
// Check for capability matching criterion
|
||||
function hasCapability(domainObject) {
|
||||
return domainObject && domainObject.hasCapability(criterion);
|
||||
function hasCapability(object) {
|
||||
return object && object.hasCapability(criterion);
|
||||
}
|
||||
|
||||
// For the recursive step...
|
||||
@ -61,8 +61,8 @@ define(
|
||||
}
|
||||
|
||||
// Avoid infinite recursion
|
||||
function notVisiting(domainObject) {
|
||||
return !visiting[domainObject.getId()];
|
||||
function notVisiting(object) {
|
||||
return !visiting[object.getId()];
|
||||
}
|
||||
|
||||
// Put the composition of this domain object into the result
|
||||
|
@ -55,8 +55,8 @@ define([
|
||||
if (!!model.composition) {
|
||||
mockDomainObject.useCapability.andCallFake(function (c) {
|
||||
return c === 'composition' &&
|
||||
Promise.resolve(model.composition.map(function (id) {
|
||||
return mockDomainObjects[id];
|
||||
Promise.resolve(model.composition.map(function (cid) {
|
||||
return mockDomainObjects[cid];
|
||||
}));
|
||||
});
|
||||
}
|
||||
@ -68,8 +68,8 @@ define([
|
||||
);
|
||||
mockRelationships.getRelatedObjects.andCallFake(function (k) {
|
||||
var ids = model.relationships[k] || [];
|
||||
return Promise.resolve(ids.map(function (id) {
|
||||
return mockDomainObjects[id];
|
||||
return Promise.resolve(ids.map(function (objId) {
|
||||
return mockDomainObjects[objId];
|
||||
}));
|
||||
});
|
||||
mockDomainObject.getCapability.andCallFake(function (c) {
|
||||
|
@ -67,8 +67,12 @@ define(
|
||||
mockQ.when.andCallFake(asPromise);
|
||||
mockQ.all.andCallFake(function (values) {
|
||||
var result = [];
|
||||
function addResult(v) { result.push(v); }
|
||||
function promiseResult(v) { asPromise(v).then(addResult); }
|
||||
function addResult(v) {
|
||||
result.push(v);
|
||||
}
|
||||
function promiseResult(v) {
|
||||
asPromise(v).then(addResult);
|
||||
}
|
||||
values.forEach(promiseResult);
|
||||
return asPromise(result);
|
||||
});
|
||||
|
@ -69,8 +69,8 @@ define(
|
||||
resources: function () {
|
||||
return Object.keys(costs).sort();
|
||||
},
|
||||
cost: function (c) {
|
||||
return costs[c];
|
||||
cost: function (k) {
|
||||
return costs[k];
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -61,7 +61,9 @@ define(
|
||||
mockTimespan.getDuration.andReturn(50);
|
||||
mockTimespan.getEnd.andReturn(150);
|
||||
|
||||
mockToPixels.andCallFake(function (t) { return t * 10; });
|
||||
mockToPixels.andCallFake(function (t) {
|
||||
return t * 10;
|
||||
});
|
||||
|
||||
controller = new TimelineGanttController(TEST_MAX_OFFSCREEN);
|
||||
});
|
||||
|
@ -90,7 +90,9 @@ define(
|
||||
mockScope.domainObject.getCapability.andCallFake(function (c) {
|
||||
if (c === 'editor') {
|
||||
return {
|
||||
inEditContext: function () {return true;}
|
||||
inEditContext: function () {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
});
|
||||
|
@ -56,22 +56,22 @@ define(
|
||||
}
|
||||
|
||||
function makeMockDomainObject(id, composition) {
|
||||
var mockDomainObject = jasmine.createSpyObj(
|
||||
var mockDomainObj = jasmine.createSpyObj(
|
||||
'domainObject-' + id,
|
||||
['getId', 'getModel', 'getCapability', 'useCapability']
|
||||
);
|
||||
|
||||
mockDomainObject.getId.andReturn(id);
|
||||
mockDomainObject.getModel.andReturn({ composition: composition });
|
||||
mockDomainObject.useCapability.andReturn(asPromise(mockTimespans[id]));
|
||||
mockDomainObject.getCapability.andCallFake(function (c) {
|
||||
mockDomainObj.getId.andReturn(id);
|
||||
mockDomainObj.getModel.andReturn({ composition: composition });
|
||||
mockDomainObj.useCapability.andReturn(asPromise(mockTimespans[id]));
|
||||
mockDomainObj.getCapability.andCallFake(function (c) {
|
||||
return {
|
||||
persistence: mockPersists[id],
|
||||
mutation: mockMutations[id]
|
||||
}[c];
|
||||
});
|
||||
|
||||
return mockDomainObject;
|
||||
return mockDomainObj;
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
|
@ -49,10 +49,14 @@ define(
|
||||
var colors = {}, i, ids = [];
|
||||
|
||||
// Add item to set
|
||||
function set(c) { colors[c] = true; }
|
||||
function set(c) {
|
||||
colors[c] = true;
|
||||
}
|
||||
|
||||
// Generate ids
|
||||
for (i = 0; i < 30; i += 1) { ids.push("id" + i); }
|
||||
for (i = 0; i < 30; i += 1) {
|
||||
ids.push("id" + i);
|
||||
}
|
||||
|
||||
// Assign colors to each id, then retrieve colors,
|
||||
// storing into the set
|
||||
|
@ -42,16 +42,16 @@ define(
|
||||
}
|
||||
|
||||
function makeMockDomainObject(id, composition) {
|
||||
var mockDomainObject = jasmine.createSpyObj(
|
||||
var mockDomainObj = jasmine.createSpyObj(
|
||||
'domainObject-' + id,
|
||||
['getId', 'getModel', 'getCapability', 'useCapability']
|
||||
);
|
||||
|
||||
mockDomainObject.getId.andReturn(id);
|
||||
mockDomainObject.getModel.andReturn({ composition: composition });
|
||||
mockDomainObject.useCapability.andReturn(asPromise(false));
|
||||
mockDomainObj.getId.andReturn(id);
|
||||
mockDomainObj.getModel.andReturn({ composition: composition });
|
||||
mockDomainObj.useCapability.andReturn(asPromise(false));
|
||||
|
||||
return mockDomainObject;
|
||||
return mockDomainObj;
|
||||
}
|
||||
|
||||
function subgraph(domainObject, objects) {
|
||||
|
@ -36,7 +36,9 @@ define(
|
||||
testConfiguration;
|
||||
|
||||
function asPromise(v) {
|
||||
return { then: function (cb) { cb(v); } };
|
||||
return { then: function (cb) {
|
||||
cb(v);
|
||||
} };
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
|
@ -82,8 +82,12 @@ define(
|
||||
mockQ.when.andCallFake(asPromise);
|
||||
mockQ.all.andCallFake(function (values) {
|
||||
var result = [];
|
||||
function addResult(v) { result.push(v); }
|
||||
function promiseResult(v) { asPromise(v).then(addResult); }
|
||||
function addResult(v) {
|
||||
result.push(v);
|
||||
}
|
||||
function promiseResult(v) {
|
||||
asPromise(v).then(addResult);
|
||||
}
|
||||
values.forEach(promiseResult);
|
||||
return asPromise(result);
|
||||
});
|
||||
|
@ -73,7 +73,9 @@ define(
|
||||
// loadBundleDefinition, so at this point they are safe
|
||||
// to discard.
|
||||
function filterBundles(array) {
|
||||
return array.filter(function (x) { return x !== undefined; });
|
||||
return array.filter(function (x) {
|
||||
return x !== undefined;
|
||||
});
|
||||
}
|
||||
|
||||
// Load a definition for a bundle
|
||||
|
@ -92,7 +92,9 @@ define(
|
||||
// Always return a static value; used to represent plain
|
||||
// metadata as a single dependency in Angular.
|
||||
function staticFunction(value) {
|
||||
return function () { return value; };
|
||||
return function () {
|
||||
return value;
|
||||
};
|
||||
}
|
||||
|
||||
// Utility function; create the second argument for Angular's
|
||||
@ -162,15 +164,15 @@ define(
|
||||
|
||||
// Examine a group of resolved dependencies to determine
|
||||
// which extension categories still need to be satisfied.
|
||||
function findEmptyExtensionDependencies(extensionGroup) {
|
||||
function findEmptyExtensionDependencies(extGroup) {
|
||||
var needed = {},
|
||||
categories = Object.keys(extensionGroup),
|
||||
categories = Object.keys(extGroup),
|
||||
allExtensions = [];
|
||||
|
||||
// Build up an array of all extensions
|
||||
categories.forEach(function (category) {
|
||||
allExtensions =
|
||||
allExtensions.concat(extensionGroup[category]);
|
||||
allExtensions.concat(extGroup[category]);
|
||||
});
|
||||
|
||||
// Track all extension dependencies exposed therefrom
|
||||
@ -195,10 +197,9 @@ define(
|
||||
// Register any extension categories that are depended-upon but
|
||||
// have not been declared anywhere; such dependencies are then
|
||||
// satisfied by an empty array, instead of not at all.
|
||||
function registerEmptyDependencies(extensionGroup) {
|
||||
findEmptyExtensionDependencies(
|
||||
extensionGroup
|
||||
).forEach(function (name) {
|
||||
function registerEmptyDependencies(extGroup) {
|
||||
findEmptyExtensionDependencies(extGroup)
|
||||
.forEach(function (name) {
|
||||
$log.info("Registering empty extension category " + name);
|
||||
app.factory(name, [staticFunction([])]);
|
||||
});
|
||||
|
@ -58,11 +58,11 @@ define(
|
||||
var loader = this.loader,
|
||||
$log = this.$log;
|
||||
|
||||
function loadImplementation(extension) {
|
||||
var implPromise = extension.hasImplementationValue() ?
|
||||
Promise.resolve(extension.getImplementationValue()) :
|
||||
loader.load(extension.getImplementationPath()),
|
||||
definition = extension.getDefinition();
|
||||
function loadImplementation(ext) {
|
||||
var implPromise = ext.hasImplementationValue() ?
|
||||
Promise.resolve(ext.getImplementationValue()) :
|
||||
loader.load(ext.getImplementationPath()),
|
||||
definition = ext.getDefinition();
|
||||
|
||||
// Wrap a constructor function (to avoid modifying the original)
|
||||
function constructorFor(impl) {
|
||||
@ -94,7 +94,7 @@ define(
|
||||
result.definition = definition;
|
||||
|
||||
// Log that this load was successful
|
||||
$log.info("Resolved " + extension.getLogName());
|
||||
$log.info("Resolved " + ext.getLogName());
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -105,7 +105,7 @@ define(
|
||||
// Build up a log message from parts
|
||||
var message = [
|
||||
"Could not load implementation for extension ",
|
||||
extension.getLogName(),
|
||||
ext.getLogName(),
|
||||
" due to ",
|
||||
err.message
|
||||
].join("");
|
||||
@ -113,16 +113,16 @@ define(
|
||||
// Log that the extension was not loaded
|
||||
$log.warn(message);
|
||||
|
||||
return extension.getDefinition();
|
||||
return ext.getDefinition();
|
||||
}
|
||||
|
||||
if (!extension.hasImplementationValue()) {
|
||||
if (!ext.hasImplementationValue()) {
|
||||
// Log that loading has begun
|
||||
$log.info([
|
||||
"Loading implementation ",
|
||||
extension.getImplementationPath(),
|
||||
ext.getImplementationPath(),
|
||||
" for extension ",
|
||||
extension.getLogName()
|
||||
ext.getLogName()
|
||||
].join(""));
|
||||
}
|
||||
|
||||
|
@ -50,10 +50,14 @@ define(
|
||||
it("calls injected stages in order", function () {
|
||||
var result;
|
||||
|
||||
initializer.runApplication([]).then(function (v) { result = v; });
|
||||
initializer.runApplication([]).then(function (v) {
|
||||
result = v;
|
||||
});
|
||||
|
||||
waitsFor(
|
||||
function () { return result !== undefined; },
|
||||
function () {
|
||||
return result !== undefined;
|
||||
},
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
|
@ -40,7 +40,9 @@ define(
|
||||
mockSorter = jasmine.createSpyObj("sorter", ["sort"]);
|
||||
customRegistrars = {};
|
||||
|
||||
mockSorter.sort.andCallFake(function (v) { return v; });
|
||||
mockSorter.sort.andCallFake(function (v) {
|
||||
return v;
|
||||
});
|
||||
|
||||
registrar = new ExtensionRegistrar(
|
||||
mockApp,
|
||||
@ -98,7 +100,9 @@ define(
|
||||
var a = { a: 'a' }, b = { b: 'b' }, c = { c: 'c' };
|
||||
|
||||
// Fake sorting; just reverse the array
|
||||
mockSorter.sort.andCallFake(function (v) { return v.reverse(); });
|
||||
mockSorter.sort.andCallFake(function (v) {
|
||||
return v.reverse();
|
||||
});
|
||||
|
||||
// Register the extensions
|
||||
registrar.registerExtensions({ things: [a, b, c] });
|
||||
|
@ -66,11 +66,21 @@ define(
|
||||
it("allows composite services to be registered", function () {
|
||||
// Prepare components that look like resolved extensions
|
||||
var components, name;
|
||||
function MyDecorator() { return {}; }
|
||||
function MyOtherDecorator() { return {}; }
|
||||
function MyProvider() { return {}; }
|
||||
function MyOtherProvider() { return {}; }
|
||||
function MyAggregator() { return {}; }
|
||||
function MyDecorator() {
|
||||
return {};
|
||||
}
|
||||
function MyOtherDecorator() {
|
||||
return {};
|
||||
}
|
||||
function MyProvider() {
|
||||
return {};
|
||||
}
|
||||
function MyOtherProvider() {
|
||||
return {};
|
||||
}
|
||||
function MyAggregator() {
|
||||
return {};
|
||||
}
|
||||
|
||||
components = [
|
||||
MyDecorator,
|
||||
@ -85,7 +95,9 @@ define(
|
||||
MyProvider.type = "provider";
|
||||
MyOtherProvider.type = "provider";
|
||||
MyAggregator.type = "aggregator";
|
||||
components.forEach(function (c) { c.provides = "testService"; });
|
||||
components.forEach(function (c) {
|
||||
c.provides = "testService";
|
||||
});
|
||||
|
||||
// Add some test dependencies, to check prepending
|
||||
MyOtherDecorator.depends = ["someOtherService"];
|
||||
@ -117,16 +129,24 @@ define(
|
||||
it("allows registered composite services to be instantiated", function () {
|
||||
// Prepare components that look like resolved extensions
|
||||
var components, name;
|
||||
function MyProvider() { return {}; }
|
||||
function MyOtherProvider() { return {}; }
|
||||
function MyAggregator() { return {}; }
|
||||
function MyProvider() {
|
||||
return {};
|
||||
}
|
||||
function MyOtherProvider() {
|
||||
return {};
|
||||
}
|
||||
function MyAggregator() {
|
||||
return {};
|
||||
}
|
||||
|
||||
components = [MyProvider, MyAggregator, MyOtherProvider];
|
||||
|
||||
MyProvider.type = "provider";
|
||||
MyOtherProvider.type = "provider";
|
||||
MyAggregator.type = "aggregator";
|
||||
components.forEach(function (c) { c.provides = "testService"; });
|
||||
components.forEach(function (c) {
|
||||
c.provides = "testService";
|
||||
});
|
||||
|
||||
// Register!
|
||||
compositor.registerCompositeServices(components);
|
||||
@ -149,9 +169,15 @@ define(
|
||||
it("warns and skips components with no service type", function () {
|
||||
// Prepare components that look like resolved extensions
|
||||
var components;
|
||||
function MyProvider() { return {}; }
|
||||
function MyDecorator() { return {}; }
|
||||
function MyAggregator() { return {}; }
|
||||
function MyProvider() {
|
||||
return {};
|
||||
}
|
||||
function MyDecorator() {
|
||||
return {};
|
||||
}
|
||||
function MyAggregator() {
|
||||
return {};
|
||||
}
|
||||
|
||||
components = [MyProvider, MyAggregator, MyDecorator];
|
||||
|
||||
@ -175,7 +201,9 @@ define(
|
||||
it("warns about and skips aggregators with zero providers", function () {
|
||||
// Prepare components that look like resolved extensions
|
||||
var components;
|
||||
function MyAggregator() { return {}; }
|
||||
function MyAggregator() {
|
||||
return {};
|
||||
}
|
||||
|
||||
components = [MyAggregator];
|
||||
|
||||
@ -195,7 +223,9 @@ define(
|
||||
it("warns about and skips decorators with nothing to decorate", function () {
|
||||
// Prepare components that look like resolved extensions
|
||||
var components;
|
||||
function MyDecorator() { return {}; }
|
||||
function MyDecorator() {
|
||||
return {};
|
||||
}
|
||||
|
||||
components = [MyDecorator];
|
||||
|
||||
|
@ -63,10 +63,14 @@ define(
|
||||
new Bundle("x", { extensions: { tests: [{}, {}, {}] } }),
|
||||
new Bundle("y", { extensions: { tests: [{}, {}], others: [{}, {}] } }),
|
||||
new Bundle("z", { extensions: { others: [{}] } })
|
||||
]).then(function (v) { result = v; });
|
||||
]).then(function (v) {
|
||||
result = v;
|
||||
});
|
||||
|
||||
waitsFor(
|
||||
function () { return result !== undefined; },
|
||||
function () {
|
||||
return result !== undefined;
|
||||
},
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
|
@ -33,7 +33,9 @@ define(
|
||||
resolver;
|
||||
|
||||
// Test implementation, to load from the mock loader
|
||||
function Constructor() { return { someKey: "some value" }; }
|
||||
function Constructor() {
|
||||
return { someKey: "some value" };
|
||||
}
|
||||
Constructor.someProperty = "some static value";
|
||||
|
||||
beforeEach(function () {
|
||||
@ -57,10 +59,14 @@ define(
|
||||
extension = bundle.getExtensions("tests")[0],
|
||||
result;
|
||||
|
||||
resolver.resolve(extension).then(function (v) { result = v; });
|
||||
resolver.resolve(extension).then(function (v) {
|
||||
result = v;
|
||||
});
|
||||
|
||||
waitsFor(
|
||||
function () { return result !== undefined; },
|
||||
function () {
|
||||
return result !== undefined;
|
||||
},
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
@ -88,10 +94,14 @@ define(
|
||||
result;
|
||||
|
||||
mockLoader.load.andReturn(Promise.reject(new Error("test error")));
|
||||
resolver.resolve(extension).then(function (v) { result = v; });
|
||||
resolver.resolve(extension).then(function (v) {
|
||||
result = v;
|
||||
});
|
||||
|
||||
waitsFor(
|
||||
function () { return result !== undefined; },
|
||||
function () {
|
||||
return result !== undefined;
|
||||
},
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
@ -114,10 +124,14 @@ define(
|
||||
extension = bundle.getExtensions("tests")[0],
|
||||
result;
|
||||
|
||||
resolver.resolve(extension).then(function (v) { result = v; });
|
||||
resolver.resolve(extension).then(function (v) {
|
||||
result = v;
|
||||
});
|
||||
|
||||
waitsFor(
|
||||
function () { return result !== undefined; },
|
||||
function () {
|
||||
return result !== undefined;
|
||||
},
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
|
@ -53,14 +53,18 @@ define(
|
||||
var result;
|
||||
|
||||
// Load and get the result
|
||||
loader.load("xyz.js").then(function (v) { result = v; });
|
||||
loader.load("xyz.js").then(function (v) {
|
||||
result = v;
|
||||
});
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
|
||||
required.fulfill("test result");
|
||||
|
||||
waitsFor(
|
||||
function () { return result !== undefined; },
|
||||
function () {
|
||||
return result !== undefined;
|
||||
},
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
@ -76,8 +80,12 @@ define(
|
||||
|
||||
// Load and get the result
|
||||
loader.load("xyz.js").then(
|
||||
function (v) { result = v; },
|
||||
function (v) { rejection = v; }
|
||||
function (v) {
|
||||
result = v;
|
||||
},
|
||||
function (v) {
|
||||
rejection = v;
|
||||
}
|
||||
);
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
@ -85,7 +93,9 @@ define(
|
||||
required.reject("test result");
|
||||
|
||||
waitsFor(
|
||||
function () { return rejection !== undefined; },
|
||||
function () {
|
||||
return rejection !== undefined;
|
||||
},
|
||||
"promise resolution",
|
||||
250
|
||||
);
|
||||
|
@ -61,7 +61,9 @@ define(
|
||||
}
|
||||
|
||||
this.providerMapPromise = $q.all(providers.map(addToMap))
|
||||
.then(function () { return providerMap; });
|
||||
.then(function () {
|
||||
return providerMap;
|
||||
});
|
||||
}
|
||||
|
||||
PersistenceAggregator.prototype.listSpaces = function () {
|
||||
|
@ -70,7 +70,9 @@ define(
|
||||
mockQ.all.andCallFake(function (fakePromises) {
|
||||
var result = [];
|
||||
fakePromises.forEach(function (p) {
|
||||
p.then(function (v) { result.push(v); });
|
||||
p.then(function (v) {
|
||||
result.push(v);
|
||||
});
|
||||
});
|
||||
return fakePromise(result);
|
||||
});
|
||||
|
@ -57,7 +57,9 @@ define(
|
||||
// Pull out a list of document IDs from CouchDB's
|
||||
// _all_docs response
|
||||
function getIdsFromAllDocs(allDocs) {
|
||||
return allDocs.rows.map(function (r) { return r.id; });
|
||||
return allDocs.rows.map(function (r) {
|
||||
return r.id;
|
||||
});
|
||||
}
|
||||
|
||||
// Check the response to a create/update/delete request;
|
||||
|
@ -92,8 +92,8 @@ define(
|
||||
if ((response || {}).status === CONFLICT) {
|
||||
error.key = "revision";
|
||||
// Load the updated model, then reject the promise
|
||||
return this.get(key).then(function (response) {
|
||||
error.model = response[SRC];
|
||||
return this.get(key).then(function (res) {
|
||||
error.model = res[SRC];
|
||||
return $q.reject(error);
|
||||
});
|
||||
}
|
||||
|
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