Merge remote-tracking branch 'github/master' into open450b
Merge latest from master branch to reconcile conflicts for https://github.com/nasa/openmctweb/pull/469 Conflicts: platform/commonUI/general/bundle.json
This commit is contained in:
@@ -35,10 +35,21 @@ define(
|
||||
* Both "Start" and "Restart" share this implementation, but
|
||||
* control their visibility with different `appliesTo` behavior.
|
||||
*
|
||||
* @implements Action
|
||||
* @implements {Action}
|
||||
* @memberof platform/features/clock
|
||||
* @constructor
|
||||
* @param {Function} now a function which returns the current
|
||||
* time (typically wrapping `Date.now`)
|
||||
* @param {ActionContext} context the context for this action
|
||||
*/
|
||||
function AbstractStartTimerAction(now, context) {
|
||||
var domainObject = context.domainObject;
|
||||
this.domainObject = context.domainObject;
|
||||
this.now = now;
|
||||
}
|
||||
|
||||
AbstractStartTimerAction.prototype.perform = function () {
|
||||
var domainObject = this.domainObject,
|
||||
now = this.now;
|
||||
|
||||
function doPersist() {
|
||||
var persistence = domainObject.getCapability('persistence');
|
||||
@@ -49,13 +60,9 @@ define(
|
||||
model.timestamp = now();
|
||||
}
|
||||
|
||||
return {
|
||||
perform: function () {
|
||||
return domainObject.useCapability('mutation', setTimestamp)
|
||||
.then(doPersist);
|
||||
}
|
||||
};
|
||||
}
|
||||
return domainObject.useCapability('mutation', setTimestamp)
|
||||
.then(doPersist);
|
||||
};
|
||||
|
||||
return AbstractStartTimerAction;
|
||||
}
|
||||
|
||||
@@ -31,12 +31,22 @@ define(
|
||||
*
|
||||
* Behaves the same as (and delegates functionality to)
|
||||
* the "Start" action.
|
||||
* @implements Action
|
||||
*
|
||||
* @extends {platform/features/clock.AbstractTimerAction}
|
||||
* @implements {Action}
|
||||
* @memberof platform/features/clock
|
||||
* @constructor
|
||||
* @param {Function} now a function which returns the current
|
||||
* time (typically wrapping `Date.now`)
|
||||
* @param {ActionContext} context the context for this action
|
||||
*/
|
||||
function RestartTimerAction(now, context) {
|
||||
return new AbstractStartTimerAction(now, context);
|
||||
AbstractStartTimerAction.apply(this, [ now, context ]);
|
||||
}
|
||||
|
||||
RestartTimerAction.prototype =
|
||||
Object.create(AbstractStartTimerAction.prototype);
|
||||
|
||||
RestartTimerAction.appliesTo = function (context) {
|
||||
var model =
|
||||
(context.domainObject && context.domainObject.getModel())
|
||||
|
||||
@@ -32,12 +32,21 @@ define(
|
||||
* Sets the reference timestamp in a timer to the current
|
||||
* time, such that it begins counting up.
|
||||
*
|
||||
* @implements Action
|
||||
* @extends {platform/features/clock.AbstractTimerAction}
|
||||
* @implements {Action}
|
||||
* @memberof platform/features/clock
|
||||
* @constructor
|
||||
* @param {Function} now a function which returns the current
|
||||
* time (typically wrapping `Date.now`)
|
||||
* @param {ActionContext} context the context for this action
|
||||
*/
|
||||
function StartTimerAction(now, context) {
|
||||
return new AbstractStartTimerAction(now, context);
|
||||
AbstractStartTimerAction.apply(this, [ now, context ]);
|
||||
}
|
||||
|
||||
StartTimerAction.prototype =
|
||||
Object.create(AbstractStartTimerAction.prototype);
|
||||
|
||||
StartTimerAction.appliesTo = function (context) {
|
||||
var model =
|
||||
(context.domainObject && context.domainObject.getModel())
|
||||
|
||||
@@ -30,19 +30,21 @@ define(
|
||||
* Controller for views of a Clock domain object.
|
||||
*
|
||||
* @constructor
|
||||
* @memberof platform/features/clock
|
||||
* @param {angular.Scope} $scope the Angular scope
|
||||
* @param {platform/features/clock.TickerService} tickerService
|
||||
* a service used to align behavior with clock ticks
|
||||
*/
|
||||
function ClockController($scope, tickerService) {
|
||||
var text,
|
||||
ampm,
|
||||
use24,
|
||||
lastTimestamp,
|
||||
var lastTimestamp,
|
||||
unlisten,
|
||||
timeFormat;
|
||||
timeFormat,
|
||||
self = this;
|
||||
|
||||
function update() {
|
||||
var m = moment.utc(lastTimestamp);
|
||||
text = timeFormat && m.format(timeFormat);
|
||||
ampm = m.format("A"); // Just the AM or PM part
|
||||
self.textValue = timeFormat && m.format(timeFormat);
|
||||
self.ampmValue = m.format("A"); // Just the AM or PM part
|
||||
}
|
||||
|
||||
function tick(timestamp) {
|
||||
@@ -56,8 +58,8 @@ define(
|
||||
if (clockFormat !== undefined) {
|
||||
baseFormat = clockFormat[0];
|
||||
|
||||
use24 = clockFormat[1] === 'clock24';
|
||||
timeFormat = use24 ?
|
||||
self.use24 = clockFormat[1] === 'clock24';
|
||||
timeFormat = self.use24 ?
|
||||
baseFormat.replace('hh', "HH") : baseFormat;
|
||||
|
||||
update();
|
||||
@@ -69,32 +71,32 @@ define(
|
||||
// Listen for clock ticks ... and stop listening on destroy
|
||||
unlisten = tickerService.listen(tick);
|
||||
$scope.$on('$destroy', unlisten);
|
||||
|
||||
return {
|
||||
/**
|
||||
* Get the clock's time zone, as displayable text.
|
||||
* @returns {string}
|
||||
*/
|
||||
zone: function () {
|
||||
return "UTC";
|
||||
},
|
||||
/**
|
||||
* Get the current time, as displayable text.
|
||||
* @returns {string}
|
||||
*/
|
||||
text: function () {
|
||||
return text;
|
||||
},
|
||||
/**
|
||||
* Get the text to display to qualify a time as AM or PM.
|
||||
* @returns {string}
|
||||
*/
|
||||
ampm: function () {
|
||||
return use24 ? '' : ampm;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the clock's time zone, as displayable text.
|
||||
* @returns {string}
|
||||
*/
|
||||
ClockController.prototype.zone = function () {
|
||||
return "UTC";
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the current time, as displayable text.
|
||||
* @returns {string}
|
||||
*/
|
||||
ClockController.prototype.text = function () {
|
||||
return this.textValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the text to display to qualify a time as AM or PM.
|
||||
* @returns {string}
|
||||
*/
|
||||
ClockController.prototype.ampm = function () {
|
||||
return this.use24 ? '' : this.ampmValue;
|
||||
};
|
||||
|
||||
return ClockController;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -31,6 +31,12 @@ define(
|
||||
*
|
||||
* This is a short-term workaround to assure Timer views stay
|
||||
* up-to-date; should be replaced by a global auto-refresh.
|
||||
*
|
||||
* @constructor
|
||||
* @memberof platform/features/clock
|
||||
* @param {angular.Scope} $scope the Angular scope
|
||||
* @param {platform/features/clock.TickerService} tickerService
|
||||
* a service used to align behavior with clock ticks
|
||||
*/
|
||||
function RefreshingController($scope, tickerService) {
|
||||
var unlisten;
|
||||
|
||||
@@ -33,26 +33,30 @@ define(
|
||||
* Controller for views of a Timer domain object.
|
||||
*
|
||||
* @constructor
|
||||
* @memberof platform/features/clock
|
||||
* @param {angular.Scope} $scope the Angular scope
|
||||
* @param $window Angular-provided window object
|
||||
* @param {Function} now a function which returns the current
|
||||
* time (typically wrapping `Date.now`)
|
||||
*/
|
||||
function TimerController($scope, $window, now) {
|
||||
var timerObject,
|
||||
relevantAction,
|
||||
sign = '',
|
||||
text = '',
|
||||
formatter,
|
||||
active = true,
|
||||
relativeTimestamp,
|
||||
lastTimestamp;
|
||||
lastTimestamp,
|
||||
self = this;
|
||||
|
||||
function update() {
|
||||
var timeDelta = lastTimestamp - relativeTimestamp;
|
||||
|
||||
if (formatter && !isNaN(timeDelta)) {
|
||||
text = formatter(timeDelta);
|
||||
sign = timeDelta < 0 ? "-" : timeDelta >= 1000 ? "+" : "";
|
||||
self.textValue = formatter(timeDelta);
|
||||
self.signValue = timeDelta < 0 ? "-" :
|
||||
timeDelta >= 1000 ? "+" : "";
|
||||
} else {
|
||||
text = "";
|
||||
sign = "";
|
||||
self.textValue = "";
|
||||
self.signValue = "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +79,7 @@ define(
|
||||
updateFormat(formatKey);
|
||||
updateTimestamp(timestamp);
|
||||
|
||||
relevantAction = actionCapability &&
|
||||
self.relevantAction = actionCapability &&
|
||||
actionCapability.getActions(actionKey)[0];
|
||||
|
||||
update();
|
||||
@@ -92,13 +96,14 @@ define(
|
||||
}
|
||||
|
||||
function tick() {
|
||||
var lastSign = sign, lastText = text;
|
||||
var lastSign = self.signValue,
|
||||
lastText = self.textValue;
|
||||
lastTimestamp = now();
|
||||
update();
|
||||
// We're running in an animation frame, not in a digest cycle.
|
||||
// We need to trigger a digest cycle if our displayable data
|
||||
// changes.
|
||||
if (lastSign !== sign || lastText !== text) {
|
||||
if (lastSign !== self.signValue || lastText !== self.textValue) {
|
||||
$scope.$apply();
|
||||
}
|
||||
if (active) {
|
||||
@@ -117,51 +122,59 @@ define(
|
||||
active = false;
|
||||
});
|
||||
|
||||
return {
|
||||
/**
|
||||
* Get the glyph to display for the start/restart button.
|
||||
* @returns {string} glyph to display
|
||||
*/
|
||||
buttonGlyph: function () {
|
||||
return relevantAction ?
|
||||
relevantAction.getMetadata().glyph : "";
|
||||
},
|
||||
/**
|
||||
* Get the text to show for the start/restart button
|
||||
* (e.g. in a tooltip)
|
||||
* @returns {string} name of the action
|
||||
*/
|
||||
buttonText: function () {
|
||||
return relevantAction ?
|
||||
relevantAction.getMetadata().name : "";
|
||||
},
|
||||
/**
|
||||
* Perform the action associated with the start/restart button.
|
||||
*/
|
||||
clickButton: function () {
|
||||
if (relevantAction) {
|
||||
relevantAction.perform();
|
||||
updateObject($scope.domainObject);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Get the sign (+ or -) of the current timer value, as
|
||||
* displayable text.
|
||||
* @returns {string} sign of the current timer value
|
||||
*/
|
||||
sign: function () {
|
||||
return sign;
|
||||
},
|
||||
/**
|
||||
* Get the text to display for the current timer value.
|
||||
* @returns {string} current timer value
|
||||
*/
|
||||
text: function () {
|
||||
return text;
|
||||
}
|
||||
};
|
||||
this.$scope = $scope;
|
||||
this.signValue = '';
|
||||
this.textValue = '';
|
||||
this.updateObject = updateObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the glyph to display for the start/restart button.
|
||||
* @returns {string} glyph to display
|
||||
*/
|
||||
TimerController.prototype.buttonGlyph = function () {
|
||||
return this.relevantAction ?
|
||||
this.relevantAction.getMetadata().glyph : "";
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the text to show for the start/restart button
|
||||
* (e.g. in a tooltip)
|
||||
* @returns {string} name of the action
|
||||
*/
|
||||
TimerController.prototype.buttonText = function () {
|
||||
return this.relevantAction ?
|
||||
this.relevantAction.getMetadata().name : "";
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Perform the action associated with the start/restart button.
|
||||
*/
|
||||
TimerController.prototype.clickButton = function () {
|
||||
if (this.relevantAction) {
|
||||
this.relevantAction.perform();
|
||||
this.updateObject(this.$scope.domainObject);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the sign (+ or -) of the current timer value, as
|
||||
* displayable text.
|
||||
* @returns {string} sign of the current timer value
|
||||
*/
|
||||
TimerController.prototype.sign = function () {
|
||||
return this.signValue;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the text to display for the current timer value.
|
||||
* @returns {string} current timer value
|
||||
*/
|
||||
TimerController.prototype.text = function () {
|
||||
return this.textValue;
|
||||
};
|
||||
|
||||
return TimerController;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -37,45 +37,39 @@ define(
|
||||
* supports `TimerController`.
|
||||
*
|
||||
* @constructor
|
||||
* @memberof platform/features/clock
|
||||
*/
|
||||
function TimerFormatter() {
|
||||
|
||||
// Round this timestamp down to the second boundary
|
||||
// (e.g. 1124ms goes down to 1000ms, -2400ms goes down to -3000ms)
|
||||
function toWholeSeconds(duration) {
|
||||
return Math.abs(Math.floor(duration / 1000) * 1000);
|
||||
}
|
||||
|
||||
// Short-form format, e.g. 02:22:11
|
||||
function short(duration) {
|
||||
return moment.duration(toWholeSeconds(duration), 'ms')
|
||||
.format(SHORT_FORMAT, { trim: false });
|
||||
}
|
||||
|
||||
// Long-form format, e.g. 3d 02:22:11
|
||||
function long(duration) {
|
||||
return moment.duration(toWholeSeconds(duration), 'ms')
|
||||
.format(LONG_FORMAT, { trim: false });
|
||||
}
|
||||
|
||||
return {
|
||||
/**
|
||||
* Format a duration for display, using the short form.
|
||||
* (e.g. 03:33:11)
|
||||
* @param {number} duration the duration, in milliseconds
|
||||
* @param {boolean} sign true if positive
|
||||
*/
|
||||
short: short,
|
||||
/**
|
||||
* Format a duration for display, using the long form.
|
||||
* (e.g. 0d 03:33:11)
|
||||
* @param {number} duration the duration, in milliseconds
|
||||
* @param {boolean} sign true if positive
|
||||
*/
|
||||
long: long
|
||||
};
|
||||
}
|
||||
|
||||
// Round this timestamp down to the second boundary
|
||||
// (e.g. 1124ms goes down to 1000ms, -2400ms goes down to -3000ms)
|
||||
function toWholeSeconds(duration) {
|
||||
return Math.abs(Math.floor(duration / 1000) * 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a duration for display, using the short form.
|
||||
* (e.g. 03:33:11)
|
||||
* @param {number} duration the duration, in milliseconds
|
||||
* @param {boolean} sign true if positive
|
||||
*/
|
||||
TimerFormatter.prototype.short = function (duration) {
|
||||
return moment.duration(toWholeSeconds(duration), 'ms')
|
||||
.format(SHORT_FORMAT, { trim: false });
|
||||
};
|
||||
|
||||
/**
|
||||
* Format a duration for display, using the long form.
|
||||
* (e.g. 0d 03:33:11)
|
||||
* @param {number} duration the duration, in milliseconds
|
||||
* @param {boolean} sign true if positive
|
||||
*/
|
||||
TimerFormatter.prototype.long = function (duration) {
|
||||
return moment.duration(toWholeSeconds(duration), 'ms')
|
||||
.format(LONG_FORMAT, { trim: false });
|
||||
};
|
||||
|
||||
return TimerFormatter;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -28,32 +28,40 @@ define(
|
||||
|
||||
/**
|
||||
* Indicator that displays the current UTC time in the status area.
|
||||
* @implements Indicator
|
||||
* @implements {Indicator}
|
||||
* @memberof platform/features/clock
|
||||
* @param {platform/features/clock.TickerService} tickerService
|
||||
* a service used to align behavior with clock ticks
|
||||
* @param {string} indicatorFormat format string for timestamps
|
||||
* shown in this indicator
|
||||
*/
|
||||
function ClockIndicator(tickerService, CLOCK_INDICATOR_FORMAT) {
|
||||
var text = "";
|
||||
function ClockIndicator(tickerService, indicatorFormat) {
|
||||
var self = this;
|
||||
|
||||
this.text = "";
|
||||
|
||||
tickerService.listen(function (timestamp) {
|
||||
text = moment.utc(timestamp).format(CLOCK_INDICATOR_FORMAT) + " UTC";
|
||||
self.text = moment.utc(timestamp)
|
||||
.format(indicatorFormat) + " UTC";
|
||||
});
|
||||
|
||||
return {
|
||||
getGlyph: function () {
|
||||
return "C";
|
||||
},
|
||||
getGlyphClass: function () {
|
||||
return "no-icon no-collapse float-right subtle";
|
||||
},
|
||||
getText: function () {
|
||||
return text;
|
||||
},
|
||||
getDescription: function () {
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
ClockIndicator.prototype.getGlyph = function () {
|
||||
return "C";
|
||||
};
|
||||
|
||||
ClockIndicator.prototype.getGlyphClass = function () {
|
||||
return "no-icon no-collapse float-right subtle";
|
||||
};
|
||||
|
||||
ClockIndicator.prototype.getText = function () {
|
||||
return this.text;
|
||||
};
|
||||
|
||||
ClockIndicator.prototype.getDescription = function () {
|
||||
return "";
|
||||
};
|
||||
|
||||
return ClockIndicator;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -30,23 +30,23 @@ define(
|
||||
* Calls functions every second, as close to the actual second
|
||||
* tick as is feasible.
|
||||
* @constructor
|
||||
* @memberof platform/features/clock
|
||||
* @param $timeout Angular's $timeout
|
||||
* @param {Function} now function to provide the current time in ms
|
||||
*/
|
||||
function TickerService($timeout, now) {
|
||||
var callbacks = [],
|
||||
last = now() - 1000;
|
||||
var self = this;
|
||||
|
||||
function tick() {
|
||||
var timestamp = now(),
|
||||
millis = timestamp % 1000;
|
||||
|
||||
// Only update callbacks if a second has actually passed.
|
||||
if (timestamp >= last + 1000) {
|
||||
callbacks.forEach(function (callback) {
|
||||
if (timestamp >= self.last + 1000) {
|
||||
self.callbacks.forEach(function (callback) {
|
||||
callback(timestamp);
|
||||
});
|
||||
last = timestamp - millis;
|
||||
self.last = timestamp - millis;
|
||||
}
|
||||
|
||||
// Try to update at exactly the next second
|
||||
@@ -55,35 +55,35 @@ define(
|
||||
|
||||
tick();
|
||||
|
||||
return {
|
||||
/**
|
||||
* Listen for clock ticks. The provided callback will
|
||||
* be invoked with the current timestamp (in milliseconds
|
||||
* since Jan 1 1970) at regular intervals, as near to the
|
||||
* second boundary as possible.
|
||||
*
|
||||
* @method listen
|
||||
* @name TickerService#listen
|
||||
* @param {Function} callback callback to invoke
|
||||
* @returns {Function} a function to unregister this listener
|
||||
*/
|
||||
listen: function (callback) {
|
||||
callbacks.push(callback);
|
||||
|
||||
// Provide immediate feedback
|
||||
callback(last);
|
||||
|
||||
// Provide a deregistration function
|
||||
return function () {
|
||||
callbacks = callbacks.filter(function (cb) {
|
||||
return cb !== callback;
|
||||
});
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
this.callbacks = [];
|
||||
this.last = now() - 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
* Listen for clock ticks. The provided callback will
|
||||
* be invoked with the current timestamp (in milliseconds
|
||||
* since Jan 1 1970) at regular intervals, as near to the
|
||||
* second boundary as possible.
|
||||
*
|
||||
* @param {Function} callback callback to invoke
|
||||
* @returns {Function} a function to unregister this listener
|
||||
*/
|
||||
TickerService.prototype.listen = function (callback) {
|
||||
var self = this;
|
||||
|
||||
self.callbacks.push(callback);
|
||||
|
||||
// Provide immediate feedback
|
||||
callback(this.last);
|
||||
|
||||
// Provide a deregistration function
|
||||
return function () {
|
||||
self.callbacks = self.callbacks.filter(function (cb) {
|
||||
return cb !== callback;
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
return TickerService;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -424,6 +424,58 @@ define(
|
||||
expect(controller.selected().style).not.toEqual(oldStyle);
|
||||
});
|
||||
|
||||
describe("on display bounds changes", function () {
|
||||
var testBounds;
|
||||
|
||||
beforeEach(function () {
|
||||
testBounds = { start: 123, end: 321 };
|
||||
mockScope.domainObject = mockDomainObject;
|
||||
mockScope.model = testModel;
|
||||
findWatch("domainObject")(mockDomainObject);
|
||||
findWatch("model.modified")(testModel.modified);
|
||||
findWatch("model.composition")(mockScope.model.composition);
|
||||
findOn('telemetry:display:bounds')({}, testBounds);
|
||||
});
|
||||
|
||||
it("issues new requests", function () {
|
||||
expect(mockHandle.request).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("requests only a single point", function () {
|
||||
expect(mockHandle.request.mostRecentCall.args[0].size)
|
||||
.toEqual(1);
|
||||
});
|
||||
|
||||
describe("and after data has been received", function () {
|
||||
var mockSeries,
|
||||
testValue;
|
||||
|
||||
beforeEach(function () {
|
||||
testValue = 12321;
|
||||
|
||||
mockSeries = jasmine.createSpyObj('series', [
|
||||
'getPointCount',
|
||||
'getDomainValue',
|
||||
'getRangeValue'
|
||||
]);
|
||||
mockSeries.getPointCount.andReturn(1);
|
||||
mockSeries.getRangeValue.andReturn(testValue);
|
||||
|
||||
// Fire the callback associated with the request
|
||||
mockHandle.request.mostRecentCall.args[1](
|
||||
mockHandle.getTelemetryObjects()[0],
|
||||
mockSeries
|
||||
);
|
||||
});
|
||||
|
||||
it("updates displayed values", function () {
|
||||
expect(controller.getElements()[0].value)
|
||||
.toEqual("Formatted " + testValue);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it("reflects limit status", function () {
|
||||
var elements;
|
||||
|
||||
@@ -459,6 +511,7 @@ define(
|
||||
expect(elements[1].cssClass).toEqual("alarm-b");
|
||||
expect(elements[2].cssClass).toEqual("alarm-c");
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -286,6 +286,34 @@ define(
|
||||
expect(mockHandle.request.calls.length).toEqual(2);
|
||||
});
|
||||
|
||||
|
||||
it("maintains externally-provided domain axis bounds after data is received", function () {
|
||||
mockSeries.getPointCount.andReturn(3);
|
||||
mockSeries.getRangeValue.andReturn(42);
|
||||
mockSeries.getDomainValue.andCallFake(function (i) {
|
||||
return 2500 + i * 2500;
|
||||
});
|
||||
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
fireEvent("telemetry:display:bounds", [
|
||||
{},
|
||||
{start: 0, end: 10000}
|
||||
]);
|
||||
mockHandle.request.mostRecentCall.args[1](
|
||||
mockDomainObject,
|
||||
mockSeries
|
||||
);
|
||||
|
||||
// Pan-zoom state should reflect bounds set externally;
|
||||
// domain axis should not have shrunk to fit data.
|
||||
expect(
|
||||
controller.getSubPlots()[0].panZoomStack.getOrigin()[0]
|
||||
).toEqual(0);
|
||||
expect(
|
||||
controller.getSubPlots()[0].panZoomStack.getDimensions()[0]
|
||||
).toEqual(10000);
|
||||
});
|
||||
|
||||
it("provides classes for legends based on limit state", function () {
|
||||
var mockTelemetryObjects = mockHandle.getTelemetryObjects();
|
||||
|
||||
|
||||
@@ -32,16 +32,14 @@ define(
|
||||
var TEST_RANGE_VALUE = "some formatted range value";
|
||||
|
||||
describe("A range column", function () {
|
||||
var mockDataSet,
|
||||
var testDatum,
|
||||
testMetadata,
|
||||
mockFormatter,
|
||||
mockDomainObject,
|
||||
column;
|
||||
|
||||
beforeEach(function () {
|
||||
mockDataSet = jasmine.createSpyObj(
|
||||
"data",
|
||||
[ "getRangeValue" ]
|
||||
);
|
||||
testDatum = { testKey: 123, otherKey: 456 };
|
||||
mockFormatter = jasmine.createSpyObj(
|
||||
"formatter",
|
||||
[ "formatDomainValue", "formatRangeValue" ]
|
||||
@@ -50,6 +48,10 @@ define(
|
||||
key: "testKey",
|
||||
name: "Test Name"
|
||||
};
|
||||
mockDomainObject = jasmine.createSpyObj(
|
||||
"domainObject",
|
||||
[ "getModel", "getCapability" ]
|
||||
);
|
||||
mockFormatter.formatRangeValue.andReturn(TEST_RANGE_VALUE);
|
||||
|
||||
column = new RangeColumn(testMetadata, mockFormatter);
|
||||
@@ -59,20 +61,13 @@ define(
|
||||
expect(column.getTitle()).toEqual("Test Name");
|
||||
});
|
||||
|
||||
xit("looks up data from a data set", function () {
|
||||
column.getValue(undefined, mockDataSet, 42);
|
||||
expect(mockDataSet.getRangeValue)
|
||||
.toHaveBeenCalledWith(42, "testKey");
|
||||
});
|
||||
|
||||
xit("formats range values as numbers", function () {
|
||||
mockDataSet.getRangeValue.andReturn(123.45678);
|
||||
expect(column.getValue(undefined, mockDataSet, 42).text)
|
||||
it("formats range values as numbers", function () {
|
||||
expect(column.getValue(mockDomainObject, testDatum).text)
|
||||
.toEqual(TEST_RANGE_VALUE);
|
||||
|
||||
// Make sure that service interactions were as expected
|
||||
expect(mockFormatter.formatRangeValue)
|
||||
.toHaveBeenCalledWith(123.45678);
|
||||
.toHaveBeenCalledWith(testDatum.testKey);
|
||||
expect(mockFormatter.formatDomainValue)
|
||||
.not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user