Skip to content

Commit

Permalink
fixing merging conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
izalu99 committed Apr 7, 2024
2 parents 0c1a70b + 821d95d commit b145141
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 28 deletions.
31 changes: 6 additions & 25 deletions __tests__/Students/SearchPage/search_page.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// test search page

import { render, screen, fireEvent, act, waitFor } from '@testing-library/react';
import { render, screen, fireEvent, act, waitFor } from '@testing-library/react';
import '@testing-library/jest-dom';
import Page from '../../../app/Students/page';
Expand Down Expand Up @@ -41,21 +42,8 @@ describe('Page component', () => {


//0. test that the page renders the heading: Student Search Page
test('renders Student Search Page', async() => {
test('renders Student Search Page', async() => {
render(<Page />);

// Wait for the "Loading..." text to disappear
await waitFor(() => {
expect(screen.queryByText('Loading...')).not.toBeInTheDocument();
});


// Wait for the "Loading..." text to disappear
await waitFor(() => {
expect(screen.queryByText('Loading...')).not.toBeInTheDocument();
});

const heading = screen.getByText(/Student Search Page/i);
expect(heading).toBeInTheDocument();

Expand Down Expand Up @@ -83,17 +71,9 @@ describe('Page component', () => {

// 2. test that the search bar allows input
test('allows input in the search bar', async() => {
const { getByPlaceholderText } = render(<Page />);

// Wait for the "Loading..." text to disappear
await waitFor(() => {
expect(screen.queryByText('Loading...')).not.toBeInTheDocument();
});


// Wait for the "Loading..." text to disappear
await waitFor(() => {
expect(screen.queryByText('Loading...')).not.toBeInTheDocument();
let component;
await act(async () => {
component = render(<Page />);
});

const searchBar = getByPlaceholderText("Search by name, class or student ID");
Expand All @@ -119,7 +99,8 @@ describe('Page component', () => {
await waitFor(() => {
expect(errorSpy).toHaveBeenCalledWith('Error fetching data:', 'Fetch error');
});


expect(errorSpy).toHaveBeenCalledWith('Error fetching data:', 'Fetch error');
});

});
3 changes: 0 additions & 3 deletions app/Students/[username]/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,14 @@ const StudentPage = ({ params }) => {

if (loading) {
return <div className="text-neutral">Loading...</div>;
return <div className="text-neutral">Loading...</div>;
}


if (error) {
return <div className="text-error">Error: {error.message}</div>;
return <div className="text-error">Error: {error.message}</div>;
}

return (
<div className="bg-primary p-4 rounded-md justify-between">
<div className="bg-primary p-4 rounded-md justify-between">
<h1
data-testid="student-name"
Expand Down

0 comments on commit b145141

Please sign in to comment.