Merge remote-tracking branch 'github/master' into open245b
...in preparation to complete merge nasa/openmctweb#257 Conflicts: platform/entanglement/src/actions/CopyAction.js platform/entanglement/src/actions/LinkAction.js platform/entanglement/src/actions/MoveAction.js
This commit is contained in:
@@ -30,7 +30,8 @@ define(
|
||||
"use strict";
|
||||
|
||||
describe("The action provider", function () {
|
||||
var actions,
|
||||
var mockLog,
|
||||
actions,
|
||||
actionProvider;
|
||||
|
||||
function SimpleAction() {
|
||||
@@ -62,6 +63,10 @@ define(
|
||||
MetadataAction.key = "metadata";
|
||||
|
||||
beforeEach(function () {
|
||||
mockLog = jasmine.createSpyObj(
|
||||
'$log',
|
||||
['error', 'warn', 'info', 'debug']
|
||||
);
|
||||
actions = [
|
||||
SimpleAction,
|
||||
CategorizedAction,
|
||||
@@ -137,6 +142,42 @@ define(
|
||||
expect(provided[0].getMetadata()).toEqual("custom metadata");
|
||||
});
|
||||
|
||||
describe("when actions throw errors during instantiation", function () {
|
||||
var errorText,
|
||||
provided;
|
||||
|
||||
beforeEach(function () {
|
||||
errorText = "some error text";
|
||||
|
||||
function BadAction() {
|
||||
throw new Error(errorText);
|
||||
}
|
||||
|
||||
provided = new ActionProvider(
|
||||
[ SimpleAction, BadAction ],
|
||||
mockLog
|
||||
).getActions();
|
||||
});
|
||||
|
||||
it("logs an error", function () {
|
||||
expect(mockLog.error)
|
||||
.toHaveBeenCalledWith(jasmine.any(String));
|
||||
});
|
||||
|
||||
it("reports the error's message", function () {
|
||||
expect(
|
||||
mockLog.error.mostRecentCall.args[0].indexOf(errorText)
|
||||
).not.toEqual(-1);
|
||||
});
|
||||
|
||||
it("still provides valid actions", function () {
|
||||
expect(provided.length).toEqual(1);
|
||||
expect(provided[0].perform()).toEqual("simple");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
@@ -28,13 +28,18 @@ define(
|
||||
|
||||
describe("The 'topic' service", function () {
|
||||
var topic,
|
||||
mockLog,
|
||||
testMessage,
|
||||
mockCallback;
|
||||
|
||||
beforeEach(function () {
|
||||
testMessage = { someKey: "some value"};
|
||||
mockLog = jasmine.createSpyObj(
|
||||
'$log',
|
||||
[ 'error', 'warn', 'info', 'debug' ]
|
||||
);
|
||||
mockCallback = jasmine.createSpy('callback');
|
||||
topic = new Topic();
|
||||
topic = new Topic(mockLog);
|
||||
});
|
||||
|
||||
it("notifies listeners on a topic", function () {
|
||||
@@ -65,6 +70,21 @@ define(
|
||||
expect(mockCallback).toHaveBeenCalledWith(testMessage);
|
||||
});
|
||||
|
||||
it("is robust against errors thrown by listeners", function () {
|
||||
var mockBadCallback = jasmine.createSpy("bad-callback"),
|
||||
t = topic();
|
||||
|
||||
mockBadCallback.andCallFake(function () {
|
||||
throw new Error("I'm afraid I can't do that.");
|
||||
});
|
||||
|
||||
t.listen(mockBadCallback);
|
||||
t.listen(mockCallback);
|
||||
|
||||
t.notify(testMessage);
|
||||
expect(mockCallback).toHaveBeenCalledWith(testMessage);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -101,6 +101,12 @@ define(
|
||||
expect(type.getInitialModel().someKey).toEqual("some value");
|
||||
});
|
||||
|
||||
it("provides a fresh initial model each time", function () {
|
||||
var model = type.getInitialModel();
|
||||
model.someKey = "some other value";
|
||||
expect(type.getInitialModel().someKey).toEqual("some value");
|
||||
});
|
||||
|
||||
it("provides type properties", function () {
|
||||
expect(type.getProperties().length).toEqual(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user