Skip to content

Commit ec14d15

Browse files
atvanekrachelk585MatteoDitersophia-bui
committed
Added two edge case test in componentPanel
Co-authored-by: rachelk585 <[email protected]> Co-authored-by: Matteo <[email protected]> Co-authored-by: Sophia Bui <[email protected]>
1 parent 1e45fe9 commit ec14d15

File tree

3 files changed

+143
-92
lines changed

3 files changed

+143
-92
lines changed

__tests__/BottomTabs.test.tsx

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React from 'react';
22
import { Provider } from 'react-redux';
33
import '@testing-library/jest-dom';
4-
import { render, screen } from '@testing-library/react';
4+
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
55
import BottomTabs from '../app/src/components/bottom/BottomTabs';
66
import store from '../app/src/redux/store';
7+
import ComponentPanel from '../app/src/components/right/ComponentPanel';
78

89
test('Bottom Panel Contains All Seven Tabs', () => {
910
render(
@@ -20,3 +21,52 @@ test('Bottom Panel Contains All Seven Tabs', () => {
2021
expect(screen.getByText('Context Manager')).toBeInTheDocument();
2122
expect(screen.getByText('State Manager')).toBeInTheDocument();
2223
});
24+
25+
test('empty name field for new component', async () => {
26+
render(
27+
<Provider store={store}>
28+
<ComponentPanel isThemeLight={null} />
29+
</Provider>
30+
);
31+
32+
fireEvent.click(screen.getByText('Create'), {
33+
target: {
34+
value: 'fasdfasd'
35+
}
36+
});
37+
38+
expect(screen.getByText('New Component')).toBeInTheDocument();
39+
40+
await waitFor(() => {
41+
expect(
42+
screen.getByText('Component name must start with a letter.')
43+
).toBeInTheDocument();
44+
});
45+
});
46+
47+
test('symbols in name of new component', async () => {
48+
render(
49+
<Provider store={store}>
50+
<ComponentPanel isThemeLight={null} />
51+
</Provider>
52+
);
53+
54+
fireEvent.change(screen.getByLabelText('Name:'), {
55+
target: {
56+
value: '!@#'
57+
}
58+
});
59+
60+
fireEvent.click(screen.getByText('Create'));
61+
62+
await waitFor(() => {
63+
expect(
64+
screen.getByText('Component name must start with a letter.')
65+
).toBeInTheDocument();
66+
});
67+
});
68+
//test for edge cases
69+
//trigger an event for each input
70+
//value being empty string
71+
//grab error message
72+
//check if it matches what is expected

__tests__/HTMLPanel.test.tsx

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)