Browse Source

ref(ts): Convert loginForm.spec to tsx (#51944)

Evan Purkhiser 1 year ago
parent
commit
8e7ce5608d
1 changed files with 12 additions and 6 deletions
  1. 12 6
      static/app/views/auth/loginForm.spec.tsx

+ 12 - 6
static/app/views/auth/loginForm.spec.jsx → static/app/views/auth/loginForm.spec.tsx

@@ -12,7 +12,14 @@ async function doLogin() {
 }
 
 describe('LoginForm', function () {
-  const api = new MockApiClient();
+  const emptyAuthConfig = {
+    canRegister: false,
+    githubLoginLink: '',
+    googleLoginLink: '',
+    hasNewsletter: false,
+    serverHostname: '',
+    vstsLoginLink: '',
+  };
 
   it('handles errors', async function () {
     MockApiClient.addMockResponse({
@@ -25,8 +32,7 @@ describe('LoginForm', function () {
       },
     });
 
-    const authConfig = {};
-    render(<LoginForm api={api} authConfig={authConfig} />);
+    render(<LoginForm authConfig={emptyAuthConfig} />);
     await doLogin();
 
     expect(await screen.findByText('Bad username password')).toBeInTheDocument();
@@ -48,8 +54,7 @@ describe('LoginForm', function () {
       },
     });
 
-    const authConfig = {};
-    render(<LoginForm api={api} authConfig={authConfig} />);
+    render(<LoginForm authConfig={emptyAuthConfig} />);
     await doLogin();
 
     expect(mockRequest).toHaveBeenCalledWith(
@@ -65,11 +70,12 @@ describe('LoginForm', function () {
 
   it('renders login provider buttons', function () {
     const authConfig = {
+      ...emptyAuthConfig,
       vstsLoginLink: '/vstsLogin',
       githubLoginLink: '/githubLogin',
     };
 
-    render(<LoginForm api={api} authConfig={authConfig} />);
+    render(<LoginForm authConfig={authConfig} />);
 
     expect(screen.getByText('Sign in with GitHub')).toBeInTheDocument();
     expect(screen.getByText('Sign in with Azure DevOps')).toBeInTheDocument();