@@ -2,7 +2,6 @@ import React from 'react';
2
2
import { shallow } from 'enzyme' ;
3
3
import { FileNode } from '../../modules/IDE/components/FileNode' ;
4
4
5
- beforeAll ( ( ) => { } ) ;
6
5
describe ( '<FileNode />' , ( ) => {
7
6
let component ;
8
7
let props = { } ;
@@ -17,7 +16,7 @@ describe('<FileNode />', () => {
17
16
const getUpdatedName = ( ) => getState ( ) . updatedName ;
18
17
19
18
describe ( 'with valid props, regardless of filetype' , ( ) => {
20
- [ '' ] . forEach ( ( fileType ) => {
19
+ [ 'folder' , 'file '] . forEach ( ( fileType ) => {
21
20
beforeEach ( ( ) => {
22
21
props = {
23
22
...props ,
@@ -39,6 +38,24 @@ describe('<FileNode />', () => {
39
38
} ;
40
39
component = shallow ( < FileNode { ...props } /> ) ;
41
40
} ) ;
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
+ } ) ;
42
59
} ) ;
43
60
} ) ;
44
61
@@ -88,15 +105,6 @@ describe('<FileNode />', () => {
88
105
89
106
// Failure Scenarios
90
107
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
-
100
108
describe ( 'to an extensionless filename' , ( ) => {
101
109
const newName = 'extensionless' ;
102
110
beforeEach ( ( ) => changeName ( newName ) ) ;
0 commit comments