[Telemetry] Add data structure specs

Add specs for data structures which will support resolution
of WTD-784 by retaining all data not yet received by callbacks
(instead of just the very latest) such that plots can ensure
they do not miss streaming data.
This commit is contained in:
Victor Woeltjen
2015-01-30 15:16:36 -08:00
parent 01d66bbf93
commit acf4261a08
6 changed files with 134 additions and 7 deletions

View File

@@ -0,0 +1,53 @@
/*global define,Promise,describe,it,expect,beforeEach,waitsFor,jasmine*/
define(
["../src/TelemetryTable"],
function (TelemetryTable) {
"use strict";
describe("The telemetry table", function () {
var queue;
beforeEach(function () {
// put, isEmpty, dequeue
queue = new TelemetryTable();
});
it("stores elements by key", function () {
queue.put("a", { someKey: "some value" });
expect(queue.poll())
.toEqual({ a: { someKey: "some value" }});
});
it("merges non-overlapping keys", function () {
queue.put("a", { someKey: "some value" });
queue.put("b", 42);
expect(queue.poll())
.toEqual({ a: { someKey: "some value" }, b: 42 });
});
it("overwrites repeated keys", function () {
queue.put("a", { someKey: "some value" });
queue.put("a", { someKey: "some other value" });
queue.put("b", 42);
expect(queue.poll())
.toEqual({ a: { someKey: "some other value" }, b: 42 });
expect(queue.poll())
.toBeUndefined();
});
it("reports emptiness", function () {
expect(queue.isEmpty()).toBeTruthy();
queue.put("a", { someKey: "some value" });
queue.put("a", { someKey: "some other value" });
queue.put("b", 42);
expect(queue.isEmpty()).toBeFalsy();
queue.poll();
expect(queue.isEmpty()).toBeTruthy();
});
});
}
);