add tests for filenode regardless of type

This commit is contained in:
ghalestrilo 2020-04-30 12:59:41 -03:00
parent a307b0f84c
commit 3b74ef9737
2 changed files with 28 additions and 11 deletions

View file

@ -2,7 +2,6 @@ import React from 'react';
import { shallow } from 'enzyme';
import { FileNode } from '../../modules/IDE/components/FileNode';
beforeAll(() => {});
describe('<FileNode />', () => {
let component;
let props = {};
@ -17,7 +16,7 @@ describe('<FileNode />', () => {
const getUpdatedName = () => getState().updatedName;
describe('with valid props, regardless of filetype', () => {
[''].forEach((fileType) => {
['folder', 'file'].forEach((fileType) => {
beforeEach(() => {
props = {
...props,
@ -39,6 +38,24 @@ describe('<FileNode />', () => {
};
component = shallow(<FileNode {...props} />);
});
describe('when changing name', () => {
beforeEach(() => {
input = component.find('.sidebar__file-item-input');
renameTriggerButton = component
.find('.sidebar__file-item-option')
.first();
component.setState({ isEditing: true });
});
describe('to an empty name', () => {
const newName = '';
beforeEach(() => changeName(newName));
it('should not save', () => expect(props.updateFileName).not.toHaveBeenCalled());
it('should reset name', () => expect(getUpdatedName()).toEqual(props.name));
});
});
});
});
@ -88,15 +105,6 @@ describe('<FileNode />', () => {
// Failure Scenarios
describe('to an empty filename', () => {
const newName = '';
beforeEach(() => changeName(newName));
it('should not save', () => expect(props.updateFileName).not.toHaveBeenCalled());
it('should reset name', () => expect(getUpdatedName()).toEqual(props.name));
});
describe('to an extensionless filename', () => {
const newName = 'extensionless';
beforeEach(() => changeName(newName));

View file

@ -0,0 +1,9 @@
import React from 'react';
import { shallow } from 'enzyme';
import { Toolbar } from '../../modules/IDE/components/Toolbar';
describe('<Toolbar />', () => {
describe('with valid props', () => {
it('renders', () => expect(true).toEqual(true));
});
});