All files / libs/amalia-lang/formula/components/src/test-utils FormulaBuilderContextProviderTest.tsx

100% Statements 44/44
100% Branches 5/5
0% Functions 0/1
100% Lines 44/44

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 451x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 65x 1x  
import { noop } from 'lodash-es';
import { memo, type ReactElement } from 'react';
 
import { type CustomObjectDefinition } from '@amalia/data-capture/record-models/types';
 
import {
  FormulaBuilderContext,
  type FormulaBuilderContextValue,
} from '../lib/components/formula-builder/FormulaBuilder.context';
 
export const FormulaBuilderContextProviderTest = memo(function FormulaBuilderContextProviderTest({
  children,
  value,
}: {
  readonly children: ReactElement;
  readonly value?: Partial<FormulaBuilderContextValue>;
}) {
  return (
    <FormulaBuilderContext.Provider
      value={{
        designerLibrary: {
          OBJECT_DEFINITIONS: [],
          VIRTUAL_OBJECT_DEFINITIONS: [],
          FIELD: [],
          QUOTA: [],
          VARIABLE: [],
          LINK: [],
          FILTER: [],
          FUNCTION: [],
          RULE: [],
        },
        customObjectDefinition: { machineName: 'opportunity', properties: {} } as CustomObjectDefinition,
        setActiveConditionId: noop,
        portalElement: value?.portalElement ?? null,
        activeConditionId: value?.activeConditionId ?? null,
        onOpenToken: () => Promise.resolve(),
        errors: value?.errors ?? {},
        ...value,
      }}
    >
      {children}
    </FormulaBuilderContext.Provider>
  );
});