Update test specs to use Jasmine 3 (#2089)
* Updated Karma and Jasmine versions * Added DOMObserver class. Supports promise-based testing of DOM changes Update asynchronous test specs to use promises or done() instead of waitsFor/runs * Modified ActionCapability to duplicate context object properties as own properties for better object equality comparisons * Global find + replace to fix syntax issues * Fixed various issues caused by non-deterministic runtime order of tests in Jasmine 3. Fixed issues caused by changes to determination of object equality * Addressed review comments * Resolved merge conflicts with master * Fixed style errors * Use spy.calls.count() instead of manually tracking
This commit is contained in:
committed by
Pete Richards
parent
013eba744d
commit
433dee0314
@@ -54,7 +54,7 @@ define(
|
||||
['getId', 'getModel', 'getCapability']
|
||||
);
|
||||
testModel = { composition: TEST_IDS };
|
||||
mockDomainObject.getModel.andReturn(testModel);
|
||||
mockDomainObject.getModel.and.returnValue(testModel);
|
||||
});
|
||||
|
||||
it("returns a corresponding value from the map", function () {
|
||||
|
||||
@@ -32,7 +32,8 @@ define(
|
||||
mockType,
|
||||
testContext,
|
||||
testType,
|
||||
action;
|
||||
action,
|
||||
actionPromise;
|
||||
|
||||
beforeEach(function () {
|
||||
mockDomainObject = jasmine.createSpyObj(
|
||||
@@ -60,11 +61,11 @@ define(
|
||||
['dismiss']
|
||||
);
|
||||
|
||||
mockNotificationService.notify.andReturn(mockNotification);
|
||||
mockNotificationService.notify.and.returnValue(mockNotification);
|
||||
|
||||
mockDomainObject.hasCapability.andReturn(true);
|
||||
mockDomainObject.getCapability.andReturn(mockType);
|
||||
mockType.instanceOf.andCallFake(function (type) {
|
||||
mockDomainObject.hasCapability.and.returnValue(true);
|
||||
mockDomainObject.getCapability.and.returnValue(mockType);
|
||||
mockType.instanceOf.and.callFake(function (type) {
|
||||
return type === testType;
|
||||
});
|
||||
|
||||
@@ -92,14 +93,12 @@ define(
|
||||
});
|
||||
|
||||
describe("when performed", function () {
|
||||
var testPromise,
|
||||
mockCallback;
|
||||
var testPromise;
|
||||
|
||||
beforeEach(function () {
|
||||
mockCallback = jasmine.createSpy('callback');
|
||||
// White-boxy; we know most work is delegated
|
||||
// to the associated Task, so stub out that interaction.
|
||||
spyOn(action.task, "run").andCallFake(function () {
|
||||
spyOn(action.task, "run").and.callFake(function () {
|
||||
return new Promise(function (resolve, reject) {
|
||||
testPromise = {
|
||||
resolve: resolve,
|
||||
@@ -107,7 +106,7 @@ define(
|
||||
};
|
||||
});
|
||||
});
|
||||
action.perform().then(mockCallback);
|
||||
actionPromise = action.perform();
|
||||
});
|
||||
|
||||
it("shows a notification", function () {
|
||||
@@ -122,9 +121,7 @@ define(
|
||||
describe("and completed", function () {
|
||||
beforeEach(function () {
|
||||
testPromise.resolve();
|
||||
waitsFor(function () {
|
||||
return mockCallback.calls.length > 0;
|
||||
});
|
||||
return actionPromise;
|
||||
});
|
||||
|
||||
it("dismisses the displayed notification", function () {
|
||||
@@ -144,9 +141,8 @@ define(
|
||||
beforeEach(function () {
|
||||
testError = { someProperty: "some value" };
|
||||
testPromise.reject(testError);
|
||||
waitsFor(function () {
|
||||
return mockCallback.calls.length > 0;
|
||||
});
|
||||
|
||||
return actionPromise;
|
||||
});
|
||||
|
||||
it("dismisses the displayed notification", function () {
|
||||
|
||||
@@ -47,8 +47,8 @@ define(
|
||||
]
|
||||
);
|
||||
|
||||
mockDomainObject.getId.andReturn('mock');
|
||||
mockDomainObject.getModel.andReturn({});
|
||||
mockDomainObject.getId.and.returnValue('mock');
|
||||
mockDomainObject.getModel.and.returnValue({});
|
||||
|
||||
task = new ExportTimelineAsCSVTask(
|
||||
mockExportService,
|
||||
@@ -58,14 +58,9 @@ define(
|
||||
});
|
||||
|
||||
describe("when run", function () {
|
||||
var mockCallback;
|
||||
|
||||
beforeEach(function () {
|
||||
mockCallback = jasmine.createSpy('callback');
|
||||
task.run().then(mockCallback);
|
||||
waitsFor(function () {
|
||||
return mockCallback.calls.length > 0;
|
||||
});
|
||||
return task.run();
|
||||
});
|
||||
|
||||
it("exports to CSV", function () {
|
||||
|
||||
@@ -46,7 +46,7 @@ define(
|
||||
'domainObject',
|
||||
['getId', 'getModel', 'getCapability']
|
||||
);
|
||||
mockDomainObject.getId.andReturn(testId);
|
||||
mockDomainObject.getId.and.returnValue(testId);
|
||||
});
|
||||
|
||||
it("provides a value mapped from domain object's identifier", function () {
|
||||
|
||||
@@ -54,7 +54,7 @@ define(
|
||||
testIndex = 1;
|
||||
testMetadata[testIndex].name = testName;
|
||||
|
||||
mockDomainObject.useCapability.andCallFake(function (c) {
|
||||
mockDomainObject.useCapability.and.callFake(function (c) {
|
||||
return (c === 'metadata') && testMetadata;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -58,7 +58,7 @@ define(
|
||||
modes: TEST_IDS
|
||||
}
|
||||
};
|
||||
mockDomainObject.getModel.andReturn(testModel);
|
||||
mockDomainObject.getModel.and.returnValue(testModel);
|
||||
});
|
||||
|
||||
it("returns a corresponding value from the map", function () {
|
||||
|
||||
@@ -39,9 +39,9 @@ define(
|
||||
'getModel'
|
||||
]
|
||||
);
|
||||
mockDomainObject.getId.andReturn('id-' + index);
|
||||
mockDomainObject.getModel.andReturn(model);
|
||||
mockDomainObject.useCapability.andCallFake(function (c) {
|
||||
mockDomainObject.getId.and.returnValue('id-' + index);
|
||||
mockDomainObject.getModel.and.returnValue(model);
|
||||
mockDomainObject.useCapability.and.callFake(function (c) {
|
||||
return c === 'metadata' && [];
|
||||
});
|
||||
return mockDomainObject;
|
||||
@@ -64,14 +64,14 @@ define(
|
||||
{ }
|
||||
].map(makeMockDomainObject);
|
||||
|
||||
mockDomainObjects[1].hasCapability.andCallFake(function (c) {
|
||||
mockDomainObjects[1].hasCapability.and.callFake(function (c) {
|
||||
return c === 'timespan';
|
||||
});
|
||||
mockDomainObjects[1].useCapability.andCallFake(function (c) {
|
||||
mockDomainObjects[1].useCapability.and.callFake(function (c) {
|
||||
return c === 'timespan' ? Promise.resolve(mockTimespan) :
|
||||
c === 'metadata' ? [] : undefined;
|
||||
});
|
||||
mockDomainObjects[2].useCapability.andCallFake(function (c) {
|
||||
mockDomainObjects[2].useCapability.and.callFake(function (c) {
|
||||
return c === 'metadata' && testMetadata;
|
||||
});
|
||||
|
||||
@@ -82,12 +82,9 @@ define(
|
||||
var rows;
|
||||
|
||||
beforeEach(function () {
|
||||
exporter.rows().then(function (r) {
|
||||
return exporter.rows().then(function (r) {
|
||||
rows = r;
|
||||
});
|
||||
waitsFor(function () {
|
||||
return rows !== undefined;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -43,17 +43,17 @@ define([
|
||||
mockRelationships,
|
||||
model = testModels[id];
|
||||
|
||||
mockDomainObject.getId.andReturn(id);
|
||||
mockDomainObject.getModel.andReturn(model);
|
||||
mockDomainObject.getId.and.returnValue(id);
|
||||
mockDomainObject.getModel.and.returnValue(model);
|
||||
|
||||
mockDomainObject.hasCapability.andCallFake(function (c) {
|
||||
mockDomainObject.hasCapability.and.callFake(function (c) {
|
||||
return c === 'composition' ? !!model.composition :
|
||||
c === 'relationship' ? !!model.relationships :
|
||||
false;
|
||||
});
|
||||
|
||||
if (!!model.composition) {
|
||||
mockDomainObject.useCapability.andCallFake(function (c) {
|
||||
mockDomainObject.useCapability.and.callFake(function (c) {
|
||||
return c === 'composition' &&
|
||||
Promise.resolve(model.composition.map(function (cid) {
|
||||
return mockDomainObjects[cid];
|
||||
@@ -66,13 +66,13 @@ define([
|
||||
'relationship',
|
||||
['getRelatedObjects']
|
||||
);
|
||||
mockRelationships.getRelatedObjects.andCallFake(function (k) {
|
||||
mockRelationships.getRelatedObjects.and.callFake(function (k) {
|
||||
var ids = model.relationships[k] || [];
|
||||
return Promise.resolve(ids.map(function (objId) {
|
||||
return mockDomainObjects[objId];
|
||||
}));
|
||||
});
|
||||
mockDomainObject.getCapability.andCallFake(function (c) {
|
||||
mockDomainObject.getCapability.and.callFake(function (c) {
|
||||
return c === 'relationship' && mockRelationships;
|
||||
});
|
||||
}
|
||||
@@ -105,12 +105,9 @@ define([
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
traverser.buildObjectList().then(function (objectList) {
|
||||
return traverser.buildObjectList().then(function (objectList) {
|
||||
objects = objectList;
|
||||
});
|
||||
waitsFor(function () {
|
||||
return objects !== undefined;
|
||||
});
|
||||
});
|
||||
|
||||
it("includes the object originally passed in", function () {
|
||||
|
||||
@@ -42,12 +42,12 @@ define(
|
||||
'domainObject',
|
||||
['useCapability', 'hasCapability']
|
||||
);
|
||||
mockTimespan.getStart.andReturn(testTimes.start);
|
||||
mockTimespan.getEnd.andReturn(testTimes.end);
|
||||
mockDomainObject.useCapability.andCallFake(function (c) {
|
||||
mockTimespan.getStart.and.returnValue(testTimes.start);
|
||||
mockTimespan.getEnd.and.returnValue(testTimes.end);
|
||||
mockDomainObject.useCapability.and.callFake(function (c) {
|
||||
return c === 'timespan' && Promise.resolve(mockTimespan);
|
||||
});
|
||||
mockDomainObject.hasCapability.andCallFake(function (c) {
|
||||
mockDomainObject.hasCapability.and.callFake(function (c) {
|
||||
return c === 'timespan';
|
||||
});
|
||||
});
|
||||
@@ -71,12 +71,9 @@ define(
|
||||
beforeEach(function () {
|
||||
value = undefined;
|
||||
testFormatter = new TimelineFormatter();
|
||||
column.value(mockDomainObject).then(function (v) {
|
||||
return column.value(mockDomainObject).then(function (v) {
|
||||
value = v;
|
||||
});
|
||||
waitsFor(function () {
|
||||
return value !== undefined;
|
||||
});
|
||||
});
|
||||
|
||||
it("returns a formatted " + bound + " time", function () {
|
||||
|
||||
@@ -44,8 +44,8 @@ define(
|
||||
['getModel', 'getCapability']
|
||||
);
|
||||
|
||||
mockQ.when.andCallFake(asPromise);
|
||||
mockDomainObject.getModel.andReturn({
|
||||
mockQ.when.and.callFake(asPromise);
|
||||
mockDomainObject.getModel.and.returnValue({
|
||||
start: {
|
||||
timestamp: 42000,
|
||||
epoch: "TEST"
|
||||
|
||||
@@ -47,7 +47,7 @@ define(
|
||||
// not intended usage.)
|
||||
mutatorModel = JSON.parse(JSON.stringify(testModel));
|
||||
mockMutation = jasmine.createSpyObj("mutation", ["mutate"]);
|
||||
mockMutation.mutate.andCallFake(function (mutator) {
|
||||
mockMutation.mutate.and.callFake(function (mutator) {
|
||||
mutator(mutatorModel);
|
||||
});
|
||||
timespan = new ActivityTimespan(testModel, mockMutation);
|
||||
|
||||
@@ -42,7 +42,7 @@ define(
|
||||
}
|
||||
};
|
||||
|
||||
mockDomainObject.getModel.andReturn(testModel);
|
||||
mockDomainObject.getModel.and.returnValue(testModel);
|
||||
|
||||
capability = new CostCapability(mockDomainObject);
|
||||
});
|
||||
|
||||
@@ -37,11 +37,11 @@ define(
|
||||
['getPointCount', 'getDomainValue', 'getRangeValue']
|
||||
);
|
||||
|
||||
mockGraph.getPointCount.andReturn(points.length * 2);
|
||||
mockGraph.getDomainValue.andCallFake(function (i) {
|
||||
mockGraph.getPointCount.and.returnValue(points.length * 2);
|
||||
mockGraph.getDomainValue.and.callFake(function (i) {
|
||||
return Math.floor(i / 2) * 100 + 25;
|
||||
});
|
||||
mockGraph.getRangeValue.andCallFake(function (i) {
|
||||
mockGraph.getRangeValue.and.callFake(function (i) {
|
||||
return points[Math.floor(i / 2) + i % 2];
|
||||
});
|
||||
|
||||
|
||||
@@ -53,8 +53,8 @@ define(
|
||||
}
|
||||
};
|
||||
|
||||
mockQ.when.andCallFake(asPromise);
|
||||
mockDomainObject.getModel.andReturn(testModel);
|
||||
mockQ.when.and.callFake(asPromise);
|
||||
mockDomainObject.getModel.and.returnValue(testModel);
|
||||
|
||||
capability = new GraphCapability(
|
||||
mockQ,
|
||||
@@ -82,7 +82,7 @@ define(
|
||||
it("provides one graph per resource type", function () {
|
||||
var mockCallback = jasmine.createSpy('callback');
|
||||
|
||||
mockDomainObject.useCapability.andReturn(asPromise([
|
||||
mockDomainObject.useCapability.and.returnValue(asPromise([
|
||||
{ key: "abc", start: 0, end: 15 },
|
||||
{ key: "abc", start: 0, end: 15 },
|
||||
{ key: "def", start: 4, end: 15 },
|
||||
@@ -103,7 +103,7 @@ define(
|
||||
testModel.capacity = 1000;
|
||||
testModel.startingSOC = 100;
|
||||
testModel.type = "timeline";
|
||||
mockDomainObject.useCapability.andReturn(asPromise([
|
||||
mockDomainObject.useCapability.and.returnValue(asPromise([
|
||||
{ key: "power", start: 0, end: 15 }
|
||||
]));
|
||||
capability.invoke().then(mockCallback);
|
||||
|
||||
@@ -64,8 +64,8 @@ define(
|
||||
['getEnd']
|
||||
);
|
||||
|
||||
mockQ.when.andCallFake(asPromise);
|
||||
mockQ.all.andCallFake(function (values) {
|
||||
mockQ.when.and.callFake(asPromise);
|
||||
mockQ.all.and.callFake(function (values) {
|
||||
var result = [];
|
||||
function addResult(v) {
|
||||
result.push(v);
|
||||
@@ -76,7 +76,7 @@ define(
|
||||
values.forEach(promiseResult);
|
||||
return asPromise(result);
|
||||
});
|
||||
mockDomainObject.getModel.andReturn({
|
||||
mockDomainObject.getModel.and.returnValue({
|
||||
start: {
|
||||
timestamp: 42000,
|
||||
epoch: "TEST"
|
||||
@@ -85,17 +85,17 @@ define(
|
||||
timestamp: 12321
|
||||
}
|
||||
});
|
||||
mockDomainObject.useCapability.andCallFake(function (c) {
|
||||
mockDomainObject.useCapability.and.callFake(function (c) {
|
||||
if (c === 'composition') {
|
||||
return asPromise([mockChildA, mockChildB]);
|
||||
}
|
||||
});
|
||||
mockChildA.hasCapability.andReturn(true);
|
||||
mockChildB.hasCapability.andReturn(true);
|
||||
mockChildA.useCapability.andCallFake(function (c) {
|
||||
mockChildA.hasCapability.and.returnValue(true);
|
||||
mockChildB.hasCapability.and.returnValue(true);
|
||||
mockChildA.useCapability.and.callFake(function (c) {
|
||||
return c === 'timespan' && mockTimespanA;
|
||||
});
|
||||
mockChildB.useCapability.andCallFake(function (c) {
|
||||
mockChildB.useCapability.and.callFake(function (c) {
|
||||
return c === 'timespan' && mockTimespanB;
|
||||
});
|
||||
|
||||
@@ -129,7 +129,7 @@ define(
|
||||
getEpoch: jasmine.any(Function)
|
||||
});
|
||||
// Finally, verify that getEnd recurses
|
||||
mockCallback.mostRecentCall.args[0].getEnd();
|
||||
mockCallback.calls.mostRecent().args[0].getEnd();
|
||||
expect(mockTimespanA.getEnd).toHaveBeenCalled();
|
||||
expect(mockTimespanB.getEnd).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -36,7 +36,7 @@ define(
|
||||
'timespan-' + end,
|
||||
['getEnd']
|
||||
);
|
||||
mockTimespan.getEnd.andReturn(end);
|
||||
mockTimespan.getEnd.and.returnValue(end);
|
||||
return mockTimespan;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ define(
|
||||
mockMutation = jasmine.createSpyObj("mutation", ["mutate"]);
|
||||
mockTimespans = [44000, 65000, 1100].map(makeMockTimespan);
|
||||
|
||||
mockMutation.mutate.andCallFake(function (mutator) {
|
||||
mockMutation.mutate.and.callFake(function (mutator) {
|
||||
mutator(mutationModel);
|
||||
});
|
||||
|
||||
|
||||
@@ -108,13 +108,13 @@ define(
|
||||
relationship: mockRelationship
|
||||
};
|
||||
|
||||
mockQ.when.andCallFake(asPromise);
|
||||
mockQ.all.andCallFake(allPromises);
|
||||
mockDomainObject.getModel.andReturn(testModel);
|
||||
mockDomainObject.getCapability.andCallFake(function (c) {
|
||||
mockQ.when.and.callFake(asPromise);
|
||||
mockQ.all.and.callFake(allPromises);
|
||||
mockDomainObject.getModel.and.returnValue(testModel);
|
||||
mockDomainObject.getCapability.and.callFake(function (c) {
|
||||
return testCapabilities[c];
|
||||
});
|
||||
mockDomainObject.useCapability.andCallFake(function (c) {
|
||||
mockDomainObject.useCapability.and.callFake(function (c) {
|
||||
return testCapabilities[c] && testCapabilities[c].invoke();
|
||||
});
|
||||
|
||||
@@ -142,7 +142,7 @@ define(
|
||||
});
|
||||
|
||||
it("accumulates resources from composition", function () {
|
||||
mockComposition.invoke.andReturn(asPromise([
|
||||
mockComposition.invoke.and.returnValue(asPromise([
|
||||
fakeDomainObject(['abc', 'def']),
|
||||
fakeDomainObject(['def', 'xyz']),
|
||||
fakeDomainObject(['abc', 'xyz'])
|
||||
@@ -155,7 +155,7 @@ define(
|
||||
});
|
||||
|
||||
it("accumulates utilizations from composition", function () {
|
||||
mockComposition.invoke.andReturn(asPromise([
|
||||
mockComposition.invoke.and.returnValue(asPromise([
|
||||
fakeDomainObject(['abc', 'def'], 10, 100),
|
||||
fakeDomainObject(['def', 'xyz'], 50, 90)
|
||||
]));
|
||||
@@ -179,16 +179,16 @@ define(
|
||||
'timespanCapability',
|
||||
['invoke']
|
||||
);
|
||||
mockComposition.invoke.andReturn(asPromise([]));
|
||||
mockRelationship.getRelatedObjects.andReturn(asPromise([
|
||||
mockComposition.invoke.and.returnValue(asPromise([]));
|
||||
mockRelationship.getRelatedObjects.and.returnValue(asPromise([
|
||||
fakeDomainObject([], 0, 0, { abc: 5, xyz: 15 })
|
||||
]));
|
||||
|
||||
testCapabilities.timespan = mockTimespanCapability;
|
||||
mockTimespanCapability.invoke.andReturn(asPromise(mockTimespan));
|
||||
mockTimespan.getStart.andReturn(42);
|
||||
mockTimespan.getEnd.andReturn(12321);
|
||||
mockTimespan.getEpoch.andReturn("TEST");
|
||||
mockTimespanCapability.invoke.and.returnValue(asPromise(mockTimespan));
|
||||
mockTimespan.getStart.and.returnValue(42);
|
||||
mockTimespan.getEnd.and.returnValue(12321);
|
||||
mockTimespan.getEpoch.and.returnValue("TEST");
|
||||
|
||||
capability.invoke().then(mockCallback);
|
||||
|
||||
@@ -199,8 +199,8 @@ define(
|
||||
});
|
||||
|
||||
it("provides resource keys from related objects", function () {
|
||||
mockComposition.invoke.andReturn(asPromise([]));
|
||||
mockRelationship.getRelatedObjects.andReturn(asPromise([
|
||||
mockComposition.invoke.and.returnValue(asPromise([]));
|
||||
mockRelationship.getRelatedObjects.and.returnValue(asPromise([
|
||||
fakeDomainObject([], 0, 0, { abc: 5, xyz: 15 })
|
||||
]));
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ define(
|
||||
"fillRect"
|
||||
]
|
||||
);
|
||||
mockCanvas.getContext.andReturn(mock2d);
|
||||
mockCanvas.getContext.and.returnValue(mock2d);
|
||||
|
||||
chart = new Canvas2DChart(mockCanvas);
|
||||
});
|
||||
@@ -60,7 +60,7 @@ define(
|
||||
});
|
||||
|
||||
it("does not construct if 2D is unavailable", function () {
|
||||
mockCanvas.getContext.andReturn(undefined);
|
||||
mockCanvas.getContext.and.returnValue(undefined);
|
||||
expect(function () {
|
||||
return new Canvas2DChart(mockCanvas);
|
||||
}).toThrow();
|
||||
@@ -77,7 +77,7 @@ define(
|
||||
testPoints = 2;
|
||||
chart.drawLine(testBuffer, testColor, testPoints);
|
||||
expect(mock2d.beginPath).toHaveBeenCalled();
|
||||
expect(mock2d.lineTo.calls.length).toEqual(1);
|
||||
expect(mock2d.lineTo.calls.count()).toEqual(1);
|
||||
expect(mock2d.stroke).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
||||
@@ -68,11 +68,11 @@ define(
|
||||
|
||||
// Echo back names for uniform locations, so we can
|
||||
// test which of these are set for certain operations.
|
||||
mockGL.getUniformLocation.andCallFake(function (a, name) {
|
||||
mockGL.getUniformLocation.and.callFake(function (a, name) {
|
||||
return name;
|
||||
});
|
||||
|
||||
mockCanvas.getContext.andReturn(mockGL);
|
||||
mockCanvas.getContext.and.returnValue(mockGL);
|
||||
|
||||
glChart = new GLChart(mockCanvas);
|
||||
});
|
||||
@@ -83,7 +83,7 @@ define(
|
||||
});
|
||||
|
||||
it("does not construct if WebGL is unavailable", function () {
|
||||
mockCanvas.getContext.andReturn(undefined);
|
||||
mockCanvas.getContext.and.returnValue(undefined);
|
||||
expect(function () {
|
||||
return new GLChart(mockCanvas);
|
||||
}).toThrow();
|
||||
|
||||
@@ -91,15 +91,15 @@ define(
|
||||
|
||||
// Echo back names for uniform locations, so we can
|
||||
// test which of these are set for certain operations.
|
||||
mockGL.getUniformLocation.andCallFake(function (a, name) {
|
||||
mockGL.getUniformLocation.and.callFake(function (a, name) {
|
||||
return name;
|
||||
});
|
||||
|
||||
mockElement.find.andReturn([mockCanvas]);
|
||||
mockCanvas.getContext.andCallFake(function (type) {
|
||||
mockElement.find.and.returnValue([mockCanvas]);
|
||||
mockCanvas.getContext.and.callFake(function (type) {
|
||||
return { webgl: mockGL, '2d': mockC2d }[type];
|
||||
});
|
||||
mockInterval.andReturn(mockPromise);
|
||||
mockInterval.and.returnValue(mockPromise);
|
||||
|
||||
mctChart = new MCTTimelineChart(mockInterval, mockLog);
|
||||
});
|
||||
@@ -121,15 +121,15 @@ define(
|
||||
|
||||
it("issues one draw call per line", function () {
|
||||
mctChart.link(mockScope, mockElement);
|
||||
mockScope.$watchCollection.mostRecentCall.args[1]({
|
||||
mockScope.$watchCollection.calls.mostRecent().args[1]({
|
||||
lines: [{}, {}, {}]
|
||||
});
|
||||
expect(mockGL.drawArrays.calls.length).toEqual(3);
|
||||
expect(mockGL.drawArrays.calls.count()).toEqual(3);
|
||||
});
|
||||
|
||||
it("issues one draw call per box", function () {
|
||||
mctChart.link(mockScope, mockElement);
|
||||
mockScope.$watchCollection.mostRecentCall.args[1]({
|
||||
mockScope.$watchCollection.calls.mostRecent().args[1]({
|
||||
boxes: [
|
||||
{ start: [0, 0], end: [1, 1] },
|
||||
{ start: [0, 0], end: [1, 1] },
|
||||
@@ -137,12 +137,12 @@ define(
|
||||
{ start: [0, 0], end: [1, 1] }
|
||||
]
|
||||
});
|
||||
expect(mockGL.drawArrays.calls.length).toEqual(4);
|
||||
expect(mockGL.drawArrays.calls.count()).toEqual(4);
|
||||
});
|
||||
|
||||
it("does not fail if no draw object is in scope", function () {
|
||||
mctChart.link(mockScope, mockElement);
|
||||
expect(mockScope.$watchCollection.mostRecentCall.args[1])
|
||||
expect(mockScope.$watchCollection.calls.mostRecent().args[1])
|
||||
.not.toThrow();
|
||||
});
|
||||
|
||||
@@ -164,14 +164,14 @@ define(
|
||||
mockCanvas.offsetWidth = 150;
|
||||
mockCanvas.height = 200;
|
||||
mockCanvas.offsetHeight = 200;
|
||||
mockInterval.mostRecentCall.args[0]();
|
||||
mockInterval.calls.mostRecent().args[0]();
|
||||
|
||||
// Use clear as an indication that drawing has occurred
|
||||
expect(mockGL.clear).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("warns if no WebGL context is available", function () {
|
||||
mockCanvas.getContext.andReturn(undefined);
|
||||
mockCanvas.getContext.and.returnValue(undefined);
|
||||
mctChart.link(mockScope, mockElement);
|
||||
expect(mockLog.warn).toHaveBeenCalled();
|
||||
});
|
||||
@@ -181,7 +181,7 @@ define(
|
||||
expect(mockCanvas.addEventListener)
|
||||
.toHaveBeenCalledWith("webglcontextlost", jasmine.any(Function));
|
||||
expect(mockCanvas.getContext).not.toHaveBeenCalledWith('2d');
|
||||
mockCanvas.addEventListener.mostRecentCall.args[1]();
|
||||
mockCanvas.addEventListener.calls.mostRecent().args[1]();
|
||||
expect(mockCanvas.getContext).toHaveBeenCalledWith('2d');
|
||||
});
|
||||
|
||||
@@ -205,7 +205,7 @@ define(
|
||||
expect(mockInterval.cancel).not.toHaveBeenCalled();
|
||||
|
||||
// Broadcast a $destroy
|
||||
mockScope.$on.mostRecentCall.args[1]();
|
||||
mockScope.$on.calls.mostRecent().args[1]();
|
||||
|
||||
// Should have stopped the interval
|
||||
expect(mockInterval.cancel).toHaveBeenCalledWith(mockPromise);
|
||||
|
||||
@@ -69,7 +69,7 @@ define(
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -114,23 +114,23 @@ define(
|
||||
|
||||
mockScope.domainObject = mockDomainObject;
|
||||
mockScope.configuration = testConfiguration;
|
||||
mockQ.when.andCallFake(asPromise);
|
||||
mockQ.all.andCallFake(allPromises);
|
||||
mockA.getId.andReturn('a');
|
||||
mockA.getModel.andReturn(testModels.a);
|
||||
mockB.getId.andReturn('b');
|
||||
mockB.getModel.andReturn(testModels.b);
|
||||
mockA.useCapability.andCallFake(useCapability);
|
||||
mockB.useCapability.andCallFake(useCapability);
|
||||
mockA.hasCapability.andReturn(true);
|
||||
mockB.hasCapability.andReturn(true);
|
||||
mockA.getCapability.andCallFake(getCapability);
|
||||
mockB.getCapability.andCallFake(getCapability);
|
||||
mockSpan.getStart.andReturn(42);
|
||||
mockSpan.getEnd.andReturn(12321);
|
||||
mockUtilization.resources.andReturn(['abc', 'xyz']);
|
||||
mockUtilization.utilization.andReturn(mockPromise);
|
||||
mockLoader.load.andCallFake(function () {
|
||||
mockQ.when.and.callFake(asPromise);
|
||||
mockQ.all.and.callFake(allPromises);
|
||||
mockA.getId.and.returnValue('a');
|
||||
mockA.getModel.and.returnValue(testModels.a);
|
||||
mockB.getId.and.returnValue('b');
|
||||
mockB.getModel.and.returnValue(testModels.b);
|
||||
mockA.useCapability.and.callFake(useCapability);
|
||||
mockB.useCapability.and.callFake(useCapability);
|
||||
mockA.hasCapability.and.returnValue(true);
|
||||
mockB.hasCapability.and.returnValue(true);
|
||||
mockA.getCapability.and.callFake(getCapability);
|
||||
mockB.getCapability.and.callFake(getCapability);
|
||||
mockSpan.getStart.and.returnValue(42);
|
||||
mockSpan.getEnd.and.returnValue(12321);
|
||||
mockUtilization.resources.and.returnValue(['abc', 'xyz']);
|
||||
mockUtilization.utilization.and.returnValue(mockPromise);
|
||||
mockLoader.load.and.callFake(function () {
|
||||
return asPromise(subgraph(mockA, {
|
||||
a: mockA,
|
||||
b: mockB
|
||||
@@ -160,7 +160,7 @@ define(
|
||||
var fnWatchCall;
|
||||
|
||||
// Find the $watch that was given a function
|
||||
mockScope.$watch.calls.forEach(function (call) {
|
||||
mockScope.$watch.calls.all().forEach(function (call) {
|
||||
if (typeof call.args[0] === 'function') {
|
||||
// white-box: we know the first call is
|
||||
// the one we're looking for
|
||||
@@ -197,17 +197,17 @@ define(
|
||||
expect(controller.graphs().length).toEqual(0);
|
||||
|
||||
// Execute the watch function for graph state
|
||||
tmp = mockScope.$watch.calls[3].args[0]();
|
||||
tmp = mockScope.$watch.calls.all()[3].args[0]();
|
||||
|
||||
// Change graph state
|
||||
testConfiguration.graph = { a: true, b: true };
|
||||
|
||||
// Verify that this would have triggered a watch
|
||||
expect(mockScope.$watch.calls[3].args[0]())
|
||||
expect(mockScope.$watch.calls.all()[3].args[0]())
|
||||
.not.toEqual(tmp);
|
||||
|
||||
// Run the function the watch would have triggered
|
||||
mockScope.$watch.calls[3].args[1]();
|
||||
mockScope.$watch.calls.all()[3].args[1]();
|
||||
|
||||
// Should have some graphs now
|
||||
expect(controller.graphs().length).toEqual(2);
|
||||
|
||||
@@ -40,9 +40,9 @@ define(
|
||||
// Verify two-way binding support
|
||||
it("updates model on changes to entry fields", function () {
|
||||
// Make sure we're looking at the right watch
|
||||
expect(mockScope.$watchCollection.calls[0].args[0])
|
||||
expect(mockScope.$watchCollection.calls.all()[0].args[0])
|
||||
.toEqual("datetime");
|
||||
mockScope.$watchCollection.calls[0].args[1]({
|
||||
mockScope.$watchCollection.calls.all()[0].args[1]({
|
||||
days: 4,
|
||||
hours: 12,
|
||||
minutes: 30,
|
||||
@@ -55,12 +55,12 @@ define(
|
||||
|
||||
it("updates form when model changes", function () {
|
||||
// Make sure we're looking at the right watch
|
||||
expect(mockScope.$watchCollection.calls[1].args[0])
|
||||
expect(mockScope.$watchCollection.calls.all()[1].args[0])
|
||||
.toEqual(jasmine.any(Function));
|
||||
// ...and that it's really looking at the field in ngModel
|
||||
expect(mockScope.$watchCollection.calls[1].args[0]())
|
||||
expect(mockScope.$watchCollection.calls.all()[1].args[0]())
|
||||
.toBe(mockScope.ngModel.testField);
|
||||
mockScope.$watchCollection.calls[1].args[1]({
|
||||
mockScope.$watchCollection.calls.all()[1].args[1]({
|
||||
timestamp: ((((((4 * 24) + 12) * 60) + 30) * 60) + 11) * 1000
|
||||
});
|
||||
expect(mockScope.datetime).toEqual({
|
||||
|
||||
@@ -57,11 +57,11 @@ define(
|
||||
testScroll = { x: 0, width: 2000 };
|
||||
mockToPixels = jasmine.createSpy('toPixels');
|
||||
|
||||
mockTimespan.getStart.andReturn(100);
|
||||
mockTimespan.getDuration.andReturn(50);
|
||||
mockTimespan.getEnd.andReturn(150);
|
||||
mockTimespan.getStart.and.returnValue(100);
|
||||
mockTimespan.getDuration.and.returnValue(50);
|
||||
mockTimespan.getEnd.and.returnValue(150);
|
||||
|
||||
mockToPixels.andCallFake(function (t) {
|
||||
mockToPixels.and.callFake(function (t) {
|
||||
return t * 10;
|
||||
});
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ define(
|
||||
mockGraphB = jasmine.createSpyObj('graph-b', ['setBounds']);
|
||||
|
||||
// Supply new parameters
|
||||
mockScope.$watchCollection.mostRecentCall.args[1]({
|
||||
mockScope.$watchCollection.calls.mostRecent().args[1]({
|
||||
graphs: [mockGraphA, mockGraphB],
|
||||
origin: 9,
|
||||
duration: 144
|
||||
@@ -71,8 +71,8 @@ define(
|
||||
it("provides labels for graphs", function () {
|
||||
var mockGraph = jasmine.createSpyObj('graph', ['minimum', 'maximum']);
|
||||
|
||||
mockGraph.minimum.andReturn(12.3412121);
|
||||
mockGraph.maximum.andReturn(88.7555555);
|
||||
mockGraph.minimum.and.returnValue(12.3412121);
|
||||
mockGraph.maximum.and.returnValue(88.7555555);
|
||||
mockGraph.key = "def";
|
||||
|
||||
expect(controller.label(mockGraph)).toEqual({
|
||||
|
||||
@@ -46,10 +46,10 @@ define([
|
||||
]);
|
||||
mockScope.scroll = { x: 10, width: 1000 };
|
||||
|
||||
spyOn(mockmct.time, "on").andCallThrough();
|
||||
spyOn(mockmct.time, "off").andCallThrough();
|
||||
spyOn(mockTimerService, "on").andCallThrough();
|
||||
spyOn(mockTimerService, "off").andCallThrough();
|
||||
spyOn(mockmct.time, "on").and.callThrough();
|
||||
spyOn(mockmct.time, "off").and.callThrough();
|
||||
spyOn(mockTimerService, "on").and.callThrough();
|
||||
spyOn(mockTimerService, "off").and.callThrough();
|
||||
|
||||
controller = new TimelineTOIController(
|
||||
mockmct,
|
||||
@@ -96,11 +96,11 @@ define([
|
||||
beforeEach(function () {
|
||||
testNow = 333221;
|
||||
mockScope.zoomController.toPixels
|
||||
.andCallFake(function (millis) {
|
||||
.and.callFake(function (millis) {
|
||||
return millis * 2;
|
||||
});
|
||||
mockTimerService.emit('change', mockTimer);
|
||||
mockTimerService.now.andReturn(testNow);
|
||||
mockTimerService.now.and.returnValue(testNow);
|
||||
});
|
||||
|
||||
it("reports an x value from the zoomController", function () {
|
||||
@@ -125,7 +125,7 @@ define([
|
||||
describe("when follow mode is enabled", function () {
|
||||
beforeEach(function () {
|
||||
mockScope.scroll.follow = true;
|
||||
mockTimerService.now.andReturn(500);
|
||||
mockTimerService.now.and.returnValue(500);
|
||||
});
|
||||
|
||||
it("zooms on bounds events", function () {
|
||||
|
||||
@@ -40,7 +40,7 @@ define(
|
||||
|
||||
beforeEach(function () {
|
||||
mockToMillis = jasmine.createSpy('toMillis');
|
||||
mockToMillis.andCallFake(function (v) {
|
||||
mockToMillis.and.callFake(function (v) {
|
||||
return v * 2 + BILLION;
|
||||
});
|
||||
controller = new TimelineTickController();
|
||||
@@ -69,7 +69,7 @@ define(
|
||||
it("does rebuild arrays when zoom changes", function () {
|
||||
var firstValue = controller.labels(800, 300, 100, mockToMillis);
|
||||
|
||||
mockToMillis.andCallFake(function (v) {
|
||||
mockToMillis.and.callFake(function (v) {
|
||||
return BILLION * 2 + v;
|
||||
});
|
||||
|
||||
|
||||
@@ -95,24 +95,24 @@ define(
|
||||
'getDuration'
|
||||
]);
|
||||
|
||||
mockDomainObject.useCapability.andCallFake(function (c) {
|
||||
mockDomainObject.useCapability.and.callFake(function (c) {
|
||||
return c === 'timespan' && mockPromise;
|
||||
});
|
||||
mockPromise.then.andCallFake(function (callback) {
|
||||
mockPromise.then.and.callFake(function (callback) {
|
||||
callback(mockTimespan);
|
||||
});
|
||||
mockTimespan.getStart.andReturn(testStart);
|
||||
mockTimespan.getEnd.andReturn(testEnd);
|
||||
mockTimespan.getDuration.andReturn(testEnd - testStart);
|
||||
mockTimespan.getStart.and.returnValue(testStart);
|
||||
mockTimespan.getEnd.and.returnValue(testEnd);
|
||||
mockTimespan.getDuration.and.returnValue(testEnd - testStart);
|
||||
|
||||
mockScope.scroll = { x: 0, width: 20000 };
|
||||
mockScope.domainObject = mockDomainObject;
|
||||
|
||||
mockScope.$watch.calls.forEach(function (call) {
|
||||
mockScope.$watch.calls.all().forEach(function (call) {
|
||||
call.args[1](mockScope[call.args[0]]);
|
||||
});
|
||||
|
||||
mockWindow.requestAnimationFrame.calls.forEach(function (call) {
|
||||
mockWindow.requestAnimationFrame.calls.all().forEach(function (call) {
|
||||
call.args[0]();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -50,9 +50,9 @@ define(
|
||||
['instanceOf']
|
||||
);
|
||||
|
||||
mockDomainObject.getId.andReturn('test-id');
|
||||
mockDomainObject.getCapability.andReturn(mockType);
|
||||
mockType.instanceOf.andCallFake(function (t) {
|
||||
mockDomainObject.getId.and.returnValue('test-id');
|
||||
mockDomainObject.getCapability.and.returnValue(mockType);
|
||||
mockType.instanceOf.and.callFake(function (t) {
|
||||
return t === testType;
|
||||
});
|
||||
|
||||
|
||||
@@ -60,10 +60,10 @@ define(
|
||||
['getId', 'getModel', 'getCapability', 'useCapability']
|
||||
);
|
||||
|
||||
mockDomainObj.getId.andReturn(id);
|
||||
mockDomainObj.getModel.andReturn({ composition: composition });
|
||||
mockDomainObj.useCapability.andReturn(asPromise(mockTimespans[id]));
|
||||
mockDomainObj.getCapability.andCallFake(function (c) {
|
||||
mockDomainObj.getId.and.returnValue(id);
|
||||
mockDomainObj.getModel.and.returnValue({ composition: composition });
|
||||
mockDomainObj.useCapability.and.returnValue(asPromise(mockTimespans[id]));
|
||||
mockDomainObj.getCapability.and.callFake(function (c) {
|
||||
return {
|
||||
mutation: mockMutations[id]
|
||||
}[c];
|
||||
@@ -84,9 +84,9 @@ define(
|
||||
'mutation-' + id,
|
||||
['mutate']
|
||||
);
|
||||
mockTimespans[id].getStart.andReturn(index * 1000);
|
||||
mockTimespans[id].getDuration.andReturn(4000 + index);
|
||||
mockTimespans[id].getEnd.andReturn(4000 + index + index * 1000);
|
||||
mockTimespans[id].getStart.and.returnValue(index * 1000);
|
||||
mockTimespans[id].getDuration.and.returnValue(4000 + index);
|
||||
mockTimespans[id].getEnd.and.returnValue(4000 + index + index * 1000);
|
||||
});
|
||||
|
||||
mockLoader = jasmine.createSpyObj('objectLoader', ['load']);
|
||||
@@ -104,7 +104,7 @@ define(
|
||||
|
||||
testConfiguration = {};
|
||||
|
||||
mockLoader.load.andReturn(asPromise(
|
||||
mockLoader.load.and.returnValue(asPromise(
|
||||
subgraph(mockDomainObject, mockDomainObjects)
|
||||
));
|
||||
|
||||
@@ -193,7 +193,7 @@ define(
|
||||
|
||||
it("prevents bulk moves past 0", function () {
|
||||
// Have a start later; new lowest start is b, at 1000
|
||||
mockTimespans.a.getStart.andReturn(10000);
|
||||
mockTimespans.a.getStart.and.returnValue(10000);
|
||||
handler.move('a', -10000);
|
||||
// Verify that move was stopped at 0, for b, even though
|
||||
// move was initiated at a
|
||||
|
||||
@@ -42,7 +42,7 @@ define(
|
||||
);
|
||||
|
||||
mockSwimlane.domainObject = mockDomainObject;
|
||||
mockObjectLoader.load.andReturn(mockPromise);
|
||||
mockObjectLoader.load.and.returnValue(mockPromise);
|
||||
|
||||
populator = new TimelineDragPopulator(mockObjectLoader);
|
||||
});
|
||||
|
||||
@@ -44,19 +44,19 @@ define(
|
||||
['toMillis', 'toPixels']
|
||||
);
|
||||
|
||||
mockDragHandler.end.andReturn(12321);
|
||||
mockDragHandler.end.and.returnValue(12321);
|
||||
|
||||
// Echo back the value from snapper for most tests
|
||||
mockSnapHandler.snap.andCallFake(function (ts) {
|
||||
mockSnapHandler.snap.and.callFake(function (ts) {
|
||||
return ts;
|
||||
});
|
||||
|
||||
// Double pixels to get millis, for test purposes
|
||||
mockZoomController.toMillis.andCallFake(function (px) {
|
||||
mockZoomController.toMillis.and.callFake(function (px) {
|
||||
return px * 2;
|
||||
});
|
||||
|
||||
mockZoomController.toPixels.andCallFake(function (ms) {
|
||||
mockZoomController.toPixels.and.callFake(function (ms) {
|
||||
return ms / 2;
|
||||
});
|
||||
|
||||
@@ -88,7 +88,7 @@ define(
|
||||
});
|
||||
|
||||
it("snaps drags to other end points", function () {
|
||||
mockSnapHandler.snap.andReturn(42);
|
||||
mockSnapHandler.snap.and.returnValue(42);
|
||||
handle.begin();
|
||||
handle.drag(-10, mockZoomController);
|
||||
// Should have used snap-to timestamp
|
||||
|
||||
@@ -44,21 +44,21 @@ define(
|
||||
['toMillis', 'toPixels']
|
||||
);
|
||||
|
||||
mockDragHandler.start.andReturn(12321);
|
||||
mockDragHandler.duration.andReturn(4200);
|
||||
mockDragHandler.end.andReturn(12321 + 4200);
|
||||
mockDragHandler.start.and.returnValue(12321);
|
||||
mockDragHandler.duration.and.returnValue(4200);
|
||||
mockDragHandler.end.and.returnValue(12321 + 4200);
|
||||
|
||||
// Echo back the value from snapper for most tests
|
||||
mockSnapHandler.snap.andCallFake(function (ts) {
|
||||
mockSnapHandler.snap.and.callFake(function (ts) {
|
||||
return ts;
|
||||
});
|
||||
|
||||
// Double pixels to get millis, for test purposes
|
||||
mockZoomController.toMillis.andCallFake(function (px) {
|
||||
mockZoomController.toMillis.and.callFake(function (px) {
|
||||
return px * 2;
|
||||
});
|
||||
|
||||
mockZoomController.toPixels.andCallFake(function (ms) {
|
||||
mockZoomController.toPixels.and.callFake(function (ms) {
|
||||
return ms / 2;
|
||||
});
|
||||
|
||||
@@ -100,8 +100,8 @@ define(
|
||||
);
|
||||
|
||||
// Reflect the change from the drag handler
|
||||
mockDragHandler.start.andReturn(12521);
|
||||
mockDragHandler.end.andReturn(12521 + 4200);
|
||||
mockDragHandler.start.and.returnValue(12521);
|
||||
mockDragHandler.end.and.returnValue(12521 + 4200);
|
||||
|
||||
// ....followed by a +100 ms change.
|
||||
handle.drag(150, mockZoomController);
|
||||
@@ -112,7 +112,7 @@ define(
|
||||
});
|
||||
|
||||
it("snaps drags to other end points", function () {
|
||||
mockSnapHandler.snap.andCallFake(function (ts) {
|
||||
mockSnapHandler.snap.and.callFake(function (ts) {
|
||||
return ts + 10;
|
||||
});
|
||||
handle.begin();
|
||||
@@ -129,7 +129,7 @@ define(
|
||||
handle.begin();
|
||||
expect(mockSnapHandler.snap).not.toHaveBeenCalled();
|
||||
handle.drag(100, mockZoomController);
|
||||
expect(mockSnapHandler.snap.calls.length).toEqual(2);
|
||||
expect(mockSnapHandler.snap.calls.count()).toEqual(2);
|
||||
});
|
||||
|
||||
it("chooses the closest snap-to location", function () {
|
||||
@@ -139,7 +139,7 @@ define(
|
||||
// regardless of whether it is the start/end (which
|
||||
// will vary based on the initial state of this toggle.)
|
||||
var toggle = false;
|
||||
mockSnapHandler.snap.andCallFake(function (ts) {
|
||||
mockSnapHandler.snap.and.callFake(function (ts) {
|
||||
toggle = !toggle;
|
||||
return ts + (toggle ? -5 : 10);
|
||||
});
|
||||
@@ -151,8 +151,8 @@ define(
|
||||
);
|
||||
|
||||
// Reflect the change from the drag handler
|
||||
mockDragHandler.start.andReturn(12521 - 5);
|
||||
mockDragHandler.end.andReturn(12521 + 4200 - 5);
|
||||
mockDragHandler.start.and.returnValue(12521 - 5);
|
||||
mockDragHandler.end.and.returnValue(12521 + 4200 - 5);
|
||||
|
||||
toggle = true; // Change going-in state
|
||||
handle.drag(300, mockZoomController);
|
||||
|
||||
@@ -37,11 +37,11 @@ define(
|
||||
['start', 'end', 'ids']
|
||||
);
|
||||
|
||||
mockDragHandler.ids.andReturn(['a', 'b', 'c', 'd']);
|
||||
mockDragHandler.start.andCallFake(function (id) {
|
||||
mockDragHandler.ids.and.returnValue(['a', 'b', 'c', 'd']);
|
||||
mockDragHandler.start.and.callFake(function (id) {
|
||||
return starts[id];
|
||||
});
|
||||
mockDragHandler.end.andCallFake(function (id) {
|
||||
mockDragHandler.end.and.callFake(function (id) {
|
||||
return ends[id];
|
||||
});
|
||||
|
||||
|
||||
@@ -44,19 +44,19 @@ define(
|
||||
['toMillis', 'toPixels']
|
||||
);
|
||||
|
||||
mockDragHandler.start.andReturn(12321);
|
||||
mockDragHandler.start.and.returnValue(12321);
|
||||
|
||||
// Echo back the value from snapper for most tests
|
||||
mockSnapHandler.snap.andCallFake(function (ts) {
|
||||
mockSnapHandler.snap.and.callFake(function (ts) {
|
||||
return ts;
|
||||
});
|
||||
|
||||
// Double pixels to get millis, for test purposes
|
||||
mockZoomController.toMillis.andCallFake(function (px) {
|
||||
mockZoomController.toMillis.and.callFake(function (px) {
|
||||
return px * 2;
|
||||
});
|
||||
|
||||
mockZoomController.toPixels.andCallFake(function (ms) {
|
||||
mockZoomController.toPixels.and.callFake(function (ms) {
|
||||
return ms / 2;
|
||||
});
|
||||
|
||||
@@ -87,7 +87,7 @@ define(
|
||||
});
|
||||
|
||||
it("snaps drags to other end points", function () {
|
||||
mockSnapHandler.snap.andReturn(42);
|
||||
mockSnapHandler.snap.and.returnValue(42);
|
||||
handle.begin();
|
||||
handle.drag(-10, mockZoomController);
|
||||
// Should have used snap-to timestamp
|
||||
|
||||
@@ -64,15 +64,15 @@ define(
|
||||
'graph-' + k,
|
||||
['getPointCount', 'getDomainValue', 'getRangeValue']
|
||||
);
|
||||
mockSwimlane.graph.andReturn(true);
|
||||
mockSwimlane.graph.and.returnValue(true);
|
||||
mockSwimlane.domainObject = jasmine.createSpyObj(
|
||||
'domainObject-' + k,
|
||||
['getCapability', 'hasCapability', 'useCapability', 'getId']
|
||||
);
|
||||
mockSwimlane.color.andReturn('#' + k);
|
||||
mockSwimlane.color.and.returnValue('#' + k);
|
||||
// Provide just enough information about graphs to support
|
||||
// determination of which graphs to show
|
||||
mockSwimlane.domainObject.useCapability.andCallFake(function () {
|
||||
mockSwimlane.domainObject.useCapability.and.callFake(function () {
|
||||
var obj = {};
|
||||
testResources[k].forEach(function (r) {
|
||||
obj[r] = mockGraph;
|
||||
@@ -80,16 +80,16 @@ define(
|
||||
return asPromise(obj);
|
||||
});
|
||||
mockSwimlane.domainObject.hasCapability
|
||||
.andReturn(true);
|
||||
.and.returnValue(true);
|
||||
mockSwimlane.domainObject.getId
|
||||
.andReturn(k);
|
||||
mockGraph.getPointCount.andReturn(0);
|
||||
.and.returnValue(k);
|
||||
mockGraph.getPointCount.and.returnValue(0);
|
||||
|
||||
return mockSwimlane;
|
||||
});
|
||||
|
||||
mockQ.when.andCallFake(asPromise);
|
||||
mockQ.all.andCallFake(allPromises);
|
||||
mockQ.when.and.callFake(asPromise);
|
||||
mockQ.all.and.callFake(allPromises);
|
||||
|
||||
populator = new TimelineGraphPopulator(mockQ);
|
||||
});
|
||||
@@ -105,7 +105,7 @@ define(
|
||||
});
|
||||
|
||||
it("does not include graphs based on swimlane configuration", function () {
|
||||
mockSwimlanes[2].graph.andReturn(false);
|
||||
mockSwimlanes[2].graph.and.returnValue(false);
|
||||
populator.populate(mockSwimlanes);
|
||||
// Only two unique swimlanes in the other two
|
||||
expect(populator.get().length).toEqual(2);
|
||||
@@ -140,7 +140,7 @@ define(
|
||||
populator.populate(mockSwimlanes);
|
||||
initialValue = populator.get();
|
||||
// Change resource graph inclusion...
|
||||
mockSwimlanes[1].graph.andReturn(false);
|
||||
mockSwimlanes[1].graph.and.returnValue(false);
|
||||
populator.populate(mockSwimlanes);
|
||||
// Now we should get different graphs
|
||||
expect(populator.get()).not.toBe(initialValue);
|
||||
|
||||
@@ -59,10 +59,10 @@ define(
|
||||
'domainObject-' + k,
|
||||
['getCapability', 'useCapability']
|
||||
);
|
||||
mockDomainObjects[k].useCapability.andReturn(asPromise({
|
||||
mockDomainObjects[k].useCapability.and.returnValue(asPromise({
|
||||
testResource: mockGraph
|
||||
}));
|
||||
mockGraph.getPointCount.andReturn(i + 2);
|
||||
mockGraph.getPointCount.and.returnValue(i + 2);
|
||||
mockGraph.testField = k;
|
||||
mockGraph.testIndex = i;
|
||||
|
||||
@@ -75,7 +75,7 @@ define(
|
||||
['render', 'decode']
|
||||
);
|
||||
|
||||
mockRenderer.render.andCallFake(function (utilization) {
|
||||
mockRenderer.render.and.callFake(function (utilization) {
|
||||
var result = [];
|
||||
while (result.length < (utilization.testIndex + 2) * 2) {
|
||||
result.push(Math.floor(result.length / 2));
|
||||
@@ -88,7 +88,7 @@ define(
|
||||
return result;
|
||||
});
|
||||
|
||||
mockRenderer.decode.andCallFake(function (color) {
|
||||
mockRenderer.decode.and.callFake(function (color) {
|
||||
return testColors[color];
|
||||
});
|
||||
|
||||
@@ -114,7 +114,7 @@ define(
|
||||
expect(graph.drawingObject.lines).toEqual([
|
||||
{
|
||||
color: testColors.a,
|
||||
buffer: [0, 0, 1, 0],
|
||||
buffer: [0, 0, 1, -0],
|
||||
points: 2
|
||||
},
|
||||
{
|
||||
@@ -138,7 +138,7 @@ define(
|
||||
|
||||
it("provides a minimum/maximum even with no data", function () {
|
||||
mockGraphs.forEach(function (mockGraph) {
|
||||
mockGraph.getPointCount.andReturn(0);
|
||||
mockGraph.getPointCount.and.returnValue(0);
|
||||
});
|
||||
|
||||
// Create a graph of these utilizations
|
||||
|
||||
@@ -49,12 +49,12 @@ define(
|
||||
'action-' + type,
|
||||
['perform', 'getMetadata']
|
||||
);
|
||||
mockAction.getMetadata.andReturn({ type: type });
|
||||
mockAction.getMetadata.and.returnValue({ type: type });
|
||||
return mockAction;
|
||||
});
|
||||
|
||||
mockDomainObject.getCapability.andReturn(mockActionCapability);
|
||||
mockActionCapability.getActions.andReturn(mockActions);
|
||||
mockDomainObject.getCapability.and.returnValue(mockActionCapability);
|
||||
mockActionCapability.getActions.and.returnValue(mockActions);
|
||||
|
||||
proxy = new TimelineProxy(mockDomainObject, mockSelection);
|
||||
});
|
||||
@@ -90,10 +90,10 @@ define(
|
||||
);
|
||||
|
||||
// Set up mocks
|
||||
mockSelection.get.andReturn({ domainObject: mockOtherObject });
|
||||
mockOtherObject.getCapability.andReturn(mockOtherAction);
|
||||
mockOtherAction.getActions.andReturn([mockAction]);
|
||||
mockAction.getMetadata.andReturn({ type: 'z' });
|
||||
mockSelection.get.and.returnValue({ domainObject: mockOtherObject });
|
||||
mockOtherObject.getCapability.and.returnValue(mockOtherAction);
|
||||
mockOtherAction.getActions.and.returnValue([mockAction]);
|
||||
mockAction.getMetadata.and.returnValue({ type: 'z' });
|
||||
|
||||
// Invoke add method; should create with selected object
|
||||
proxy.add('z');
|
||||
|
||||
@@ -56,13 +56,13 @@ define(
|
||||
);
|
||||
mockPromise = jasmine.createSpyObj('promise', ['then']);
|
||||
|
||||
mockSwimlane.domainObject.getCapability.andCallFake(function (c) {
|
||||
mockSwimlane.domainObject.getCapability.and.callFake(function (c) {
|
||||
return mockCapabilities[c];
|
||||
});
|
||||
mockSwimlane.domainObject.getModel.andReturn(testModel);
|
||||
mockSwimlane.domainObject.getModel.and.returnValue(testModel);
|
||||
|
||||
mockCapabilities.type.instanceOf.andReturn(true);
|
||||
mockCapabilities.mutation.mutate.andReturn(mockPromise);
|
||||
mockCapabilities.type.instanceOf.and.returnValue(true);
|
||||
mockCapabilities.mutation.mutate.and.returnValue(mockPromise);
|
||||
|
||||
decorator = new TimelineSwimlaneDecorator(
|
||||
mockSwimlane,
|
||||
@@ -109,7 +109,7 @@ define(
|
||||
decorator.modes(['abc', 'xyz']);
|
||||
expect(mockCapabilities.mutation.mutate)
|
||||
.toHaveBeenCalledWith(jasmine.any(Function));
|
||||
mockCapabilities.mutation.mutate.mostRecentCall.args[0](testModel);
|
||||
mockCapabilities.mutation.mutate.calls.mostRecent().args[0](testModel);
|
||||
expect(testModel.relationships.modes).toEqual(['abc', 'xyz']);
|
||||
});
|
||||
|
||||
@@ -117,7 +117,7 @@ define(
|
||||
decorator.link("http://www.noaa.gov");
|
||||
expect(mockCapabilities.mutation.mutate)
|
||||
.toHaveBeenCalledWith(jasmine.any(Function));
|
||||
mockCapabilities.mutation.mutate.mostRecentCall.args[0](testModel);
|
||||
mockCapabilities.mutation.mutate.calls.mostRecent().args[0](testModel);
|
||||
expect(testModel.link).toEqual("http://www.noaa.gov");
|
||||
});
|
||||
|
||||
@@ -133,7 +133,7 @@ define(
|
||||
testModel.relationships = { modes: testModes };
|
||||
decorator.modes(testModes2);
|
||||
expect(mockCapabilities.mutation.mutate).toHaveBeenCalled();
|
||||
mockCapabilities.mutation.mutate.mostRecentCall.args[0](testModel);
|
||||
mockCapabilities.mutation.mutate.calls.mostRecent().args[0](testModel);
|
||||
expect(testModel.relationships.modes).toBe(testModes2);
|
||||
});
|
||||
|
||||
@@ -151,7 +151,7 @@ define(
|
||||
['perform']
|
||||
);
|
||||
|
||||
mockChild.getCapability.andCallFake(function (c) {
|
||||
mockChild.getCapability.and.callFake(function (c) {
|
||||
return c === 'action' ? mockAction : undefined;
|
||||
});
|
||||
|
||||
@@ -173,7 +173,7 @@ define(
|
||||
|
||||
it("allows checking for swimlane selection state", function () {
|
||||
expect(decorator.selected()).toBeFalsy();
|
||||
mockSelection.get.andReturn(decorator);
|
||||
mockSelection.get.and.returnValue(decorator);
|
||||
expect(decorator.selected()).toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
@@ -65,8 +65,8 @@ define(
|
||||
);
|
||||
|
||||
mockAction = jasmine.createSpyObj('action', ['perform']);
|
||||
mockAction.perform.andReturn(mockPromise);
|
||||
mockPromise.then.andCallFake(function (callback) {
|
||||
mockAction.perform.and.returnValue(mockPromise);
|
||||
mockPromise.then.and.callFake(function (callback) {
|
||||
callback();
|
||||
});
|
||||
|
||||
@@ -77,48 +77,48 @@ define(
|
||||
mockActionCapability = jasmine.createSpyObj("action", ["perform", "getActions"]);
|
||||
mockContext = jasmine.createSpyObj('context', ['getParent']);
|
||||
|
||||
mockActionCapability.getActions.andReturn([mockAction]);
|
||||
mockSwimlane.parent.domainObject.getId.andReturn('a');
|
||||
mockSwimlane.domainObject.getId.andReturn('b');
|
||||
mockSwimlane.children[0].domainObject.getId.andReturn('c');
|
||||
mockOtherObject.getId.andReturn('d');
|
||||
mockActionCapability.getActions.and.returnValue([mockAction]);
|
||||
mockSwimlane.parent.domainObject.getId.and.returnValue('a');
|
||||
mockSwimlane.domainObject.getId.and.returnValue('b');
|
||||
mockSwimlane.children[0].domainObject.getId.and.returnValue('c');
|
||||
mockOtherObject.getId.and.returnValue('d');
|
||||
|
||||
|
||||
mockSwimlane.domainObject.getCapability.andCallFake(function (c) {
|
||||
mockSwimlane.domainObject.getCapability.and.callFake(function (c) {
|
||||
return {
|
||||
action: mockActionCapability,
|
||||
editor: mockEditorCapability
|
||||
}[c];
|
||||
});
|
||||
mockSwimlane.parent.domainObject.getCapability.andCallFake(function (c) {
|
||||
mockSwimlane.parent.domainObject.getCapability.and.callFake(function (c) {
|
||||
return {
|
||||
action: mockActionCapability,
|
||||
editor: mockEditorCapability
|
||||
}[c];
|
||||
});
|
||||
mockOtherObject.getCapability.andCallFake(function (c) {
|
||||
mockOtherObject.getCapability.and.callFake(function (c) {
|
||||
return {
|
||||
action: mockActionCapability,
|
||||
context: mockContext,
|
||||
editor: mockEditorCapability
|
||||
}[c];
|
||||
});
|
||||
mockContext.getParent.andReturn(mockOtherObject);
|
||||
mockContext.getParent.and.returnValue(mockOtherObject);
|
||||
|
||||
mockSwimlane.domainObject.hasCapability.andReturn(true);
|
||||
mockSwimlane.domainObject.hasCapability.and.returnValue(true);
|
||||
|
||||
handler = new TimelineSwimlaneDropHandler(mockSwimlane);
|
||||
});
|
||||
|
||||
it("disallows drop outside of edit mode", function () {
|
||||
mockEditorCapability.inEditContext.andReturn(true);
|
||||
mockEditorCapability.inEditContext.and.returnValue(true);
|
||||
// Verify precondition
|
||||
expect(handler.allowDropIn('d', mockSwimlane.domainObject))
|
||||
.toBeTruthy();
|
||||
expect(handler.allowDropAfter('d', mockSwimlane.domainObject))
|
||||
.toBeTruthy();
|
||||
// Act as if we're not in edit mode
|
||||
mockEditorCapability.inEditContext.andReturn(false);
|
||||
mockEditorCapability.inEditContext.and.returnValue(false);
|
||||
// Now, they should be disallowed
|
||||
expect(handler.allowDropIn('d', mockSwimlane.domainObject))
|
||||
.toBeFalsy();
|
||||
@@ -149,48 +149,48 @@ define(
|
||||
|
||||
it("inserts into when highlighted", function () {
|
||||
var testModel = { composition: ['c'] };
|
||||
mockSwimlane.highlight.andReturn(true);
|
||||
mockSwimlane.highlight.and.returnValue(true);
|
||||
handler.drop('d', mockOtherObject);
|
||||
// Should have mutated
|
||||
expect(mockSwimlane.domainObject.useCapability)
|
||||
.toHaveBeenCalledWith("mutation", jasmine.any(Function));
|
||||
// Run the mutator
|
||||
mockSwimlane.domainObject.useCapability.mostRecentCall
|
||||
mockSwimlane.domainObject.useCapability.calls.mostRecent()
|
||||
.args[1](testModel);
|
||||
expect(testModel.composition).toEqual(['c', 'd']);
|
||||
});
|
||||
|
||||
it("inserts after as a peer when highlighted at the bottom", function () {
|
||||
var testModel = { composition: ['x', 'b', 'y'] };
|
||||
mockSwimlane.highlightBottom.andReturn(true);
|
||||
mockSwimlane.highlightBottom.and.returnValue(true);
|
||||
mockSwimlane.expanded = false;
|
||||
handler.drop('d', mockOtherObject);
|
||||
// Should have mutated
|
||||
expect(mockSwimlane.parent.domainObject.useCapability)
|
||||
.toHaveBeenCalledWith("mutation", jasmine.any(Function));
|
||||
// Run the mutator
|
||||
mockSwimlane.parent.domainObject.useCapability.mostRecentCall
|
||||
mockSwimlane.parent.domainObject.useCapability.calls.mostRecent()
|
||||
.args[1](testModel);
|
||||
expect(testModel.composition).toEqual(['x', 'b', 'd', 'y']);
|
||||
});
|
||||
|
||||
it("inserts into when highlighted at the bottom and expanded", function () {
|
||||
var testModel = { composition: ['c'] };
|
||||
mockSwimlane.highlightBottom.andReturn(true);
|
||||
mockSwimlane.highlightBottom.and.returnValue(true);
|
||||
mockSwimlane.expanded = true;
|
||||
handler.drop('d', mockOtherObject);
|
||||
// Should have mutated
|
||||
expect(mockSwimlane.domainObject.useCapability)
|
||||
.toHaveBeenCalledWith("mutation", jasmine.any(Function));
|
||||
// Run the mutator
|
||||
mockSwimlane.domainObject.useCapability.mostRecentCall
|
||||
mockSwimlane.domainObject.useCapability.calls.mostRecent()
|
||||
.args[1](testModel);
|
||||
expect(testModel.composition).toEqual(['d', 'c']);
|
||||
});
|
||||
|
||||
it("inserts after as a peer when highlighted at the bottom and childless", function () {
|
||||
var testModel = { composition: ['x', 'b', 'y'] };
|
||||
mockSwimlane.highlightBottom.andReturn(true);
|
||||
mockSwimlane.highlightBottom.and.returnValue(true);
|
||||
mockSwimlane.expanded = true;
|
||||
mockSwimlane.children = [];
|
||||
handler.drop('d', mockOtherObject);
|
||||
@@ -198,7 +198,7 @@ define(
|
||||
expect(mockSwimlane.parent.domainObject.useCapability)
|
||||
.toHaveBeenCalledWith("mutation", jasmine.any(Function));
|
||||
// Run the mutator
|
||||
mockSwimlane.parent.domainObject.useCapability.mostRecentCall
|
||||
mockSwimlane.parent.domainObject.useCapability.calls.mostRecent()
|
||||
.args[1](testModel);
|
||||
expect(testModel.composition).toEqual(['x', 'b', 'd', 'y']);
|
||||
});
|
||||
@@ -206,31 +206,28 @@ define(
|
||||
it("allows reordering within a parent", function () {
|
||||
var testModel = { composition: ['x', 'b', 'y', 'd'] };
|
||||
|
||||
mockSwimlane.highlightBottom.andReturn(true);
|
||||
mockSwimlane.highlightBottom.and.returnValue(true);
|
||||
mockSwimlane.expanded = true;
|
||||
mockSwimlane.children = [];
|
||||
mockContext.getParent
|
||||
.andReturn(mockSwimlane.parent.domainObject);
|
||||
handler.drop('d', mockOtherObject);
|
||||
mockContext.getParent.and.returnValue(mockSwimlane.parent.domainObject);
|
||||
|
||||
waitsFor(function () {
|
||||
return mockSwimlane.parent.domainObject.useCapability
|
||||
.calls.length > 0;
|
||||
});
|
||||
|
||||
runs(function () {
|
||||
mockSwimlane.parent.domainObject.useCapability.mostRecentCall
|
||||
.args[1](testModel);
|
||||
return new Promise(function (resolve, reject) {
|
||||
mockSwimlane.parent.domainObject.useCapability.and.callFake(function (name, callback) {
|
||||
resolve(callback);
|
||||
});
|
||||
handler.drop('d', mockOtherObject);
|
||||
}).then(function (callback) {
|
||||
callback(testModel);
|
||||
expect(testModel.composition).toEqual(['x', 'b', 'd', 'y']);
|
||||
});
|
||||
});
|
||||
|
||||
it("does not invoke an action when reordering", function () {
|
||||
mockSwimlane.highlightBottom.andReturn(true);
|
||||
mockSwimlane.highlightBottom.and.returnValue(true);
|
||||
mockSwimlane.expanded = true;
|
||||
mockSwimlane.children = [];
|
||||
mockContext.getParent
|
||||
.andReturn(mockSwimlane.parent.domainObject);
|
||||
.and.returnValue(mockSwimlane.parent.domainObject);
|
||||
handler.drop('d', mockOtherObject);
|
||||
expect(mockAction.perform).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -47,9 +47,9 @@ define(
|
||||
['getId', 'getModel', 'getCapability', 'useCapability']
|
||||
);
|
||||
|
||||
mockDomainObj.getId.andReturn(id);
|
||||
mockDomainObj.getModel.andReturn({ composition: composition });
|
||||
mockDomainObj.useCapability.andReturn(asPromise(false));
|
||||
mockDomainObj.getId.and.returnValue(id);
|
||||
mockDomainObj.getModel.and.returnValue({ composition: composition });
|
||||
mockDomainObj.useCapability.and.returnValue(asPromise(false));
|
||||
|
||||
return mockDomainObj;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ define(
|
||||
|
||||
testConfiguration = {};
|
||||
|
||||
mockLoader.load.andReturn(asPromise(subgraph(
|
||||
mockLoader.load.and.returnValue(asPromise(subgraph(
|
||||
mockDomainObject,
|
||||
mockDomainObjects
|
||||
)));
|
||||
@@ -129,7 +129,7 @@ define(
|
||||
populator.populate(mockDomainObject);
|
||||
|
||||
// Act as if something is already selected
|
||||
mockSelection.get.andReturn(populator.get()[1]);
|
||||
mockSelection.get.and.returnValue(populator.get()[1]);
|
||||
|
||||
// Verify precondition
|
||||
expect(mockSelection.select).not.toHaveBeenCalled();
|
||||
@@ -139,7 +139,7 @@ define(
|
||||
|
||||
// Selection should have been preserved
|
||||
expect(mockSelection.select).toHaveBeenCalled();
|
||||
expect(mockSelection.select.mostRecentCall.args[0].domainObject)
|
||||
expect(mockSelection.select.calls.mostRecent().args[0].domainObject)
|
||||
.toEqual(mockDomainObjects.b);
|
||||
});
|
||||
|
||||
|
||||
@@ -64,12 +64,12 @@ define(
|
||||
);
|
||||
mockActionCapability = jasmine.createSpyObj('action', ['perform']);
|
||||
|
||||
mockParentObject.getId.andReturn('test-parent');
|
||||
mockParentObject.getCapability.andReturn(mockActionCapability);
|
||||
mockParentObject.useCapability.andReturn(asPromise(mockParentTimespan));
|
||||
mockParentObject.getModel.andReturn({ name: "Test Parent" });
|
||||
mockChildObject.getModel.andReturn({ name: "Test Child" });
|
||||
mockChildObject.useCapability.andReturn(asPromise(mockChildTimespan));
|
||||
mockParentObject.getId.and.returnValue('test-parent');
|
||||
mockParentObject.getCapability.and.returnValue(mockActionCapability);
|
||||
mockParentObject.useCapability.and.returnValue(asPromise(mockParentTimespan));
|
||||
mockParentObject.getModel.and.returnValue({ name: "Test Parent" });
|
||||
mockChildObject.getModel.and.returnValue({ name: "Test Child" });
|
||||
mockChildObject.useCapability.and.returnValue(asPromise(mockChildTimespan));
|
||||
|
||||
testConfiguration = { graph: {} };
|
||||
|
||||
@@ -149,7 +149,7 @@ define(
|
||||
});
|
||||
|
||||
it("gets colors from the provided assigner", function () {
|
||||
mockAssigner.get.andReturn("#ABCABC");
|
||||
mockAssigner.get.and.returnValue("#ABCABC");
|
||||
expect(parent.color()).toEqual("#ABCABC");
|
||||
// Verify that id was passed, and no other interactions
|
||||
expect(mockAssigner.get).toHaveBeenCalledWith('test-parent');
|
||||
@@ -194,28 +194,28 @@ define(
|
||||
});
|
||||
|
||||
it("detects start/end violations", function () {
|
||||
mockParentTimespan.getStart.andReturn(42);
|
||||
mockParentTimespan.getEnd.andReturn(12321);
|
||||
mockParentTimespan.getStart.and.returnValue(42);
|
||||
mockParentTimespan.getEnd.and.returnValue(12321);
|
||||
|
||||
// First, start with a valid timespan
|
||||
mockChildTimespan.getStart.andReturn(84);
|
||||
mockChildTimespan.getEnd.andReturn(100);
|
||||
mockChildTimespan.getStart.and.returnValue(84);
|
||||
mockChildTimespan.getEnd.and.returnValue(100);
|
||||
expect(child.exceeded()).toBeFalsy();
|
||||
|
||||
// Start time violation
|
||||
mockChildTimespan.getStart.andReturn(21);
|
||||
mockChildTimespan.getStart.and.returnValue(21);
|
||||
expect(child.exceeded()).toBeTruthy();
|
||||
|
||||
// Now both in violation
|
||||
mockChildTimespan.getEnd.andReturn(20000);
|
||||
mockChildTimespan.getEnd.and.returnValue(20000);
|
||||
expect(child.exceeded()).toBeTruthy();
|
||||
|
||||
// And just the end
|
||||
mockChildTimespan.getStart.andReturn(100);
|
||||
mockChildTimespan.getStart.and.returnValue(100);
|
||||
expect(child.exceeded()).toBeTruthy();
|
||||
|
||||
// Now back to everything's-just-fine
|
||||
mockChildTimespan.getEnd.andReturn(10000);
|
||||
mockChildTimespan.getEnd.and.returnValue(10000);
|
||||
expect(child.exceeded()).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -55,18 +55,18 @@ define(
|
||||
stopPropagation: jasmine.createSpy()
|
||||
};
|
||||
|
||||
testEvent.dataTransfer.getData.andReturn('abc');
|
||||
mockDndService.getData.andCallFake(function (key) {
|
||||
testEvent.dataTransfer.getData.and.returnValue('abc');
|
||||
mockDndService.getData.and.callFake(function (key) {
|
||||
return key === SwimlaneDragConstants.TIMELINE_SWIMLANE_DRAG_TYPE ?
|
||||
mockSwimlane : undefined;
|
||||
});
|
||||
|
||||
mockSwimlane.graph.andReturn(false);
|
||||
mockSwimlane.graph.and.returnValue(false);
|
||||
|
||||
directive = new MCTResourceGraphDrop(mockDndService);
|
||||
directive.link(mockScope, mockElement, testAttrs);
|
||||
|
||||
mockElement.on.calls.forEach(function (call) {
|
||||
mockElement.on.calls.all().forEach(function (call) {
|
||||
handlers[call.args[0]] = call.args[1];
|
||||
});
|
||||
});
|
||||
@@ -78,7 +78,7 @@ define(
|
||||
[false, true].forEach(function (graphing) {
|
||||
describe("when swimlane graph is " + (graphing ? "" : "not ") + "enabled", function () {
|
||||
beforeEach(function () {
|
||||
mockSwimlane.graph.andReturn(graphing);
|
||||
mockSwimlane.graph.and.returnValue(graphing);
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ define(
|
||||
testAttrs = { mctSwimlaneDrag: "someTestExpr" };
|
||||
|
||||
// Simulate evaluation of expressions in scope
|
||||
mockScope.$eval.andCallFake(function (expr) {
|
||||
mockScope.$eval.and.callFake(function (expr) {
|
||||
return scopeExprs[expr];
|
||||
});
|
||||
|
||||
@@ -58,7 +58,7 @@ define(
|
||||
// for testing.
|
||||
directive.link(mockScope, mockElement, testAttrs);
|
||||
|
||||
mockElement.on.calls.forEach(function (call) {
|
||||
mockElement.on.calls.all().forEach(function (call) {
|
||||
handlers[call.args[0]] = call.args[1];
|
||||
});
|
||||
|
||||
|
||||
@@ -64,20 +64,20 @@ define(
|
||||
["getBoundingClientRect"]
|
||||
);
|
||||
mockElement[0].offsetHeight = TEST_HEIGHT;
|
||||
mockElement[0].getBoundingClientRect.andReturn({ top: TEST_TOP });
|
||||
mockElement[0].getBoundingClientRect.and.returnValue({ top: TEST_TOP });
|
||||
|
||||
// Simulate evaluation of expressions in scope
|
||||
scopeExprs.mockSwimlane = mockSwimlane;
|
||||
mockScope.$eval.andCallFake(function (expr) {
|
||||
mockScope.$eval.and.callFake(function (expr) {
|
||||
return scopeExprs[expr];
|
||||
});
|
||||
|
||||
|
||||
mockSwimlane.allowDropIn.andReturn(true);
|
||||
mockSwimlane.allowDropAfter.andReturn(true);
|
||||
mockSwimlane.allowDropIn.and.returnValue(true);
|
||||
mockSwimlane.allowDropAfter.and.returnValue(true);
|
||||
// Simulate getter-setter behavior
|
||||
mockSwimlane.highlight.andCallFake(getterSetter(false));
|
||||
mockSwimlane.highlightBottom.andCallFake(getterSetter(false));
|
||||
mockSwimlane.highlight.and.callFake(getterSetter(false));
|
||||
mockSwimlane.highlightBottom.and.callFake(getterSetter(false));
|
||||
|
||||
|
||||
|
||||
@@ -88,8 +88,8 @@ define(
|
||||
stopPropagation: jasmine.createSpy()
|
||||
};
|
||||
|
||||
testEvent.dataTransfer.getData.andReturn('abc');
|
||||
mockDndService.getData.andReturn({ domainObject: 'someDomainObject' });
|
||||
testEvent.dataTransfer.getData.and.returnValue('abc');
|
||||
mockDndService.getData.and.returnValue({ domainObject: 'someDomainObject' });
|
||||
|
||||
directive = new MCTSwimlaneDrop(mockDndService);
|
||||
|
||||
@@ -97,7 +97,7 @@ define(
|
||||
// for testing.
|
||||
directive.link(mockScope, mockElement, testAttrs);
|
||||
|
||||
mockElement.on.calls.forEach(function (call) {
|
||||
mockElement.on.calls.all().forEach(function (call) {
|
||||
handlers[call.args[0]] = call.args[1];
|
||||
});
|
||||
|
||||
@@ -133,7 +133,7 @@ define(
|
||||
// Near the top
|
||||
testEvent.pageY = TEST_TOP + TEST_HEIGHT / 10;
|
||||
|
||||
mockSwimlane.allowDropIn.andReturn(false);
|
||||
mockSwimlane.allowDropIn.and.returnValue(false);
|
||||
|
||||
handlers.dragover(testEvent);
|
||||
|
||||
@@ -145,7 +145,7 @@ define(
|
||||
// Near the top
|
||||
testEvent.pageY = TEST_TOP + TEST_HEIGHT - TEST_HEIGHT / 10;
|
||||
|
||||
mockSwimlane.allowDropAfter.andReturn(false);
|
||||
mockSwimlane.allowDropAfter.and.returnValue(false);
|
||||
|
||||
handlers.dragover(testEvent);
|
||||
|
||||
@@ -165,7 +165,7 @@ define(
|
||||
});
|
||||
|
||||
it("clears highlights when drag leaves", function () {
|
||||
mockSwimlane.highlight.andReturn(true);
|
||||
mockSwimlane.highlight.and.returnValue(true);
|
||||
handlers.dragleave();
|
||||
expect(mockSwimlane.highlight).toHaveBeenCalledWith(false);
|
||||
expect(mockSwimlane.highlightBottom).toHaveBeenCalledWith(false);
|
||||
|
||||
@@ -57,13 +57,13 @@ define(
|
||||
['useCapability', 'hasCapability', 'getId']
|
||||
);
|
||||
|
||||
mockDomainObject.getId.andReturn(id);
|
||||
mockDomainObject.useCapability.andCallFake(function (c) {
|
||||
mockDomainObject.getId.and.returnValue(id);
|
||||
mockDomainObject.useCapability.and.callFake(function (c) {
|
||||
return c === 'composition' ?
|
||||
asPromise(children.map(lookupObject)) :
|
||||
undefined;
|
||||
});
|
||||
mockDomainObject.hasCapability.andCallFake(function (c) {
|
||||
mockDomainObject.hasCapability.and.callFake(function (c) {
|
||||
return (capabilities.indexOf(c) !== -1) || (c === 'composition');
|
||||
});
|
||||
mockDomainObjects[id] = mockDomainObject;
|
||||
@@ -79,8 +79,8 @@ define(
|
||||
|
||||
// Provide subset of q's actual behavior which we
|
||||
// expect object loader to really need
|
||||
mockQ.when.andCallFake(asPromise);
|
||||
mockQ.all.andCallFake(function (values) {
|
||||
mockQ.when.and.callFake(asPromise);
|
||||
mockQ.all.and.callFake(function (values) {
|
||||
var result = [];
|
||||
function addResult(v) {
|
||||
result.push(v);
|
||||
|
||||
Reference in New Issue
Block a user