Skip to content

Commit 5bb234d

Browse files
authored
chore(util-endpoints): return undefined when value absent in referenceRecord (#3930)
1 parent 2561f60 commit 5bb234d

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

packages/util-endpoints/src/utils/getReferenceValue.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ describe(getReferenceValue.name, () => {
2222
});
2323
});
2424

25-
it("throws error if reference does not exist", () => {
26-
expect(() => getReferenceValue({ ref: mockRefName }, mockOptions)).toThrowError(
27-
new EndpointError(`Reference '${mockRefName}' not defined`)
28-
);
25+
it("returns undefined if reference does not exist", () => {
26+
expect(getReferenceValue({ ref: mockRefName }, mockOptions)).toBeUndefined();
2927
});
3028
});
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import { EndpointError, EvaluateOptions, ReferenceObject } from "../types";
1+
import { EvaluateOptions, ReferenceObject } from "../types";
22

33
export const getReferenceValue = ({ ref }: ReferenceObject, options: EvaluateOptions) => {
44
const referenceRecord = {
55
...options.endpointParams,
66
...options.referenceRecord,
77
};
8-
if (referenceRecord[ref] == undefined) {
9-
throw new EndpointError(`Reference '${ref}' not defined`);
10-
}
118
return referenceRecord[ref];
129
};

0 commit comments

Comments
 (0)