apiTokenRow.spec.tsx 938 B

12345678910111213141516171819202122232425262728
  1. import {ApiTokenFixture} from 'sentry-fixture/apiToken';
  2. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  3. import ApiTokenRow from 'sentry/views/settings/account/apiTokenRow';
  4. describe('ApiTokenRow', () => {
  5. it('renders', () => {
  6. render(<ApiTokenRow onRemove={() => {}} token={ApiTokenFixture()} />);
  7. });
  8. it('calls onRemove callback when trash can is clicked', async () => {
  9. const cb = jest.fn();
  10. render(<ApiTokenRow onRemove={cb} token={ApiTokenFixture()} />);
  11. await userEvent.click(screen.getByLabelText('Remove'));
  12. expect(cb).toHaveBeenCalled();
  13. });
  14. it('uses NewTokenHandler when lastTokenCharacters field is found', () => {
  15. const token = ApiTokenFixture();
  16. token.tokenLastCharacters = 'a1b2c3d4';
  17. const cb = jest.fn();
  18. render(<ApiTokenRow onRemove={cb} token={token} />);
  19. expect(screen.queryByLabelText('Token preview')).toBeInTheDocument();
  20. });
  21. });