Skip to content

Commit d5b13ef

Browse files
#TRAPWLS-19 test case updated
1 parent afe28f3 commit d5b13ef

File tree

3 files changed

+29
-13
lines changed

3 files changed

+29
-13
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"axios": "^1.7.7",
1111
"cors": "^2.8.5",
1212
"firebase": "^11.0.1",
13+
"jest": "^27.5.1",
1314
"jwt-decode": "^3.1.2",
1415
"nodemon": "^3.1.7",
1516
"react": "^18.2.0",

src/App.test.js

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
import { render, screen } from '@testing-library/react';
2-
import App from './App';
3-
import Demo from './Demo';
2+
import Popup from './popup/Popup';
3+
import { APP_INITIAL_POPUP_MSG } from './utility/constants';
44

5-
// test('renders learn react link', () => {
6-
// render(<App />);
7-
// const linkElement = screen.getByText(/learn react/i);
8-
// expect(linkElement).toBeInTheDocument();
9-
// });
5+
//clear local storage
6+
beforeEach(() => {
7+
localStorage.clear();
8+
});
109

11-
12-
// test('demo state test', () => {
13-
// render(<Demo />);
14-
// expect().toBeInTheDocument();
15-
// });
10+
describe('App component', () => {
11+
test('renders popup with image, message, and button', () => {
12+
const mockSetShowPopup = jest.fn(); //mock function
13+
14+
// Render the Popup component
15+
render(<Popup setShowPopup={mockSetShowPopup} />);
16+
17+
const popupImage = screen.getByRole('img');
18+
expect(popupImage).toBeInTheDocument();
19+
expect(popupImage).toHaveAttribute('src','favicon1.ico');
20+
21+
const message = screen.getByText(APP_INITIAL_POPUP_MSG);
22+
expect(message).toBeInTheDocument();
23+
24+
//check ok button
25+
const button = screen.getByRole('button',{name:/OK/i});
26+
expect(button).toBeInTheDocument();
27+
});
28+
})

src/utility/constants.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
export const LOGIN_TOAST_INFO = "Right now not implemented, check GoogleLogin";
1+
export const APP_NAME = "Javascript CRUD with SampleTasks";
2+
export const LOGIN_TOAST_INFO = "Right now not implemented, check GoogleLogin";
3+
export const APP_INITIAL_POPUP_MSG = "Here’s an important message for you!";

0 commit comments

Comments
 (0)