thresholdsStep.spec.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import ThresholdsStep, {ThresholdsConfig} from './thresholdsStep';
  3. const exampleThresholdsConfig: ThresholdsConfig = {
  4. max_values: {
  5. max_1: 100,
  6. max_2: 200,
  7. },
  8. unit: null,
  9. };
  10. describe('Widget Builder > ThresholdsStep', function () {
  11. it('renders thresholds step', function () {
  12. const onChange = jest.fn();
  13. render(
  14. <ThresholdsStep thresholdsConfig={exampleThresholdsConfig} onChange={onChange} />
  15. );
  16. expect(screen.getByText('Set thresholds')).toBeInTheDocument();
  17. // Check minimum value boxes are disabled
  18. expect(screen.getByLabelText('First Minimum')).toBeDisabled();
  19. expect(screen.getByLabelText('Second Minimum')).toBeDisabled();
  20. expect(screen.getByLabelText('Third Minimum')).toBeDisabled();
  21. // Check minimum values
  22. expect(screen.getByLabelText('First Minimum', {selector: 'input'})).toHaveValue(0);
  23. expect(screen.getByLabelText('Second Minimum', {selector: 'input'})).toHaveValue(100);
  24. expect(screen.getByLabelText('Third Minimum', {selector: 'input'})).toHaveValue(200);
  25. // Check max values
  26. expect(screen.getByLabelText('First Maximum', {selector: 'input'})).toHaveValue(100);
  27. expect(screen.getByLabelText('Second Maximum', {selector: 'input'})).toHaveValue(200);
  28. expect(screen.getByLabelText('Third Maximum', {selector: 'input'})).toHaveAttribute(
  29. 'placeholder',
  30. 'No max'
  31. );
  32. });
  33. });