Skip to content

Commit aeafca8

Browse files
author
Jeffrey Na
committed
attempted to fix SignUp
1 parent dd6b389 commit aeafca8

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

__tests__/components/SignUp.test.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { render, fireEvent, screen } from '@testing-library/react';
2+
import { render, fireEvent, screen, getByPlaceholderText } from '@testing-library/react';
33
import { ipcRenderer } from 'electron';
44
import SignUp from '../../app/components/SignUp';
55
import DashboardContextProvider from '../../app/context/DashboardContext';
@@ -31,14 +31,18 @@ describe('Create Admin Page', () => {
3131
expect(element.querySelectorAll('input').length).toBe(4);
3232
});
3333

34-
it('Sign up button should submit email, username, and password to addUser', () => {
35-
const element = screen.getByTestId('SignUp');
36-
const inputs = element.querySelectorAll('input');
37-
inputs[0].value = 'me';
38-
inputs[1].value = '[email protected]';
39-
inputs[2].value = 'me123';
40-
fireEvent.click(element);
41-
expect(ipcRenderer.sendSync).toHaveBeenCalledTimes(1);
34+
it('Sign up button should submit email, username, and password to addUser', async () => {
35+
screen.debug();
36+
37+
const username = screen.getByPlaceholderText('enter username');
38+
const email = screen.getByPlaceholderText('[email protected]');
39+
const password = screen.getByPlaceholderText('enter password');
40+
const signupButton = screen.getByRole('signup');
41+
fireEvent.change(email, { target: { value: '[email protected]' } });
42+
fireEvent.change(username, { target: { value: 'me' } });
43+
fireEvent.change(password, { target: { value: 'me123' } });
44+
fireEvent.click(signupButton);
45+
await expect(ipcRenderer.sendSync).toHaveBeenCalledTimes(1);
4246
// expect(ipcRenderer.sendSync).toHaveBeenCalledWith('addUser', {
4347
// username: 'me',
4448
// email: '[email protected]',
@@ -68,4 +72,4 @@ describe('Create Admin Page', () => {
6872
// fireEvent.submit(element);
6973
// expect(screen.getByText('Entered passwords do not match')).toBeInTheDocument();
7074
// })
71-
// })
75+
// })

0 commit comments

Comments
 (0)