Skip to content

Commit fbda3db

Browse files
committed
PR fixes
1 parent 9581dfb commit fbda3db

File tree

8 files changed

+15
-45
lines changed

8 files changed

+15
-45
lines changed

front/config/test/jest.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,5 @@ module.exports = {
44
restoreMocks: true,
55
moduleDirectories: ['<rootDir>/src', 'node_modules'],
66
setupFilesAfterEnv: ['<rootDir>/config/test/setup.ts'],
7-
modulePathIgnorePatterns: ['cypress'],
8-
transform: {
9-
'^.+\\.svg$': 'jest-svg-transformer',
10-
},
7+
modulePathIgnorePatterns: ['cypress']
118
};

front/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@
6868
"file-loader": "^5.0.2",
6969
"html-webpack-plugin": "^3.2.0",
7070
"jest": "^24.9.0",
71-
"jest-svg-transformer": "^1.0.0",
7271
"lint-staged": "^9.5.0",
7372
"mini-css-extract-plugin": "^0.8.0",
7473
"npm-run-all": "^4.1.5",

front/src/core/api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import io from 'socket.io-client';
1+
import * as ioClient from 'socket.io-client';
22
import { Socket } from 'socket.io';
33
import { baseSocketUrl } from './const';
44

@@ -18,5 +18,5 @@ export const createSocket = (connectionSetup: ConnectionSetup): Socket => {
1818
};
1919

2020
// TODO Add channel (room)
21-
return io(socketParams.url, socketParams.options);
21+
return ioClient(socketParams.url, socketParams.options);
2222
};

front/src/pods/student/student.component.spec.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { render, screen } from '@testing-library/react';
33
import { StudentComponent } from './student.component';
44

55
describe('StudentComponent tests', () => {
6-
it('It should show the session name and the text', () => {
6+
it('It should show the session name and the text when passing valid parameters', () => {
77
// Arrange
88
const props = {
99
room: 'Room I',
@@ -40,7 +40,7 @@ describe('StudentComponent tests', () => {
4040
expect(sessionName).toHaveTextContent(expectedSessionNameText);
4141
});
4242

43-
it('It should show an empty session name when passing null', () => {
43+
it('It should show an empty session name when passing a null room value', () => {
4444
// Arrange
4545
const props = {
4646
room: null,
@@ -58,15 +58,13 @@ describe('StudentComponent tests', () => {
5858
expect(sessionName).toHaveTextContent(expectedSessionNameText);
5959
});
6060

61-
it('It should empty text when passing undefined', () => {
61+
it('It should show an empty text when passing an undefined log value', () => {
6262
// Arrange
6363
const props = {
6464
room: 'Room I',
6565
log: undefined,
6666
};
6767

68-
const expectedSessionNameText = `Session name: ${props.room}`;
69-
7068
// Act
7169
render(<StudentComponent {...props} />);
7270

@@ -75,15 +73,13 @@ describe('StudentComponent tests', () => {
7573
expect(textArea).toHaveTextContent('');
7674
});
7775

78-
it('It should empty text when passing null', () => {
76+
it('It should show an empty text when passing a null log value', () => {
7977
// Arrange
8078
const props = {
8179
room: 'Room I',
82-
log: undefined,
80+
log: null,
8381
};
8482

85-
const expectedSessionNameText = `Session name: ${props.room}`;
86-
8783
// Act
8884
render(<StudentComponent {...props} />);
8985

front/src/pods/student/student.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const StudentComponent: React.FC<Props> = props => {
1717
<>
1818
<main className={mainContainer}>
1919
<Typography className={sessionName} variant="body1" role="heading">
20-
Session name: {room}
20+
Session name: {room ?? ''}
2121
</Typography>
2222
<label className={labelTextarea} htmlFor="session">
2323
Content
@@ -27,7 +27,7 @@ export const StudentComponent: React.FC<Props> = props => {
2727
rowsMax={30}
2828
rowsMin={30}
2929
className={studentBoard}
30-
value={log}
30+
value={log ?? ''}
3131
/>
3232
</main>
3333
</>

front/src/pods/student/student.container.spec.tsx

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

front/src/pods/student/student.container.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ import { useLog } from 'core';
99
import { StudentComponent } from './student.component';
1010
import { useWithRef } from 'common';
1111
import { getPreviousSessionContent } from 'common-app';
12+
import { useParams } from 'react-router-dom';
1213

13-
interface Props {
14+
interface Params {
1415
room: string;
1516
}
1617

17-
export const StudentContainer: React.FC<Props> = ({ room }) => {
18+
export const StudentContainer = () => {
19+
const { room } = useParams<Params>();
1820
const { log, appendToLog, setLog } = useLog();
1921
const [socket, setSocket, socketRef] = useWithRef<SocketIO.Socket>(null);
2022

front/src/scenes/student.scene.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ export const StudentScene = () => {
1111
React.useEffect(() => {
1212
document.title = `Student - Code Paster`;
1313
}, []);
14-
const { room } = useParams<Params>();
1514
return (
1615
<SessionLayout>
17-
<StudentContainer room={room}/>
16+
<StudentContainer />
1817
</SessionLayout>
1918
);
2019
};

0 commit comments

Comments
 (0)