♻️ export unconnected Toolbar for testability
This commit is contained in:
parent
3b74ef9737
commit
90b11844c5
2 changed files with 48 additions and 2 deletions
|
@ -3,7 +3,53 @@ import { shallow } from 'enzyme';
|
||||||
import { Toolbar } from '../../modules/IDE/components/Toolbar';
|
import { Toolbar } from '../../modules/IDE/components/Toolbar';
|
||||||
|
|
||||||
describe('<Toolbar />', () => {
|
describe('<Toolbar />', () => {
|
||||||
|
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', () => {
|
describe('with valid props', () => {
|
||||||
it('renders', () => expect(true).toEqual(true));
|
beforeEach(() => {
|
||||||
|
setProps();
|
||||||
|
component = shallow(<Toolbar {...props} />);
|
||||||
|
});
|
||||||
|
it('renders', () => expect(component).toBeDefined());
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,7 +14,7 @@ const stopUrl = require('../../../images/stop.svg');
|
||||||
const preferencesUrl = require('../../../images/preferences.svg');
|
const preferencesUrl = require('../../../images/preferences.svg');
|
||||||
const editProjectNameUrl = require('../../../images/pencil.svg');
|
const editProjectNameUrl = require('../../../images/pencil.svg');
|
||||||
|
|
||||||
class Toolbar extends React.Component {
|
export class Toolbar extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.handleKeyPress = this.handleKeyPress.bind(this);
|
this.handleKeyPress = this.handleKeyPress.bind(this);
|
||||||
|
|
Loading…
Reference in a new issue