) => {
+ return Flag: {details.flagKey}, Value: {String(details.value)}, Reason: {details.reason}
;
+ });
+
+ render(
+
+
+
+
+ ,
+ );
+
+ expect(fallbackFunction).toHaveBeenCalledWith(expect.objectContaining({
+ flagKey: MISSING_FLAG_KEY,
+ value: false,
+ reason: expect.any(String)
+ }));
+ });
+
+ it('should support function-based fallback for error conditions', () => {
+ // Create a provider that will cause an error
+ const errorProvider = new InMemoryProvider({});
+ OpenFeature.setProvider('error-test', errorProvider);
+
+ const fallbackFunction = jest.fn((details: EvaluationDetails) => Error fallback: {details.reason}
);
+
+ render(
+
+
+
+
+ ,
+ );
+
+ expect(fallbackFunction).toHaveBeenCalled();
+ expect(screen.queryByText(childText)).not.toBeInTheDocument();
+ });
+
+ it('should render static fallback when fallback is not a function', () => {
+ render(
+
+ Static fallback}>
+
+
+ ,
+ );
+
+ expect(screen.queryByText('Static fallback')).toBeInTheDocument();
+ expect(screen.queryByText(childText)).not.toBeInTheDocument();
+ });
+ });
+});