mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 15:18:12 +00:00
[Telmetry] Add test cases
Add test cases for TelemetrySubscription related to listening for mutation, to support views of domain objects which delegate telemetry, for WTD-1329.
This commit is contained in:
@ -34,6 +34,7 @@ define(
|
|||||||
mockTelemetry,
|
mockTelemetry,
|
||||||
mockMutation,
|
mockMutation,
|
||||||
mockUnsubscribe,
|
mockUnsubscribe,
|
||||||
|
mockUnlisten,
|
||||||
mockSeries,
|
mockSeries,
|
||||||
testMetadata,
|
testMetadata,
|
||||||
subscription;
|
subscription;
|
||||||
@ -65,6 +66,7 @@ define(
|
|||||||
["mutate", "listen"]
|
["mutate", "listen"]
|
||||||
);
|
);
|
||||||
mockUnsubscribe = jasmine.createSpy("unsubscribe");
|
mockUnsubscribe = jasmine.createSpy("unsubscribe");
|
||||||
|
mockUnlisten = jasmine.createSpy("unlisten");
|
||||||
mockSeries = jasmine.createSpyObj(
|
mockSeries = jasmine.createSpyObj(
|
||||||
"series",
|
"series",
|
||||||
[ "getPointCount", "getDomainValue", "getRangeValue" ]
|
[ "getPointCount", "getDomainValue", "getRangeValue" ]
|
||||||
@ -84,6 +86,8 @@ define(
|
|||||||
mockTelemetry.subscribe.andReturn(mockUnsubscribe);
|
mockTelemetry.subscribe.andReturn(mockUnsubscribe);
|
||||||
mockTelemetry.getMetadata.andReturn(testMetadata);
|
mockTelemetry.getMetadata.andReturn(testMetadata);
|
||||||
|
|
||||||
|
mockMutation.listen.andReturn(mockUnlisten);
|
||||||
|
|
||||||
mockSeries.getPointCount.andReturn(42);
|
mockSeries.getPointCount.andReturn(42);
|
||||||
mockSeries.getDomainValue.andReturn(123456);
|
mockSeries.getDomainValue.andReturn(123456);
|
||||||
mockSeries.getRangeValue.andReturn(789);
|
mockSeries.getRangeValue.andReturn(789);
|
||||||
@ -223,6 +227,22 @@ define(
|
|||||||
expect(mockCallback2)
|
expect(mockCallback2)
|
||||||
.toHaveBeenCalledWith([ mockDomainObject ]);
|
.toHaveBeenCalledWith([ mockDomainObject ]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("reinitializes on mutation", function () {
|
||||||
|
expect(mockTelemetry.subscribe.calls.length).toEqual(1);
|
||||||
|
// Notify of a mutation which appears to change composition
|
||||||
|
mockMutation.listen.mostRecentCall.args[0]({
|
||||||
|
composition: ['Z']
|
||||||
|
});
|
||||||
|
// Use subscribe call as an indication of reinitialization
|
||||||
|
expect(mockTelemetry.subscribe.calls.length).toEqual(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("stops listening for mutation on unsubscribe", function () {
|
||||||
|
expect(mockUnlisten).not.toHaveBeenCalled();
|
||||||
|
subscription.unsubscribe();
|
||||||
|
expect(mockUnlisten).toHaveBeenCalled();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user