mirror of
https://github.com/nasa/openmct.git
synced 2025-01-21 12:05:12 +00:00
[Events] Starting tests
Starting to write tests for the real time messages view. #26.
This commit is contained in:
parent
42361aff25
commit
750d3f473e
@ -17,6 +17,7 @@
|
|||||||
"platform/features/plot",
|
"platform/features/plot",
|
||||||
"platform/features/scrolling",
|
"platform/features/scrolling",
|
||||||
"platform/features/events",
|
"platform/features/events",
|
||||||
|
"platform/features/rtevents",
|
||||||
"platform/forms",
|
"platform/forms",
|
||||||
"platform/persistence/queue",
|
"platform/persistence/queue",
|
||||||
"platform/policy",
|
"platform/policy",
|
||||||
|
@ -0,0 +1,84 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT Web includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RTEventSpec. Created by vwoeltje on 11/6/14. Modified by shale on 06/25/2015.
|
||||||
|
*/
|
||||||
|
define(
|
||||||
|
["../src/DomainColumn"],
|
||||||
|
function (DomainColumn) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var TEST_DOMAIN_VALUE = "some formatted domain value";
|
||||||
|
|
||||||
|
describe("A real time event list domain column", function () {
|
||||||
|
var mockDataSet,
|
||||||
|
testMetadata,
|
||||||
|
mockFormatter,
|
||||||
|
column;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
mockDataSet = jasmine.createSpyObj(
|
||||||
|
"data",
|
||||||
|
[ "getDomainValue" ]
|
||||||
|
);
|
||||||
|
mockFormatter = jasmine.createSpyObj(
|
||||||
|
"formatter",
|
||||||
|
[ "formatDomainValue", "formatRangeValue" ]
|
||||||
|
);
|
||||||
|
testMetadata = {
|
||||||
|
key: "testKey",
|
||||||
|
name: "Test Name"
|
||||||
|
};
|
||||||
|
mockFormatter.formatDomainValue.andReturn(TEST_DOMAIN_VALUE);
|
||||||
|
|
||||||
|
column = new DomainColumn(testMetadata, mockFormatter);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("reports a column header from domain metadata", function () {
|
||||||
|
expect(column.getTitle()).toEqual("Test Name");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("looks up data from a data set", function () {
|
||||||
|
column.getValue(undefined, mockDataSet, 42);
|
||||||
|
expect(mockDataSet.getDomainValue)
|
||||||
|
.toHaveBeenCalledWith(42, "testKey");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("formats domain values as time", function () {
|
||||||
|
mockDataSet.getDomainValue.andReturn(402513731000);
|
||||||
|
|
||||||
|
// Should have just given the value the formatter gave
|
||||||
|
expect(column.getValue(undefined, mockDataSet, 42))
|
||||||
|
.toEqual(TEST_DOMAIN_VALUE);
|
||||||
|
|
||||||
|
// Make sure that service interactions were as expected
|
||||||
|
expect(mockFormatter.formatDomainValue)
|
||||||
|
.toHaveBeenCalledWith(402513731000);
|
||||||
|
expect(mockFormatter.formatRangeValue)
|
||||||
|
.not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
@ -0,0 +1,110 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT Web includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RTEventSpec. Created by shale on 06/25/2015.
|
||||||
|
*/
|
||||||
|
define(
|
||||||
|
["../src/RTEventListController"],
|
||||||
|
function (RTEventListController) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
describe("The real time event list controller", function () {
|
||||||
|
var mockScope,
|
||||||
|
mockTelemetry,
|
||||||
|
testMetadata,
|
||||||
|
controller;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
mockScope = jasmine.createSpyObj(
|
||||||
|
"$scope",
|
||||||
|
[ "$on", "$watch" ]
|
||||||
|
);
|
||||||
|
mockTelemetry = jasmine.createSpyObj(
|
||||||
|
"telemetryController",
|
||||||
|
[ "getResponse", "getMetadata", "getTelemetryObjects" ]
|
||||||
|
);
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("listens for telemetry data updates", function () {
|
||||||
|
expect(mockScope.$on).toHaveBeenCalledWith(
|
||||||
|
"telemetryUpdate",
|
||||||
|
jasmine.any(Function)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("watches for telemetry controller changes", function () {
|
||||||
|
expect(mockScope.$watch).toHaveBeenCalledWith(
|
||||||
|
"telemetry",
|
||||||
|
jasmine.any(Function)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("provides a column for each unique domain and range", function () {
|
||||||
|
// Should have five columns based on metadata above,
|
||||||
|
// (d0, d1, d2, r0, r1)
|
||||||
|
mockScope.$watch.mostRecentCall.args[1](mockTelemetry);
|
||||||
|
expect(mockScope.headers).toEqual(["D0", "D1", "D2", "R0", "R1"]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("does not throw if telemetry controller is undefined", function () {
|
||||||
|
// Just a general robustness check
|
||||||
|
mockScope.telemetry = undefined;
|
||||||
|
expect(mockScope.$watch.mostRecentCall.args[1])
|
||||||
|
.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"]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
@ -0,0 +1,81 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT Web includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
/*global define,describe,it,expect,beforeEach,waitsFor,jasmine*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RTEventSpec. Created by vwoeltje on 11/6/14. Modified by shale on 06/25/2015.
|
||||||
|
*/
|
||||||
|
define(
|
||||||
|
["../src/RangeColumn"],
|
||||||
|
function (RangeColumn) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var TEST_RANGE_VALUE = "some formatted range value";
|
||||||
|
|
||||||
|
describe("A real time event list range column", function () {
|
||||||
|
var mockDataSet,
|
||||||
|
testMetadata,
|
||||||
|
mockFormatter,
|
||||||
|
column;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
mockDataSet = jasmine.createSpyObj(
|
||||||
|
"data",
|
||||||
|
[ "getRangeValue" ]
|
||||||
|
);
|
||||||
|
mockFormatter = jasmine.createSpyObj(
|
||||||
|
"formatter",
|
||||||
|
[ "formatDomainValue", "formatRangeValue" ]
|
||||||
|
);
|
||||||
|
testMetadata = {
|
||||||
|
key: "testKey",
|
||||||
|
name: "Test Name"
|
||||||
|
};
|
||||||
|
mockFormatter.formatRangeValue.andReturn(TEST_RANGE_VALUE);
|
||||||
|
|
||||||
|
column = new RangeColumn(testMetadata, mockFormatter);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("reports a column header from range metadata", function () {
|
||||||
|
expect(column.getTitle()).toEqual("Test Name");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("looks up data from a data set", function () {
|
||||||
|
column.getValue(undefined, mockDataSet, 42);
|
||||||
|
expect(mockDataSet.getRangeValue)
|
||||||
|
.toHaveBeenCalledWith(42, "testKey");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("formats range values as time", function () {
|
||||||
|
mockDataSet.getRangeValue.andReturn(123.45678);
|
||||||
|
expect(column.getValue(undefined, mockDataSet, 42))
|
||||||
|
.toEqual(TEST_RANGE_VALUE);
|
||||||
|
|
||||||
|
// Make sure that service interactions were as expected
|
||||||
|
expect(mockFormatter.formatRangeValue)
|
||||||
|
.toHaveBeenCalledWith(123.45678);
|
||||||
|
expect(mockFormatter.formatDomainValue)
|
||||||
|
.not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
@ -0,0 +1,81 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||||
|
* as represented by the Administrator of the National Aeronautics and Space
|
||||||
|
* Administration. All rights reserved.
|
||||||
|
*
|
||||||
|
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
* License for the specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*
|
||||||
|
* Open MCT Web includes source code licensed under additional open source
|
||||||
|
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||||
|
* this source code distribution or the Licensing information page available
|
||||||
|
* at runtime from the About dialog for additional information.
|
||||||
|
*****************************************************************************/
|
||||||
|
/*global define,describe,it,expect,beforeEach,jasmine*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RTEventSpec. Created by shale on 06/25/2015.
|
||||||
|
*/
|
||||||
|
define(
|
||||||
|
["../../src/policies/RTMessagesViewPolicy"],
|
||||||
|
function (RTMessagesViewPolicy) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
describe("The real time messages view policy", function () {
|
||||||
|
var mockDomainObject,
|
||||||
|
mockTelemetry,
|
||||||
|
telemetryType,
|
||||||
|
testType,
|
||||||
|
testView,
|
||||||
|
testMetadata,
|
||||||
|
policy;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
|
||||||
|
testView = { key: "string" };
|
||||||
|
testMetadata = {};
|
||||||
|
|
||||||
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
|
'domainObject',
|
||||||
|
['getModel', 'getCapability']
|
||||||
|
);
|
||||||
|
mockTelemetry = jasmine.createSpyObj(
|
||||||
|
'telemetry',
|
||||||
|
['getMetadata']
|
||||||
|
);
|
||||||
|
|
||||||
|
mockDomainObject.getModel.andCallFake(function (c) {
|
||||||
|
return {type: testType};
|
||||||
|
});
|
||||||
|
mockDomainObject.getCapability.andCallFake(function (c) {
|
||||||
|
return c === 'telemetry' ? mockTelemetry : undefined;
|
||||||
|
});
|
||||||
|
mockTelemetry.getMetadata.andReturn(testMetadata);
|
||||||
|
|
||||||
|
policy = new RTMessagesViewPolicy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("disallows the message view for objects without string telemetry", function () {
|
||||||
|
testMetadata.ranges = [ { format: 'notString' } ];
|
||||||
|
expect(policy.allow({ key: 'messages' }, mockDomainObject)).toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("allows the message view for objects with string telemetry", function () {
|
||||||
|
testMetadata.ranges = [ { format: 'string' } ];
|
||||||
|
expect(policy.allow({ key: 'messages' }, mockDomainObject)).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("returns true when the current view is not the Messages view", function () {
|
||||||
|
expect(policy.allow({ key: 'notMessages' }, mockDomainObject)).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
@ -0,0 +1,6 @@
|
|||||||
|
[
|
||||||
|
"DomainColumn",
|
||||||
|
"RTEventListController",
|
||||||
|
"policies/RTMessagesViewPolicy",
|
||||||
|
"RangeColumn"
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user