Skip to content

Commit

Permalink
test: attempt to find a reason of freezing test #4
Browse files Browse the repository at this point in the history
  • Loading branch information
Tedzury committed Dec 26, 2023
1 parent 252a0bb commit 4eaef65
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 26 deletions.
55 changes: 29 additions & 26 deletions src/test/docsComponent/DocsComp.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { act, fireEvent, render, screen, waitForElementToBeRemoved } from '@testing-library/react';
// import { act, fireEvent, render, screen, waitForElementToBeRemoved } from '@testing-library/react';
import { describe, expect, it } from 'vitest';

import App from '@/app/App';
// import App from '@/app/App';

describe('Testing for docs component', () => {
// it('Should render docs components after clicking on show docs btn', async () => {
Expand All @@ -19,30 +19,30 @@ describe('Testing for docs component', () => {
// await screen.findByText('A GraphQL schema provides a root type for each kind of operation.'),
// ).toBeInTheDocument();
// });
it('Should close docs section after clicking on overlay', async () => {
render(<App />);
const showDocsBtn = screen.getByText('show docs');
expect(screen.queryByTestId('overlay')).toBeNull();
expect(screen.queryByText('Docs')).toBeNull();
expect(screen.queryByText('A GraphQL schema provides a root type for each kind of operation')).toBeNull();
await act(async () => {
fireEvent.click(showDocsBtn);
});
const overlay = await screen.findByTestId('overlay');
expect(overlay).toBeInTheDocument();
expect(await screen.findByText('Docs')).toBeInTheDocument();
expect(
await screen.findByText('A GraphQL schema provides a root type for each kind of operation.'),
).toBeInTheDocument();
await act(async () => {
fireEvent.click(overlay);
});
waitForElementToBeRemoved(() => {
expect(overlay).toBeNull();
expect(screen.queryByText('Docs')).toBeNull();
expect(screen.queryByText('A GraphQL schema provides a root type for each kind of operation.')).toBeNull();
}).catch(() => {});
});
// it('Should close docs section after clicking on overlay', async () => {
// render(<App />);
// const showDocsBtn = screen.getByText('show docs');
// expect(screen.queryByTestId('overlay')).toBeNull();
// expect(screen.queryByText('Docs')).toBeNull();
// expect(screen.queryByText('A GraphQL schema provides a root type for each kind of operation')).toBeNull();
// await act(async () => {
// fireEvent.click(showDocsBtn);
// });
// const overlay = await screen.findByTestId('overlay');
// expect(overlay).toBeInTheDocument();
// expect(await screen.findByText('Docs')).toBeInTheDocument();
// expect(
// await screen.findByText('A GraphQL schema provides a root type for each kind of operation.'),
// ).toBeInTheDocument();
// await act(async () => {
// fireEvent.click(overlay);
// });
// waitForElementToBeRemoved(() => {
// expect(overlay).toBeNull();
// expect(screen.queryByText('Docs')).toBeNull();
// expect(screen.queryByText('A GraphQL schema provides a root type for each kind of operation.')).toBeNull();
// }).catch(() => {});
// });
// it('Should close docs section after clicking on close docs button', async () => {
// render(<App />);
// const showDocsBtn = screen.getByText('show docs');
Expand Down Expand Up @@ -132,4 +132,7 @@ describe('Testing for docs component', () => {
// await screen.findByText('A GraphQL schema provides a root type for each kind of operation.'),
// ).toBeInTheDocument();
// });
it('fake', () => {
expect(1).toBe(1);
});
});
34 changes: 34 additions & 0 deletions src/test/docsComponent/SomeCompletelyDiffFile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { act, fireEvent, render, screen, waitForElementToBeRemoved } from '@testing-library/react';
import { describe, expect, it } from 'vitest';

import App from '@/app/App';

describe('Testing for docs component', () => {
it('Should close docs section after clicking on overlay', async () => {
render(<App />);
const showDocsBtn = screen.getByText('show docs');
expect(screen.queryByTestId('overlay')).toBeNull();
expect(screen.queryByText('Docs')).toBeNull();
expect(screen.queryByText('A GraphQL schema provides a root type for each kind of operation')).toBeNull();
await act(async () => {
fireEvent.click(showDocsBtn);
});
const overlay = await screen.findByTestId('overlay');
expect(overlay).toBeInTheDocument();
expect(await screen.findByText('Docs')).toBeInTheDocument();
expect(
await screen.findByText('A GraphQL schema provides a root type for each kind of operation.'),
).toBeInTheDocument();
await act(async () => {
fireEvent.click(overlay);
});
waitForElementToBeRemoved(() => {
expect(overlay).toBeNull();
expect(screen.queryByText('Docs')).toBeNull();
expect(screen.queryByText('A GraphQL schema provides a root type for each kind of operation.')).toBeNull();
}).catch(() => {});
});
it('fake', () => {
expect(1).toBe(1);
});
});

0 comments on commit 4eaef65

Please sign in to comment.