mirror of
https://github.com/nasa/openmct.git
synced 2025-01-30 08:04:03 +00:00
[Table] Retain rows in scope (#1813)
* [Table] Push rows in as they are added ...such that sorting does not cause real-time table rows to be lost. Fixes #1738 * [Table] Test adding rows * [Table] Fix code style in test https://github.com/nasa/openmct/pull/1813#pullrequestreview-78277635
This commit is contained in:
parent
06e93ff520
commit
6bbdfcdfbe
@ -170,6 +170,9 @@ define(
|
|||||||
* @param rows
|
* @param rows
|
||||||
*/
|
*/
|
||||||
TelemetryTableController.prototype.addRowsToTable = function (rows) {
|
TelemetryTableController.prototype.addRowsToTable = function (rows) {
|
||||||
|
rows.forEach(function (row) {
|
||||||
|
this.$scope.rows.push(row);
|
||||||
|
}, this);
|
||||||
this.$scope.$broadcast('add:rows', rows);
|
this.$scope.$broadcast('add:rows', rows);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -436,5 +436,28 @@ define(
|
|||||||
expect(mockScope.$broadcast).toHaveBeenCalledWith("remove:rows", discardedRows);
|
expect(mockScope.$broadcast).toHaveBeenCalledWith("remove:rows", discardedRows);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when telemetry is added', function () {
|
||||||
|
var testRows;
|
||||||
|
var expectedRows;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
testRows = [{ a: 0 }, { a: 1 }, { a: 2 }];
|
||||||
|
mockScope.rows = [{ a: -1 }];
|
||||||
|
expectedRows = mockScope.rows.concat(testRows);
|
||||||
|
|
||||||
|
spyOn(controller.telemetry, "on").andCallThrough();
|
||||||
|
controller.registerChangeListeners();
|
||||||
|
|
||||||
|
controller.telemetry.on.calls.forEach(function (call) {
|
||||||
|
if (call.args[0] === 'added') {
|
||||||
|
call.args[1](testRows);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it("adds it to rows in scope", function () {
|
||||||
|
expect(mockScope.rows).toEqual(expectedRows);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user