123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
- import AcceptProjectTransfer from 'sentry/views/acceptProjectTransfer';
- describe('AcceptProjectTransfer', function () {
- let getMock;
- let postMock;
- const endpoint = '/accept-transfer/';
- beforeEach(function () {
- MockApiClient.clearMockResponses();
- getMock = MockApiClient.addMockResponse({
- url: '/accept-transfer/',
- method: 'GET',
- body: {
- project: TestStubs.Project(),
- organizations: [TestStubs.Organization({teams: [TestStubs.Team()]})],
- },
- });
- postMock = MockApiClient.addMockResponse({
- url: '/accept-transfer/',
- method: 'POST',
- statusCode: 204,
- });
- });
- it('renders', function () {
- render(
- <AcceptProjectTransfer
- location={{
- pathname: 'endpoint',
- query: {data: 'XYZ'},
- }}
- />
- );
- expect(getMock).toHaveBeenCalled();
- });
- it('submits', async function () {
- render(
- <AcceptProjectTransfer
- location={{
- pathname: 'endpoint',
- query: {data: 'XYZ'},
- }}
- />
- );
- await userEvent.click(screen.getByRole('button', {name: 'Transfer Project'}));
- expect(postMock).toHaveBeenCalledWith(
- endpoint,
- expect.objectContaining({
- method: 'POST',
- })
- );
- });
- });
|