Skip to content

Commit 1e7ae38

Browse files
jasnoominzo-kim
andcommitted
ErrorMessage.test.tsx file updated
Co-authored-by: minzo-kim <[email protected]>
1 parent 05ab071 commit 1e7ae38

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

src/app/__tests__jn/ErrorMsg.test.tsx

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import React from 'react';
2+
import { render, screen } from '@testing-library/react';
3+
import '@testing-library/jest-dom/extend-expect'; // needed this to extend the jest-dom assertions (ex toHaveTextContent)
4+
import ErrorMsg from '../components/ErrorMsg';
5+
6+
const props = {
7+
loadingArray: [false],
8+
status: {
9+
contentScriptLaunched: true,
10+
reactDevToolsInstalled: true,
11+
targetPageisaReactApp: true,
12+
},
13+
launchContent: null,
14+
};
15+
16+
const parseError = jest.fn();
17+
18+
describe('unit testing for ErrorContainer.tsx', () => {
19+
describe("when there's a RDT Error", () => {
20+
test('RDT error related text shows', () => {
21+
props.status.reactDevToolsInstalled = false;
22+
render(<ErrorMsg {...props} />);
23+
expect(
24+
screen.getByText('React Dev Tools isnt installed!', { exact: false }),
25+
).toBeInTheDocument();
26+
props.status.reactDevToolsInstalled = true;
27+
});
28+
});
29+
30+
describe("when there's a Content Script Errorr", () => {
31+
test('Content Script Error related text shows', () => {
32+
props.status.contentScriptLaunched = false;
33+
render(<ErrorMsg {...props} />);
34+
expect(
35+
screen.getByText(
36+
'Could not connect to the Target App. Try closing Reactime and reloading the page.',
37+
{ exact: false },
38+
),
39+
).toBeInTheDocument();
40+
expect(
41+
screen.getByText(
42+
'NOTE: By default Reactime only launches the content script on URLS starting with localhost.',
43+
{ exact: false },
44+
),
45+
).toBeInTheDocument();
46+
expect(
47+
screen.getByText(
48+
'If your target URL does not match, you can manually launch the content script below.',
49+
{ exact: false },
50+
),
51+
).toBeInTheDocument();
52+
});
53+
54+
test('launch button shows', () => {
55+
render(<ErrorMsg {...props} />);
56+
expect(screen.getByRole('button')).toBeInTheDocument();
57+
props.status.contentScriptLaunched = true;
58+
});
59+
});
60+
61+
describe("when there's a Not React Error", () => {
62+
test('Not React App text shows', () => {
63+
props.status.targetPageisaReactApp = false;
64+
render(<ErrorMsg {...props} />);
65+
expect(
66+
screen.getByText(
67+
'The Target app is either not a React application or is not compatible with Reactime',
68+
{ exact: false },
69+
),
70+
).toBeInTheDocument();
71+
props.status.targetPageisaReactApp = true;
72+
});
73+
});
74+
});

0 commit comments

Comments
 (0)