mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 07:08:12 +00:00
[Capabilities] Avoid erroneous logging
Fix logic error which caused an inaccurate warning to be logged when capabilities are overridden by priority. Addresses #49.
This commit is contained in:
@ -67,8 +67,9 @@ define(
|
|||||||
function packageCapabilities(capabilities) {
|
function packageCapabilities(capabilities) {
|
||||||
var result = {};
|
var result = {};
|
||||||
capabilities.forEach(function (capability) {
|
capabilities.forEach(function (capability) {
|
||||||
if (capability.key && !result[capability.key]) {
|
if (capability.key) {
|
||||||
result[capability.key] = capability;
|
result[capability.key] =
|
||||||
|
result[capability.key] || capability;
|
||||||
} else {
|
} else {
|
||||||
$log.warn("No key defined for capability; skipping.");
|
$log.warn("No key defined for capability; skipping.");
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,19 @@ define(
|
|||||||
expect(mockLog.warn).not.toHaveBeenCalled();
|
expect(mockLog.warn).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("prefers higher-priority capability", function () {
|
||||||
|
KeylessCapability.key = BasicCapability.key;
|
||||||
|
expect(provider.getCapabilities({}).basic)
|
||||||
|
.toEqual(BasicCapability);
|
||||||
|
});
|
||||||
|
|
||||||
|
// https://github.com/nasa/openmctweb/issues/49
|
||||||
|
it("does not log a warning for multiple capabilities with the same key", function () {
|
||||||
|
KeylessCapability.key = BasicCapability.key;
|
||||||
|
provider.getCapabilities({});
|
||||||
|
expect(mockLog.warn).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user