withExperiment.spec.tsx 777 B

1234567891011121314151617181920212223242526
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import withExperiment from 'sentry/utils/withExperiment';
  4. describe('withConfig HoC', function () {
  5. beforeEach(function () {
  6. jest.clearAllMocks();
  7. });
  8. function MyComponent(props) {
  9. return <span>{props.experimentAssignment}</span>;
  10. }
  11. it('injects experiment assignment', function () {
  12. const Container = withExperiment(MyComponent, {
  13. // @ts-expect-error This is a test experiment that does not exist, it
  14. // will evalulate to -1 assignment
  15. experiment: 'orgExperiment',
  16. });
  17. render(<Container organization={OrganizationFixture()} />);
  18. expect(screen.getByText('-1')).toBeInTheDocument();
  19. });
  20. });