mirror of
https://github.com/nasa/openmct.git
synced 2025-04-13 14:13:07 +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:
parent
360c3fcf15
commit
befbcab892
@ -34,6 +34,7 @@ define(
|
||||
mockTelemetry,
|
||||
mockMutation,
|
||||
mockUnsubscribe,
|
||||
mockUnlisten,
|
||||
mockSeries,
|
||||
testMetadata,
|
||||
subscription;
|
||||
@ -65,6 +66,7 @@ define(
|
||||
["mutate", "listen"]
|
||||
);
|
||||
mockUnsubscribe = jasmine.createSpy("unsubscribe");
|
||||
mockUnlisten = jasmine.createSpy("unlisten");
|
||||
mockSeries = jasmine.createSpyObj(
|
||||
"series",
|
||||
[ "getPointCount", "getDomainValue", "getRangeValue" ]
|
||||
@ -84,6 +86,8 @@ define(
|
||||
mockTelemetry.subscribe.andReturn(mockUnsubscribe);
|
||||
mockTelemetry.getMetadata.andReturn(testMetadata);
|
||||
|
||||
mockMutation.listen.andReturn(mockUnlisten);
|
||||
|
||||
mockSeries.getPointCount.andReturn(42);
|
||||
mockSeries.getDomainValue.andReturn(123456);
|
||||
mockSeries.getRangeValue.andReturn(789);
|
||||
@ -223,6 +227,22 @@ define(
|
||||
expect(mockCallback2)
|
||||
.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();
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user