mirror of
https://github.com/nasa/openmct.git
synced 2025-05-09 20:12:50 +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) || {},
|
typeRequest = (type && type.getDefinition().telemetry) || {},
|
||||||
modelTelemetry = domainObject.getModel().telemetry,
|
modelTelemetry = domainObject.getModel().telemetry,
|
||||||
fullRequest = Object.create(typeRequest),
|
fullRequest = Object.create(typeRequest),
|
||||||
bounds;
|
bounds,
|
||||||
|
timeSystem;
|
||||||
|
|
||||||
// Add properties from the telemetry field of this
|
// Add properties from the telemetry field of this
|
||||||
// specific domain object.
|
// specific domain object.
|
||||||
@ -167,6 +168,13 @@ define(
|
|||||||
fullRequest.end = bounds.end;
|
fullRequest.end = bounds.end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (request.domain === undefined) {
|
||||||
|
timeSystem = this.openmct.conductor.timeSystem();
|
||||||
|
if (timeSystem !== undefined) {
|
||||||
|
fullRequest.domain = timeSystem.metadata.key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return fullRequest;
|
return fullRequest;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -104,6 +104,13 @@ define(
|
|||||||
start: 0,
|
start: 0,
|
||||||
end: 1
|
end: 1
|
||||||
};
|
};
|
||||||
|
},
|
||||||
|
timeSystem: function () {
|
||||||
|
return {
|
||||||
|
metadata: {
|
||||||
|
key: 'mockTimeSystem'
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -141,7 +148,8 @@ define(
|
|||||||
id: "testId", // from domain object
|
id: "testId", // from domain object
|
||||||
source: "testSource", // from model
|
source: "testSource", // from model
|
||||||
key: "testKey", // from model
|
key: "testKey", // from model
|
||||||
start: 42 // from argument
|
start: 42, // from argument
|
||||||
|
domain: 'mockTimeSystem'
|
||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -160,7 +168,8 @@ define(
|
|||||||
source: "testSource",
|
source: "testSource",
|
||||||
key: "testKey",
|
key: "testKey",
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 1
|
end: 1,
|
||||||
|
domain: 'mockTimeSystem'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -176,7 +185,8 @@ define(
|
|||||||
source: "testSource", // from model
|
source: "testSource", // from model
|
||||||
key: "testId", // from domain object
|
key: "testId", // from domain object
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 1
|
end: 1,
|
||||||
|
domain: 'mockTimeSystem'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -257,7 +267,8 @@ define(
|
|||||||
source: "testSource",
|
source: "testSource",
|
||||||
key: "testKey",
|
key: "testKey",
|
||||||
start: 0,
|
start: 0,
|
||||||
end: 1
|
end: 1,
|
||||||
|
domain: 'mockTimeSystem'
|
||||||
}]
|
}]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -274,8 +285,28 @@ define(
|
|||||||
expect(mockUnsubscribe).not.toHaveBeenCalled();
|
expect(mockUnsubscribe).not.toHaveBeenCalled();
|
||||||
subscription(); // should be an unsubscribe function
|
subscription(); // should be an unsubscribe function
|
||||||
expect(mockUnsubscribe).toHaveBeenCalled();
|
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…
x
Reference in New Issue
Block a user