Skip to content

Commit 2dc1835

Browse files
authored
Merge pull request #3221 from processing/develop-khanniie-testwarnings
fix (some) test suite warnings
2 parents 272645f + de1b882 commit 2dc1835

File tree

5 files changed

+29
-8
lines changed

5 files changed

+29
-8
lines changed

client/modules/IDE/components/EditorAccessibility.unit.test.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import EditorAccessibility from './EditorAccessibility';
66

77
describe('<EditorAccessibility />', () => {
88
it('renders empty message with no lines', () => {
9-
render(<EditorAccessibility lintMessages={[]} />);
9+
render(<EditorAccessibility lintMessages={[]} currentLine={0} />);
1010

1111
expect(
1212
screen.getByRole('listitem', {
@@ -21,11 +21,12 @@ describe('<EditorAccessibility />', () => {
2121
lintMessages={[
2222
{
2323
severity: 'info',
24-
line: '1',
24+
line: 1,
2525
message: 'foo',
26-
id: '1a2b3c'
26+
id: 123
2727
}
2828
]}
29+
currentLine={0}
2930
/>
3031
);
3132

client/modules/IDE/components/ErrorModal.unit.test.jsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,30 @@ jest.mock('../../../i18n');
88

99
describe('<ErrorModal />', () => {
1010
it('renders type forceAuthentication', () => {
11-
render(<ErrorModal type="forceAuthentication" closeModal={jest.fn()} />);
11+
render(
12+
<ErrorModal
13+
type="forceAuthentication"
14+
closeModal={jest.fn()}
15+
service="google"
16+
/>
17+
);
1218

1319
expect(screen.getByText('Login')).toBeVisible();
1420
expect(screen.getByText('Sign Up')).toBeVisible();
1521
});
1622

1723
it('renders type staleSession', () => {
18-
render(<ErrorModal type="staleSession" closeModal={jest.fn()} />);
24+
render(
25+
<ErrorModal type="staleSession" closeModal={jest.fn()} service="google" />
26+
);
1927

2028
expect(screen.getByText('log in')).toBeVisible();
2129
});
2230

2331
it('renders type staleProject', () => {
24-
render(<ErrorModal type="staleProject" closeModal={jest.fn()} />);
32+
render(
33+
<ErrorModal type="staleProject" closeModal={jest.fn()} service="google" />
34+
);
2535

2636
expect(
2737
screen.getByText(

client/modules/IDE/components/FileNode.unit.test.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,18 @@ describe('<FileNode />', () => {
8383
});
8484

8585
it('can change to a different extension', async () => {
86+
const mockConfirm = jest.fn(() => true);
87+
window.confirm = mockConfirm;
88+
8689
const newName = 'newname.gif';
8790
const props = renderFileNode('file');
8891

8992
changeName(newName);
9093

91-
await waitFor(() => expect(props.updateFileName).not.toHaveBeenCalled());
94+
expect(mockConfirm).toHaveBeenCalled();
95+
await waitFor(() =>
96+
expect(props.updateFileName).toHaveBeenCalledWith(props.id, newName)
97+
);
9298
await expectFileNameToBe(props.name);
9399
});
94100

server/controllers/project.controller/__test__/createProject.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,10 @@ describe('project.controller', () => {
179179
});
180180

181181
it('fails if user does not have permission', async () => {
182+
// We don't want to clog up the jest output with extra
183+
// logs, so we turn off console warn for this one test.
184+
jest.spyOn(console, 'warn').mockImplementation(() => {});
185+
182186
request.user = { _id: 'abc123', username: 'alice' };
183187
request.params = {
184188
username: 'dana'

server/controllers/project.controller/createProject.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export async function apiCreateProject(req, res) {
5959

6060
const checkUserHasPermission = () => {
6161
if (req.user.username !== req.params.username) {
62-
console.log('no permission');
62+
console.warn('no permission');
6363
const error = new ProjectValidationError(
6464
`'${req.user.username}' does not have permission to create for '${req.params.username}'`
6565
);

0 commit comments

Comments
 (0)