Skip to content

Commit 7f28278

Browse files
authored
Merge pull request #48 from oslabs-beta/main
ReacType4.0
2 parents f6134c1 + 14b6db9 commit 7f28278

File tree

124 files changed

+3802
-590
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

124 files changed

+3802
-590
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- <p align="center">
1+
<p align="center">
22
<img width="50" src="url('./app/src/public/icons/png/256x256.png)">
33
<h1 align="center">ReacType </h1>
44
</p>
@@ -109,20 +109,26 @@ npm run dev
109109
- Please note that the development build is not connected to the production server. `npm run dev` should spin up the development server from the server folder of this repo. For additional information, the readme is [here](https://github.com/open-source-labs/ReacType/blob/master/server/README.md). Alternatively, you can also select "Continue as guest" on the log-in page of the app to not use any features that rely on the server (authentication and saving project data.)
110110

111111
## To Run Your Exported Next.js Project
112+
112113
- Open exported project directory
113114
- Install dependencies
114115

115116
```bash
116117
npm install
117118
```
119+
118120
- Build the app
121+
119122
```bash
120123
npm run build
121124
```
125+
122126
- Start an instance
127+
123128
```bash
124129
npm run start
125130
```
131+
126132
- Open browser and navigate to localhost at specified port
127133

128134
## License

__tests__/BottomTabs.test.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React, { useReducer} from 'react';
2+
import '@testing-library/jest-dom';
3+
import { render, fireEvent, cleanup, screen } from '@testing-library/react';
4+
5+
import BottomTabs from '../app/src/components/bottom/BottomTabs';
6+
import StateContext from '../app/src/context/context';
7+
import initialState from '../app/src/context/initialState';
8+
import reducer from '../app/src/reducers/componentReducer';
9+
10+
function Test() {
11+
const [state, dispatch] = useReducer(reducer, initialState);
12+
return (
13+
<StateContext.Provider value={[state, dispatch]} >
14+
<BottomTabs />
15+
</StateContext.Provider>
16+
)
17+
}
18+
19+
test('Bottom Panel Contains Two Tabs: Code Preview and Component Tree', () => {
20+
render(<Test/>);
21+
expect(screen.getAllByRole('tab')).toHaveLength(2);
22+
expect(screen.getByText('Code Preview')).toBeInTheDocument();
23+
expect(screen.getByText('Component Tree')).toBeInTheDocument();
24+
})

__tests__/HTMLPanel.test.tsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import React, { useReducer} from 'react';
2+
import '@testing-library/jest-dom';
3+
import { DndProvider } from 'react-dnd';
4+
import { HTML5Backend } from 'react-dnd-html5-backend';
5+
import { render, fireEvent, cleanup, screen } from '@testing-library/react';
6+
7+
import StateContext from '../app/src/context/context';
8+
import initialState from '../app/src/context/initialState';
9+
import reducer from '../app/src/reducers/componentReducer';
10+
import HTMLPanel from '../app/src/components/left/HTMLPanel';
11+
12+
13+
function Test() {
14+
const [state, dispatch] = useReducer(reducer, initialState);
15+
return (
16+
<DndProvider backend={HTML5Backend}>
17+
<StateContext.Provider value={[state, dispatch]} >
18+
<HTMLPanel />
19+
</StateContext.Provider>
20+
</DndProvider>
21+
)
22+
}
23+
24+
25+
test('Renders HTMLPanel component', () => {
26+
render(
27+
<Test/>
28+
);
29+
expect(screen.getAllByRole('textbox')).toHaveLength(2);
30+
expect(screen.getByText('Div')).toBeInTheDocument();
31+
expect(screen.getByText('Image')).toBeInTheDocument();
32+
expect(screen.getByText('Form')).toBeInTheDocument();
33+
expect(screen.getByText('List')).toBeInTheDocument();
34+
expect(screen.getByText('Button')).toBeInTheDocument();
35+
expect(screen.getByText('Link')).toBeInTheDocument();
36+
expect(screen.getByText('Paragraph')).toBeInTheDocument();
37+
expect(screen.getByText('Header 1')).toBeInTheDocument();
38+
expect(screen.getByText('Header 2')).toBeInTheDocument();
39+
expect(screen.getByText('Span')).toBeInTheDocument();
40+
})
41+
42+
test('Adds new custom element', () => {
43+
render(
44+
<Test/>
45+
);
46+
47+
fireEvent.change(screen.getAllByRole('textbox')[0], {
48+
target: { value: 'Testing' }
49+
});
50+
fireEvent.change(screen.getAllByRole('textbox')[1], {
51+
target: { value: 'Testing' }
52+
});
53+
54+
fireEvent.click(screen.getByDisplayValue('Add Element'));
55+
56+
expect(screen.getByText('Testing')).toBeInTheDocument();
57+
})
58+

0 commit comments

Comments
 (0)