Skip to content

Commit 3b74ef9

Browse files
committed
✅ add tests for filenode regardless of type
1 parent a307b0f commit 3b74ef9

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

client/components/__test__/FileNode.test.jsx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from 'react';
22
import { shallow } from 'enzyme';
33
import { FileNode } from '../../modules/IDE/components/FileNode';
44

5-
beforeAll(() => {});
65
describe('<FileNode />', () => {
76
let component;
87
let props = {};
@@ -17,7 +16,7 @@ describe('<FileNode />', () => {
1716
const getUpdatedName = () => getState().updatedName;
1817

1918
describe('with valid props, regardless of filetype', () => {
20-
[''].forEach((fileType) => {
19+
['folder', 'file'].forEach((fileType) => {
2120
beforeEach(() => {
2221
props = {
2322
...props,
@@ -39,6 +38,24 @@ describe('<FileNode />', () => {
3938
};
4039
component = shallow(<FileNode {...props} />);
4140
});
41+
42+
describe('when changing name', () => {
43+
beforeEach(() => {
44+
input = component.find('.sidebar__file-item-input');
45+
renameTriggerButton = component
46+
.find('.sidebar__file-item-option')
47+
.first();
48+
component.setState({ isEditing: true });
49+
});
50+
51+
describe('to an empty name', () => {
52+
const newName = '';
53+
beforeEach(() => changeName(newName));
54+
55+
it('should not save', () => expect(props.updateFileName).not.toHaveBeenCalled());
56+
it('should reset name', () => expect(getUpdatedName()).toEqual(props.name));
57+
});
58+
});
4259
});
4360
});
4461

@@ -88,15 +105,6 @@ describe('<FileNode />', () => {
88105

89106
// Failure Scenarios
90107

91-
describe('to an empty filename', () => {
92-
const newName = '';
93-
beforeEach(() => changeName(newName));
94-
95-
96-
it('should not save', () => expect(props.updateFileName).not.toHaveBeenCalled());
97-
it('should reset name', () => expect(getUpdatedName()).toEqual(props.name));
98-
});
99-
100108
describe('to an extensionless filename', () => {
101109
const newName = 'extensionless';
102110
beforeEach(() => changeName(newName));
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
import { shallow } from 'enzyme';
3+
import { Toolbar } from '../../modules/IDE/components/Toolbar';
4+
5+
describe('<Toolbar />', () => {
6+
describe('with valid props', () => {
7+
it('renders', () => expect(true).toEqual(true));
8+
});
9+
});

0 commit comments

Comments
 (0)