2020-04-30 15:59:41 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { shallow } from 'enzyme';
|
|
|
|
import { Toolbar } from '../../modules/IDE/components/Toolbar';
|
|
|
|
|
|
|
|
describe('<Toolbar />', () => {
|
2020-04-30 16:14:41 +00:00
|
|
|
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
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-04-30 15:59:41 +00:00
|
|
|
describe('with valid props', () => {
|
2020-04-30 16:14:41 +00:00
|
|
|
beforeEach(() => {
|
|
|
|
setProps();
|
|
|
|
component = shallow(<Toolbar {...props} />);
|
|
|
|
});
|
|
|
|
it('renders', () => expect(component).toBeDefined());
|
2020-04-30 15:59:41 +00:00
|
|
|
});
|
|
|
|
});
|