Added mutation listener

This commit is contained in:
Henry
2016-03-30 14:25:53 -07:00
parent a4b79cdb5b
commit 0c00061cbc
6 changed files with 164 additions and 79 deletions

View File

@ -89,16 +89,19 @@ define(
mockDomainObject= jasmine.createSpyObj('domainObject', [
'getCapability',
'hasCapability',
'useCapability',
'getModel'
]);
mockDomainObject.getModel.andReturn({});
mockDomainObject.hasCapability.andReturn(true);
mockDomainObject.getCapability.andReturn(
{
getMetadata: function (){
return {ranges: [{format: 'string'}]};
}
});
mockDomainObject.useCapability.andReturn(promise([]));
mockScope.domainObject = mockDomainObject;
@ -125,6 +128,8 @@ define(
controller = new TableController(mockScope, mockTelemetryHandler, mockTelemetryFormatter);
controller.table = mockTable;
controller.handle = mockTelemetryHandle;
spyOn(controller, 'updateRealtime');
controller.updateRealtime.andCallThrough();
});
it('registers for streaming telemetry', function () {
@ -132,14 +137,16 @@ define(
expect(mockTelemetryHandler.handle).toHaveBeenCalledWith(jasmine.any(Object), jasmine.any(Function), true);
});
describe('receives new telemetry', function () {
describe('when receiving new telemetry', function () {
beforeEach(function() {
controller.subscribe();
mockScope.rows = [];
mockTable.columns = ['a', 'b'];
});
it('updates table with new streaming telemetry', function () {
mockTelemetryHandler.handle.mostRecentCall.args[1]();
expect(controller.updateRealtime).toHaveBeenCalled();
expect(mockScope.$broadcast).toHaveBeenCalledWith('add:row', 0);
});
it('observes the row limit', function () {