Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vitest: fix several tests #666

Merged
merged 5 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions test/components/CivicProfileForms/FinancialInfo.test.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// import React from 'react';
// import { render } from '@testing-library/react';
// import { expect, it, describe } from 'vitest';
// import { FinancialInfo } from '@components/CivicProfileForms';
import { it, describe } from 'vitest';

// describe('Financial Info Form', () => {
// it('renders', () => {
// const { getByText } = render(<FinancialInfo />);
// expect(getByText('Financial Information')).not.toBeNull();
// });
// });
describe.todo('Financial Info Form', () => {
it('renders', () => {
// const { getByText } = render(<FinancialInfo />);
// expect(getByText('Financial Information')).not.toBeNull();
});
});
4 changes: 2 additions & 2 deletions test/components/Signup/PodRegistrationForm.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ describe('PodRegistrationForm', () => {
);

const textField = screen.getByRole('textbox', { name: 'Email' });
const inputElementPassword = screen.getByLabelText('Password');
const inputElementConfirmPassord = screen.getByLabelText('Confirm Password');
const inputElementPassword = screen.getByLabelText(/^password/i);
const inputElementConfirmPassord = screen.getByLabelText(/^confirm password/i);

expect(textField).not.toBeNull();
expect(inputElementPassword).not.toBeNull();
Expand Down
70 changes: 35 additions & 35 deletions test/pages/CivicProfile.test.jsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
// import React from 'react';
// import { BrowserRouter } from 'react-router-dom';
// import { render } from '@testing-library/react';
// import { describe, expect, it } from 'vitest';
// import { CivicProfile } from '@pages';
// import createMatchMedia from '../helpers/createMatchMedia';
import React from 'react';
import { BrowserRouter } from 'react-router-dom';
import { render } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import { CivicProfile } from '@pages';
import createMatchMedia from '../helpers/createMatchMedia';

// TODO: Rewrite tests to align with changes in CivicProfile component
// e.g. "successfully navigates to Basic Information"
// describe('CivicProfile Page', () => {
// it('renders page container flex direction as row and nav container width as 25% by default', () => {
// const component = render(
// <BrowserRouter>
// <CivicProfile />
// </BrowserRouter>
// );
// const componentContainer = component.container.firstChild;
// const navContainer = componentContainer.firstChild;
// const componentContainerStyles = getComputedStyle(componentContainer);
// const navContainerStyles = getComputedStyle(navContainer);
// expect(componentContainerStyles.flexDirection).toBe('row');
// expect(navContainerStyles.width).toBe('25%');
// });
// it('renders page container flex direction as column and nav container width as 100% below 600px', () => {
// window.matchMedia = createMatchMedia(599);
// const component = render(
// <BrowserRouter>
// <CivicProfile />
// </BrowserRouter>
// );
// const componentContainer = component.container.firstChild;
// const navContainer = componentContainer.firstChild;
// const componentContainerStyles = getComputedStyle(componentContainer);
// const navContainerStyles = getComputedStyle(navContainer);
// expect(componentContainerStyles.flexDirection).toBe('column');
// expect(navContainerStyles.width).toBe('100%');
// });
// });
describe.todo('CivicProfile Page', () => {
it('renders page container flex direction as row and nav container width as 25% by default', () => {
const component = render(
<BrowserRouter>
<CivicProfile />
</BrowserRouter>
);
const componentContainer = component.container.firstChild;
const navContainer = componentContainer.firstChild;
const componentContainerStyles = getComputedStyle(componentContainer);
const navContainerStyles = getComputedStyle(navContainer);
expect(componentContainerStyles.flexDirection).toBe('row');
expect(navContainerStyles.width).toBe('25%');
});
it('renders page container flex direction as column and nav container width as 100% below 600px', () => {
window.matchMedia = createMatchMedia(599);
const component = render(
<BrowserRouter>
<CivicProfile />
</BrowserRouter>
);
const componentContainer = component.container.firstChild;
const navContainer = componentContainer.firstChild;
const componentContainerStyles = getComputedStyle(componentContainer);
const navContainerStyles = getComputedStyle(navContainer);
expect(componentContainerStyles.flexDirection).toBe('column');
expect(navContainerStyles.width).toBe('100%');
});
});
4 changes: 2 additions & 2 deletions test/pages/PersonalProfile.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Civic Profile', () => {
<CivicProfile />
</BrowserRouter>
);
expect(getByRole('nav')).not.toBeNull();
expect(getAllByRole('link').length).toEqual(numLinks);
expect(getByRole('navigation')).not.toBeNull();
expect(getAllByRole('tab').length).toEqual(numLinks);
});
});
10 changes: 5 additions & 5 deletions test/pages/Signup.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('Signup Page', () => {
};
useNotification.mockReturnValue({ addNotification: vi.fn() });
const { getByRole } = render(<MockSignupContexts session={sessionObj} />);
expect(getByRole('heading', { name: 'Register For PASS' })).not.toBeNull();
expect(getByRole('heading', { name: 'Sign Up' })).not.toBeNull();
});
it('lets users request to create pods', async () => {
const session = {
Expand All @@ -102,8 +102,8 @@ describe('Signup Page', () => {
const password = 'password';
const confirmPassword = 'password';
const emailField = getByRole('textbox', { name: 'Email' });
const passwordField = getByLabelText('Password');
const confirmPasswordField = getByLabelText('Confirm Password');
const passwordField = getByLabelText(/^password/i);
const confirmPasswordField = getByLabelText(/^confirm password/i);
await user.type(emailField, email);
await user.type(passwordField, password);
await user.type(confirmPasswordField, confirmPassword);
Expand Down Expand Up @@ -135,8 +135,8 @@ describe('Signup Page', () => {
const password = 'password';
const confirmPassword = 'password';
const emailField = getByRole('textbox', { name: 'Email' });
const passwordField = getByLabelText('Password');
const confirmPasswordField = getByLabelText('Confirm Password');
const passwordField = getByLabelText(/^password/i);
const confirmPasswordField = getByLabelText(/^confirm password/i);

await user.type(emailField, email);
await user.type(passwordField, password);
Expand Down
Loading