test: tidy up test (#670)

This commit is contained in:
Dexter Edwards 2022-06-29 16:45:03 +01:00 committed by GitHub
parent 913703e2d8
commit bd18759e5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,6 +33,8 @@ beforeEach(() => {
}; };
}); });
const DEFAULT_URL = 'http://localhost:1789/api/v1';
function generateJSX( function generateJSX(
props?: Partial<VegaConnectDialogProps>, props?: Partial<VegaConnectDialogProps>,
contextValue?: Partial<VegaWalletContextShape> contextValue?: Partial<VegaWalletContextShape>
@ -92,7 +94,7 @@ it('Successful connection using rest auth form', async () => {
fireEvent.submit(screen.getByTestId('rest-connector-form')); fireEvent.submit(screen.getByTestId('rest-connector-form'));
}); });
expect(spy).toHaveBeenCalledWith('http://localhost:1789/api/v1', fields); expect(spy).toHaveBeenCalledWith(DEFAULT_URL, fields);
expect(defaultProps.setDialogOpen).toHaveBeenCalledWith(false); expect(defaultProps.setDialogOpen).toHaveBeenCalledWith(false);
}); });
@ -150,7 +152,7 @@ it('Unsuccessful connection using rest auth form', async () => {
fireEvent.submit(screen.getByTestId('rest-connector-form')); fireEvent.submit(screen.getByTestId('rest-connector-form'));
}); });
expect(spy).toHaveBeenCalledWith('http://localhost:1789/api/v1', fields); expect(spy).toHaveBeenCalledWith(DEFAULT_URL, fields);
expect(screen.getByTestId('form-error')).toHaveTextContent( expect(screen.getByTestId('form-error')).toHaveTextContent(
'Something went wrong' 'Something went wrong'
@ -168,7 +170,7 @@ it('Unsuccessful connection using rest auth form', async () => {
}); });
expect(screen.getByTestId('form-error')).toHaveTextContent( expect(screen.getByTestId('form-error')).toHaveTextContent(
'Wallet not running at http://localhost:1789/api/v1' `Wallet not running at ${DEFAULT_URL}`
); );
// Reject eg non 200 results // Reject eg non 200 results