@@ -2,7 +2,6 @@ import React from 'react';
22import { shallow } from 'enzyme' ;
33import { FileNode } from '../../modules/IDE/components/FileNode' ;
44
5- beforeAll ( ( ) => { } ) ;
65describe ( '<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 ) ) ;
0 commit comments