Skip to content

Commit 02aed9e

Browse files
committed
Fix jest tests with GPT
1 parent edc2536 commit 02aed9e

4 files changed

Lines changed: 44 additions & 7 deletions

File tree

services/app/apps/codebattle/assets/js/__tests__/RootContainer.test.jsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,30 @@ import waitingRoom from '../widgets/machines/waitingRoom';
1919
import RootContainer from '../widgets/pages/RoomWidget';
2020
import reducers from '../widgets/slices';
2121

22+
jest.mock('monaco-editor', () => ({
23+
editor: {
24+
defineTheme: () => {},
25+
create: () => ({
26+
dispose: () => {},
27+
onDidChangeModelContent: () => {},
28+
setValue: () => {},
29+
getValue: () => {},
30+
getModel: () => {},
31+
focus: () => {},
32+
}),
33+
},
34+
}));
35+
36+
jest.mock('monaco-vim', () => ({
37+
VimMode: class {
38+
constructor() {
39+
return {
40+
dispose: () => {},
41+
};
42+
}
43+
},
44+
}));
45+
2246
jest.mock('../widgets/initEditor.js', () => ({}));
2347

2448
jest.mock('../widgets/pages/game/TaskDescriptionMarkdown', () => () => (<>Examples: </>));
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
import "bootstrap";
1+
import 'bootstrap';

services/app/apps/codebattle/assets/js/widgets/pages/registration/Registration.jsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { useState } from 'react';
22

3+
import { faEye, faEyeSlash } from '@fortawesome/free-solid-svg-icons';
34
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
45
import axios from 'axios';
56
import cn from 'classnames';
@@ -91,7 +92,8 @@ const PasswordInput = ({ id, title, formik }) => {
9192
className={`position-absolute end-0 top-0 h-100 ${isInvalid ? 'mr-4' : ''}`}
9293
onClick={togglePasswordVisibility}
9394
>
94-
<FontAwesomeIcon icon={showPassword ? 'eye-slash' : 'eye'} />
95+
{/* <FontAwesomeIcon icon={showPassword ? 'eye-slash' : 'eye'} /> */}
96+
<FontAwesomeIcon icon={showPassword ? faEyeSlash : faEye} />
9597
</Button>
9698
</div>
9799
{isInvalid && <div className="invalid-feedback">{formik.errors[id]}</div>}
@@ -122,7 +124,9 @@ const SocialLinks = ({ isSignUp }) => (
122124
href={getLinkWithNext('/auth/github')}
123125
className="btn w-100 px-2 btn-outline-dark rounded-lg"
124126
>
125-
{isSignUp ? i18n.t('Sign up with Github') : i18n.t('Sign in with Github')}
127+
{isSignUp
128+
? i18n.t('Sign up with Github')
129+
: i18n.t('Sign in with Github')}
126130
</a>
127131
</div>
128132
<div className="mt-1">
@@ -132,7 +136,9 @@ const SocialLinks = ({ isSignUp }) => (
132136
href={getLinkWithNext('/auth/discord')}
133137
className="btn w-100 px-2 btn-outline-dark rounded-lg"
134138
>
135-
{isSignUp ? i18n.t('Sign up with Discord') : i18n.t('Sign in with Discord')}
139+
{isSignUp
140+
? i18n.t('Sign up with Discord')
141+
: i18n.t('Sign in with Discord')}
136142
</a>
137143
</div>
138144
</>
@@ -273,7 +279,11 @@ function SignUp() {
273279
<Input id="name" type="text" title="Nickname" formik={formik} />
274280
<Input id="email" type="email" title="Email" formik={formik} />
275281
<PasswordInput id="password" title="Password" formik={formik} />
276-
<PasswordInput id="passwordConfirmation" title="Password Confirmation" formik={formik} />
282+
<PasswordInput
283+
id="passwordConfirmation"
284+
title="Password Confirmation"
285+
formik={formik}
286+
/>
277287
</Form>
278288
<SocialLinks isSignUp />
279289
</Body>

services/app/apps/codebattle/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
},
1818
"jest": {
1919
"verbose": true,
20+
"testEnvironment": "jsdom",
21+
"transform": {
22+
"^.+\\.(js|jsx|ts|tsx|mjs)$": "babel-jest"
23+
},
2024
"moduleNameMapper": {
2125
"^monaco-editor$": "<rootDir>/node_modules/@monaco-editor/react",
2226
"^.+\\.(css|styl|less|sass|scss|po|png|jpg|ttf|woff|woff2)$": "jest-transform-stub",
@@ -34,8 +38,7 @@
3438
"/helpers/"
3539
],
3640
"transformIgnorePatterns": [
37-
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
38-
"^.+\\.module\\.(css|sass|scss)$"
41+
"/node_modules/(?!(monaco-editor|@monaco-editor|monaco-vim)/)"
3942
]
4043
},
4144
"dependencies": {

0 commit comments

Comments
 (0)