changeARRAction.spec.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import {
  2. render,
  3. renderGlobalModal,
  4. screen,
  5. userEvent,
  6. } from 'sentry-test/reactTestingLibrary';
  7. import {textWithMarkupMatcher} from 'sentry-test/utils';
  8. import ChangeARRAction from 'admin/components/changeARRAction';
  9. describe('ChangeARRAction', function () {
  10. const onAction = jest.fn();
  11. it('renders empty', function () {
  12. render(<ChangeARRAction customer={{}} onAction={onAction} />);
  13. });
  14. it('renders default ACV value', async function () {
  15. render(<ChangeARRAction customer={{acv: 1000000}} onAction={onAction} />);
  16. await userEvent.click(screen.getByRole('button'));
  17. renderGlobalModal();
  18. expect(
  19. screen.getByText(
  20. textWithMarkupMatcher('Their new annual contract value will be $10,000')
  21. )
  22. ).toBeInTheDocument();
  23. });
  24. it('can change ACV value', async function () {
  25. render(<ChangeARRAction customer={{acv: 1000000}} onAction={onAction} />);
  26. await userEvent.click(screen.getByRole('button'));
  27. renderGlobalModal();
  28. await userEvent.type(screen.getByRole('spinbutton', {name: 'ARR'}), '15000');
  29. await userEvent.click(screen.getByRole('button', {name: 'Submit'}));
  30. expect(onAction).toHaveBeenCalledWith({customPrice: 1500000});
  31. });
  32. });