From 3b74ef97379e74bbb58c7e94f037846e655b7e50 Mon Sep 17 00:00:00 2001 From: ghalestrilo Date: Thu, 30 Apr 2020 12:59:41 -0300 Subject: [PATCH] :white_check_mark: add tests for filenode regardless of type --- client/components/__test__/FileNode.test.jsx | 30 +++++++++++++------- client/components/__test__/Toolbar.test.jsx | 9 ++++++ 2 files changed, 28 insertions(+), 11 deletions(-) create mode 100644 client/components/__test__/Toolbar.test.jsx diff --git a/client/components/__test__/FileNode.test.jsx b/client/components/__test__/FileNode.test.jsx index 756652a3..d4496496 100644 --- a/client/components/__test__/FileNode.test.jsx +++ b/client/components/__test__/FileNode.test.jsx @@ -2,7 +2,6 @@ import React from 'react'; import { shallow } from 'enzyme'; import { FileNode } from '../../modules/IDE/components/FileNode'; -beforeAll(() => {}); describe('', () => { let component; let props = {}; @@ -17,7 +16,7 @@ describe('', () => { 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('', () => { }; component = shallow(); }); + + 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('', () => { // 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)); diff --git a/client/components/__test__/Toolbar.test.jsx b/client/components/__test__/Toolbar.test.jsx new file mode 100644 index 00000000..ffb47169 --- /dev/null +++ b/client/components/__test__/Toolbar.test.jsx @@ -0,0 +1,9 @@ +import React from 'react'; +import { shallow } from 'enzyme'; +import { Toolbar } from '../../modules/IDE/components/Toolbar'; + +describe('', () => { + describe('with valid props', () => { + it('renders', () => expect(true).toEqual(true)); + }); +});