Merge remote-tracking branch 'github/master' into open115b
Merge in latest from master into topic branch for nasa/openmctweb#115 Conflicts: platform/features/conductor/src/ConductorRepresenter.js platform/features/conductor/src/ConductorTelemetrySeries.js platform/features/conductor/src/TimeConductor.js platform/features/conductor/test/ConductorRepresenterSpec.js platform/features/conductor/test/ConductorTelemetrySeriesSpec.js
This commit is contained in:
@@ -44,7 +44,8 @@ define(
|
||||
];
|
||||
|
||||
describe("ConductorRepresenter", function () {
|
||||
var mockConductorService,
|
||||
var mockThrottle,
|
||||
mockConductorService,
|
||||
mockCompile,
|
||||
testViews,
|
||||
mockScope,
|
||||
@@ -64,6 +65,7 @@ define(
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
mockThrottle = jasmine.createSpy('throttle');
|
||||
mockConductorService = jasmine.createSpyObj(
|
||||
'conductorService',
|
||||
['getConductor']
|
||||
@@ -82,8 +84,12 @@ define(
|
||||
mockCompile.andReturn(mockCompiledTemplate);
|
||||
mockCompiledTemplate.andReturn(mockNewElement);
|
||||
mockScope.$new.andReturn(mockNewScope);
|
||||
mockThrottle.andCallFake(function (fn) {
|
||||
return fn;
|
||||
});
|
||||
|
||||
representer = new ConductorRepresenter(
|
||||
mockThrottle,
|
||||
mockConductorService,
|
||||
mockCompile,
|
||||
testViews,
|
||||
@@ -121,15 +127,13 @@ define(
|
||||
});
|
||||
|
||||
it("exposes conductor state in scope", function () {
|
||||
mockConductor.queryStart.andReturn(42);
|
||||
mockConductor.queryEnd.andReturn(12321);
|
||||
mockConductor.displayStart.andReturn(1977);
|
||||
mockConductor.displayEnd.andReturn(1984);
|
||||
representer.represent(testViews[0], {});
|
||||
|
||||
expect(mockNewScope.ngModel.conductor).toEqual({
|
||||
inner: { start: 1977, end: 1984 },
|
||||
outer: { start: 42, end: 12321 }
|
||||
outer: { start: 1977, end: 1984 }
|
||||
});
|
||||
});
|
||||
|
||||
@@ -156,20 +160,56 @@ define(
|
||||
testState.inner.end
|
||||
);
|
||||
expect(mockConductor.displayEnd).toHaveBeenCalledWith(1984);
|
||||
});
|
||||
|
||||
fireWatch(
|
||||
mockNewScope,
|
||||
'ngModel.conductor.outer.start',
|
||||
testState.outer.start
|
||||
);
|
||||
expect(mockConductor.queryStart).toHaveBeenCalledWith(-1977);
|
||||
describe("when bounds are changing", function () {
|
||||
var mockThrottledFn = jasmine.createSpy('throttledFn'),
|
||||
testBounds;
|
||||
|
||||
fireWatch(
|
||||
mockNewScope,
|
||||
'ngModel.conductor.outer.end',
|
||||
testState.outer.end
|
||||
);
|
||||
expect(mockConductor.queryEnd).toHaveBeenCalledWith(12321);
|
||||
function fireThrottledFn() {
|
||||
mockThrottle.mostRecentCall.args[0]();
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
mockThrottle.andReturn(mockThrottledFn);
|
||||
representer.represent(testViews[0], {});
|
||||
testBounds = { start: 0, end: 1000 };
|
||||
mockNewScope.conductor.inner = testBounds;
|
||||
mockConductor.displayStart.andCallFake(function () {
|
||||
return testBounds.start;
|
||||
});
|
||||
mockConductor.displayEnd.andCallFake(function () {
|
||||
return testBounds.end;
|
||||
});
|
||||
});
|
||||
|
||||
it("does not broadcast while bounds are changing", function () {
|
||||
expect(mockScope.$broadcast).not.toHaveBeenCalled();
|
||||
testBounds.start = 100;
|
||||
fireWatch(mockNewScope, 'conductor.inner.start', testBounds.start);
|
||||
testBounds.end = 500;
|
||||
fireWatch(mockNewScope, 'conductor.inner.end', testBounds.end);
|
||||
fireThrottledFn();
|
||||
testBounds.start = 200;
|
||||
fireWatch(mockNewScope, 'conductor.inner.start', testBounds.start);
|
||||
testBounds.end = 400;
|
||||
fireWatch(mockNewScope, 'conductor.inner.end', testBounds.end);
|
||||
fireThrottledFn();
|
||||
expect(mockScope.$broadcast).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does broadcast when bounds have stabilized", function () {
|
||||
expect(mockScope.$broadcast).not.toHaveBeenCalled();
|
||||
testBounds.start = 100;
|
||||
fireWatch(mockNewScope, 'conductor.inner.start', testBounds.start);
|
||||
testBounds.end = 500;
|
||||
fireWatch(mockNewScope, 'conductor.inner.end', testBounds.end);
|
||||
fireThrottledFn();
|
||||
fireWatch(mockNewScope, 'conductor.inner.start', testBounds.start);
|
||||
fireWatch(mockNewScope, 'conductor.inner.end', testBounds.end);
|
||||
fireThrottledFn();
|
||||
expect(mockScope.$broadcast).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it("exposes domain selection in scope", function () {
|
||||
|
||||
@@ -43,9 +43,9 @@ define(
|
||||
|
||||
it("initializes a time conductor around the current time", function () {
|
||||
var conductor = conductorService.getConductor();
|
||||
expect(conductor.queryStart() <= TEST_NOW).toBeTruthy();
|
||||
expect(conductor.queryEnd() >= TEST_NOW).toBeTruthy();
|
||||
expect(conductor.queryEnd() > conductor.queryStart())
|
||||
expect(conductor.displayStart() <= TEST_NOW).toBeTruthy();
|
||||
expect(conductor.displayEnd() >= TEST_NOW).toBeTruthy();
|
||||
expect(conductor.displayEnd() > conductor.displayStart())
|
||||
.toBeTruthy();
|
||||
});
|
||||
|
||||
|
||||
@@ -156,27 +156,6 @@ define(
|
||||
// }]);
|
||||
// });
|
||||
|
||||
it("prunes historical values to the displayable range", function () {
|
||||
var packagedTelemetry;
|
||||
decorator.requestTelemetry([{ source: "abc", key: "xyz" }]);
|
||||
packagedTelemetry = mockPromise.then.mostRecentCall.args[0]({
|
||||
"abc": { "xyz": mockSeries }
|
||||
});
|
||||
expect(seriesIsInWindow(packagedTelemetry.abc.xyz))
|
||||
.toBeTruthy();
|
||||
});
|
||||
|
||||
it("prunes subscribed values to the displayable range", function () {
|
||||
var mockCallback = jasmine.createSpy('callback'),
|
||||
packagedTelemetry;
|
||||
decorator.subscribe(mockCallback, [{ source: "abc", key: "xyz" }]);
|
||||
mockTelemetryService.subscribe.mostRecentCall.args[0]({
|
||||
"abc": { "xyz": mockSeries }
|
||||
});
|
||||
packagedTelemetry = mockCallback.mostRecentCall.args[0];
|
||||
expect(seriesIsInWindow(packagedTelemetry.abc.xyz))
|
||||
.toBeTruthy();
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* 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*/
|
||||
|
||||
define(
|
||||
["../src/ConductorTelemetrySeries", "./TestTimeConductor"],
|
||||
function (ConductorTelemetrySeries, TestTimeConductor) {
|
||||
"use strict";
|
||||
|
||||
describe("ConductorTelemetrySeries", function () {
|
||||
var mockSeries,
|
||||
mockConductor,
|
||||
testArray,
|
||||
series;
|
||||
|
||||
beforeEach(function () {
|
||||
testArray = [ -10, 0, 42, 1977, 12321 ];
|
||||
|
||||
mockSeries = jasmine.createSpyObj(
|
||||
'series',
|
||||
[ 'getPointCount', 'getDomainValue', 'getRangeValue' ]
|
||||
);
|
||||
mockConductor = new TestTimeConductor();
|
||||
|
||||
mockSeries.getPointCount.andCallFake(function () {
|
||||
return testArray.length;
|
||||
});
|
||||
mockSeries.getDomainValue.andCallFake(function (i) {
|
||||
return testArray[i];
|
||||
});
|
||||
mockSeries.getRangeValue.andCallFake(function (i) {
|
||||
return testArray[i] * 2;
|
||||
});
|
||||
|
||||
mockConductor.displayStart.andReturn(0);
|
||||
mockConductor.displayEnd.andReturn(2000);
|
||||
|
||||
series = new ConductorTelemetrySeries(
|
||||
mockSeries,
|
||||
mockConductor
|
||||
);
|
||||
});
|
||||
|
||||
it("reduces the apparent size of a series", function () {
|
||||
expect(series.getPointCount()).toEqual(3);
|
||||
});
|
||||
|
||||
it("maps domain value indexes to the displayable range", function () {
|
||||
[0, 1, 2].forEach(function (i) {
|
||||
expect(series.getDomainValue(i))
|
||||
.toEqual(mockSeries.getDomainValue(i + 1));
|
||||
});
|
||||
});
|
||||
|
||||
it("maps range value indexes to the displayable range", function () {
|
||||
[0, 1, 2].forEach(function (i) {
|
||||
expect(series.getRangeValue(i))
|
||||
.toEqual(mockSeries.getRangeValue(i + 1));
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -43,19 +43,13 @@ define(
|
||||
});
|
||||
|
||||
it("provides accessors for query/display start/end times", function () {
|
||||
expect(conductor.queryStart()).toEqual(testStart);
|
||||
expect(conductor.queryEnd()).toEqual(testEnd);
|
||||
expect(conductor.displayStart()).toEqual(testStart);
|
||||
expect(conductor.displayEnd()).toEqual(testEnd);
|
||||
});
|
||||
|
||||
it("provides setters for query/display start/end times", function () {
|
||||
expect(conductor.queryStart(1)).toEqual(1);
|
||||
expect(conductor.queryEnd(2)).toEqual(2);
|
||||
expect(conductor.displayStart(3)).toEqual(3);
|
||||
expect(conductor.displayEnd(4)).toEqual(4);
|
||||
expect(conductor.queryStart()).toEqual(1);
|
||||
expect(conductor.queryEnd()).toEqual(2);
|
||||
expect(conductor.displayStart()).toEqual(3);
|
||||
expect(conductor.displayEnd()).toEqual(4);
|
||||
});
|
||||
|
||||
@@ -2,6 +2,5 @@
|
||||
"ConductorRepresenter",
|
||||
"ConductorService",
|
||||
"ConductorTelemetryDecorator",
|
||||
"ConductorTelemetrySeries",
|
||||
"TimeConductor"
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user