diff --git a/client/components/__test__/Toolbar.test.jsx b/client/components/__test__/Toolbar.test.jsx index ffb47169..23bed4a0 100644 --- a/client/components/__test__/Toolbar.test.jsx +++ b/client/components/__test__/Toolbar.test.jsx @@ -3,7 +3,53 @@ import { shallow } from 'enzyme'; import { Toolbar } from '../../modules/IDE/components/Toolbar'; describe('', () => { + let component; + let props = {}; + let input; + let renameTriggerButton; + const changeName = (newFileName) => { + renameTriggerButton.simulate('click'); + input.simulate('change', { target: { value: newFileName } }); + input.simulate('blur'); + }; + const getState = () => component.state(); + const getUpdatedName = () => getState().updatedName; + const setProps = (additionalProps) => { + props = { + isPlaying: false, + preferencesIsVisible: false, + stopSketch: jest.fn(), + setProjectName: jest.fn(), + openPreferences: jest.fn(), + owner: { + username: '' + }, + project: { + name: '', + isEditingName: false, + id: '', + }, + showEditProjectName: jest.fn(), + hideEditProjectName: jest.fn(), + infiniteLoop: false, + autorefresh: false, + setAutorefresh: jest.fn(), + setTextOutput: jest.fn(), + setGridOutput: jest.fn(), + startSketch: jest.fn(), + startAccessibleSketch: jest.fn(), + saveProject: jest.fn(), + currentUser: '', + ...additionalProps + }; + }; + + describe('with valid props', () => { - it('renders', () => expect(true).toEqual(true)); + beforeEach(() => { + setProps(); + component = shallow(); + }); + it('renders', () => expect(component).toBeDefined()); }); }); diff --git a/client/modules/IDE/components/Toolbar.jsx b/client/modules/IDE/components/Toolbar.jsx index 35c29f7d..07b4d7b1 100644 --- a/client/modules/IDE/components/Toolbar.jsx +++ b/client/modules/IDE/components/Toolbar.jsx @@ -14,7 +14,7 @@ const stopUrl = require('../../../images/stop.svg'); const preferencesUrl = require('../../../images/preferences.svg'); const editProjectNameUrl = require('../../../images/pencil.svg'); -class Toolbar extends React.Component { +export class Toolbar extends React.Component { constructor(props) { super(props); this.handleKeyPress = this.handleKeyPress.bind(this);