mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 05:07:52 +00:00
[Telemetry] Added unit tests for addition of bounds and domains to telemetry requests
This commit is contained in:
parent
da40f4c96e
commit
09419398e9
@ -140,7 +140,8 @@ define(
|
||||
typeRequest = (type && type.getDefinition().telemetry) || {},
|
||||
modelTelemetry = domainObject.getModel().telemetry,
|
||||
fullRequest = Object.create(typeRequest),
|
||||
bounds;
|
||||
bounds,
|
||||
timeSystem;
|
||||
|
||||
// Add properties from the telemetry field of this
|
||||
// specific domain object.
|
||||
@ -167,6 +168,13 @@ define(
|
||||
fullRequest.end = bounds.end;
|
||||
}
|
||||
|
||||
if (request.domain === undefined) {
|
||||
timeSystem = this.openmct.conductor.timeSystem();
|
||||
if (timeSystem !== undefined) {
|
||||
fullRequest.domain = timeSystem.metadata.key;
|
||||
}
|
||||
}
|
||||
|
||||
return fullRequest;
|
||||
};
|
||||
|
||||
|
@ -104,6 +104,13 @@ define(
|
||||
start: 0,
|
||||
end: 1
|
||||
};
|
||||
},
|
||||
timeSystem: function () {
|
||||
return {
|
||||
metadata: {
|
||||
key: 'mockTimeSystem'
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -141,7 +148,8 @@ define(
|
||||
id: "testId", // from domain object
|
||||
source: "testSource", // from model
|
||||
key: "testKey", // from model
|
||||
start: 42 // from argument
|
||||
start: 42, // from argument
|
||||
domain: 'mockTimeSystem'
|
||||
}]);
|
||||
});
|
||||
|
||||
@ -160,7 +168,8 @@ define(
|
||||
source: "testSource",
|
||||
key: "testKey",
|
||||
start: 0,
|
||||
end: 1
|
||||
end: 1,
|
||||
domain: 'mockTimeSystem'
|
||||
});
|
||||
});
|
||||
|
||||
@ -176,7 +185,8 @@ define(
|
||||
source: "testSource", // from model
|
||||
key: "testId", // from domain object
|
||||
start: 0,
|
||||
end: 1
|
||||
end: 1,
|
||||
domain: 'mockTimeSystem'
|
||||
});
|
||||
});
|
||||
|
||||
@ -257,7 +267,8 @@ define(
|
||||
source: "testSource",
|
||||
key: "testKey",
|
||||
start: 0,
|
||||
end: 1
|
||||
end: 1,
|
||||
domain: 'mockTimeSystem'
|
||||
}]
|
||||
);
|
||||
|
||||
@ -274,8 +285,28 @@ define(
|
||||
expect(mockUnsubscribe).not.toHaveBeenCalled();
|
||||
subscription(); // should be an unsubscribe function
|
||||
expect(mockUnsubscribe).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("applies time conductor bounds if request bounds not defined", function () {
|
||||
var fullRequest = telemetry.buildRequest({});
|
||||
var mockBounds = mockAPI.conductor.bounds();
|
||||
|
||||
expect(fullRequest.start).toBe(mockBounds.start);
|
||||
expect(fullRequest.end).toBe(mockBounds.end);
|
||||
|
||||
fullRequest = telemetry.buildRequest({start: 10, end: 20});
|
||||
|
||||
expect(fullRequest.start).toBe(10);
|
||||
expect(fullRequest.end).toBe(20);
|
||||
});
|
||||
|
||||
it("applies domain from time system if none defined", function () {
|
||||
var fullRequest = telemetry.buildRequest({});
|
||||
var mockTimeSystem = mockAPI.conductor.timeSystem();
|
||||
expect(fullRequest.domain).toBe(mockTimeSystem.metadata.key);
|
||||
|
||||
fullRequest = telemetry.buildRequest({domain: 'someOtherDomain'});
|
||||
expect(fullRequest.domain).toBe('someOtherDomain');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user