mirror of
https://github.com/nasa/openmct.git
synced 2025-04-27 22:39:51 +00:00
[Events] EventListController test
Test for the Event List controller now works. #26.
This commit is contained in:
parent
95f9d783d3
commit
41e75d7494
@ -31,29 +31,17 @@ define(
|
|||||||
|
|
||||||
describe("The real time event list controller", function () {
|
describe("The real time event list controller", function () {
|
||||||
var mockScope,
|
var mockScope,
|
||||||
mockTelemetry,
|
//mockTelemetry,
|
||||||
mockTelemetryHandler,
|
mockTelemetryHandler,
|
||||||
mockHandle,
|
mockHandle,
|
||||||
mockTelemetryFormatter,
|
mockTelemetryFormatter,
|
||||||
testMetadata,
|
|
||||||
controller;
|
controller;
|
||||||
/*
|
|
||||||
var mockDomainObject,
|
|
||||||
mockTelemetryHandler,
|
|
||||||
mockHandle,
|
|
||||||
mockFormatter,
|
|
||||||
column;
|
|
||||||
*/
|
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
mockScope = jasmine.createSpyObj(
|
mockScope = jasmine.createSpyObj(
|
||||||
"$scope",
|
"$scope",
|
||||||
[ "$on", "$watch" ]
|
[ "$on", "$watch" ]
|
||||||
);
|
);
|
||||||
mockTelemetry = jasmine.createSpyObj(
|
|
||||||
"telemetryController",
|
|
||||||
[ "getResponse", "getMetadata", "getTelemetryObjects" ]
|
|
||||||
);
|
|
||||||
mockTelemetryHandler = jasmine.createSpyObj(
|
mockTelemetryHandler = jasmine.createSpyObj(
|
||||||
"telemetryHandler",
|
"telemetryHandler",
|
||||||
["handle"]
|
["handle"]
|
||||||
@ -66,32 +54,13 @@ define(
|
|||||||
"formatter",
|
"formatter",
|
||||||
["formatDomainValue", "formatRangeValue"]
|
["formatDomainValue", "formatRangeValue"]
|
||||||
);
|
);
|
||||||
testMetadata = [
|
|
||||||
{
|
|
||||||
domains: [
|
|
||||||
{ key: "d0", name: "D0" },
|
|
||||||
{ key: "d1", name: "D1" }
|
|
||||||
],
|
|
||||||
ranges: [
|
|
||||||
{ key: "r0", name: "R0" },
|
|
||||||
{ key: "r1", name: "R1" }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
domains: [
|
|
||||||
{ key: "d0", name: "D0" },
|
|
||||||
{ key: "d2", name: "D2" }
|
|
||||||
],
|
|
||||||
ranges: [
|
|
||||||
{ key: "r0", name: "R0" }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
];
|
|
||||||
mockTelemetry.getMetadata.andReturn(testMetadata);
|
|
||||||
mockTelemetry.getResponse.andReturn([]);
|
|
||||||
mockTelemetry.getTelemetryObjects.andReturn([]);
|
|
||||||
mockScope.telemetry = mockTelemetry;
|
|
||||||
controller = new RTEventListController(mockScope, mockTelemetryHandler, mockTelemetryFormatter);
|
controller = new RTEventListController(mockScope, mockTelemetryHandler, mockTelemetryFormatter);
|
||||||
|
|
||||||
|
// Add some data into the table
|
||||||
|
controller.setUpColumns([{id: 'a'}, {id: 'b'}]);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("listens for telemetry data updates", function () {
|
it("listens for telemetry data updates", function () {
|
||||||
@ -108,11 +77,12 @@ define(
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("provides a column for each unique domain and range", function () {
|
it("provides a domain and a range column", function () {
|
||||||
// Should have five columns based on metadata above,
|
// Should have two columns
|
||||||
// (d0, d1, d2, r0, r1)
|
expect(controller.rows()[0].length).toEqual([]);
|
||||||
mockScope.$watch.mostRecentCall.args[1](mockTelemetry);
|
|
||||||
expect(mockScope.headers).toEqual(["D0", "D1", "D2", "R0", "R1"]);
|
// And they should have these headers
|
||||||
|
expect(controller.headers()).toEqual(["Time", "Message"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("does not throw if telemetry controller is undefined", function () {
|
it("does not throw if telemetry controller is undefined", function () {
|
||||||
@ -121,12 +91,6 @@ define(
|
|||||||
expect(mockScope.$watch.mostRecentCall.args[1])
|
expect(mockScope.$watch.mostRecentCall.args[1])
|
||||||
.not.toThrow();
|
.not.toThrow();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("provides default columns if domain/range metadata is unavailable", function () {
|
|
||||||
mockTelemetry.getMetadata.andReturn([]);
|
|
||||||
mockScope.$watch.mostRecentCall.args[1](mockTelemetry);
|
|
||||||
expect(mockScope.headers).toEqual(["Time", "Message"]);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
Loading…
x
Reference in New Issue
Block a user