mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-09-29 22:34:33 +00:00
59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
import {ApiTokenFixture} from 'sentry-fixture/apiToken';
|
|
import {OrganizationFixture} from 'sentry-fixture/organization';
|
|
|
|
import {fireEvent, render, screen} from 'sentry-test/reactTestingLibrary';
|
|
|
|
import {ApiTokens} from 'sentry/views/settings/account/apiTokens';
|
|
|
|
const organization = OrganizationFixture();
|
|
|
|
describe('ApiTokens', function () {
|
|
beforeEach(function () {
|
|
MockApiClient.clearMockResponses();
|
|
});
|
|
|
|
it('renders empty result', function () {
|
|
MockApiClient.addMockResponse({
|
|
url: '/api-tokens/',
|
|
body: null,
|
|
});
|
|
|
|
render(<ApiTokens organization={organization} />);
|
|
});
|
|
|
|
it('renders with result', function () {
|
|
MockApiClient.addMockResponse({
|
|
url: '/api-tokens/',
|
|
body: [ApiTokenFixture()],
|
|
});
|
|
|
|
render(<ApiTokens organization={organization} />);
|
|
});
|
|
|
|
it('can delete token', function () {
|
|
MockApiClient.addMockResponse({
|
|
url: '/api-tokens/',
|
|
body: [ApiTokenFixture()],
|
|
});
|
|
|
|
const mock = MockApiClient.addMockResponse({
|
|
url: '/api-tokens/',
|
|
method: 'DELETE',
|
|
});
|
|
expect(mock).not.toHaveBeenCalled();
|
|
|
|
render(<ApiTokens organization={organization} />);
|
|
|
|
fireEvent.click(screen.getByLabelText('Remove'));
|
|
|
|
// Should be loading
|
|
expect(mock).toHaveBeenCalledTimes(1);
|
|
expect(mock).toHaveBeenCalledWith(
|
|
'/api-tokens/',
|
|
expect.objectContaining({
|
|
method: 'DELETE',
|
|
})
|
|
);
|
|
});
|
|
});
|