add test for question delete; fix bug with delete question
This commit is contained in:
@@ -99,17 +99,45 @@ describe('complete testing', () => {
|
||||
|
||||
});
|
||||
|
||||
xit ('removes correct text field when delete button on text field is clicked', () => {
|
||||
it ('removes correct text field when delete button on text field is clicked', () => {
|
||||
const addButton = wrapper.find('button').at(0);
|
||||
addButton.simulate('click');
|
||||
addButton.simulate('click');
|
||||
const firstQuestionTextField = wrapper.find('TextField').at(2);
|
||||
const secondQuestionTextField = wrapper.find('TextField').at(3);
|
||||
const thirdQuestionTextField = wrapper.find('TextField').at(4);
|
||||
|
||||
let firstQuestionTextField = wrapper.find('TextField').at(2);
|
||||
let secondQuestionTextField = wrapper.find('TextField').at(3);
|
||||
let thirdQuestionTextField = wrapper.find('TextField').at(4);
|
||||
|
||||
firstQuestionTextField.instance().props.onChange('first question');
|
||||
secondQuestionTextField.instance().props.onChange('second question');
|
||||
thirdQuestionTextField.instance().props.onChange('third question');
|
||||
|
||||
expect(firstQuestionTextField.instance().value).toEqual('first question');
|
||||
expect(secondQuestionTextField.instance().value).toEqual('second question');
|
||||
expect(thirdQuestionTextField.instance().value).toEqual('third question');
|
||||
expect(wrapper.state('intent').questions.length).toBe(3);
|
||||
|
||||
const rightIcon = secondQuestionTextField.props().rightIcon;
|
||||
rightIcon.props.onClick(secondQuestionTextField.props().key);
|
||||
|
||||
expect(wrapper.state('intent').questions.length).toBe(2);
|
||||
expect(secondQuestionTextField.instance().value).toEqual('third question');
|
||||
expect(thirdQuestionTextField.instance()._field._field).toBeNull();
|
||||
});
|
||||
|
||||
it ('does not remove text field when it is only one left', () => {
|
||||
let firstQuestionTextField = wrapper.find('TextField').at(2);
|
||||
|
||||
firstQuestionTextField.instance().props.onChange('first question');
|
||||
|
||||
expect(firstQuestionTextField.props().id).toEqual('intent question');
|
||||
expect(secondQuestionTextField.props().id).toEqual('intent question');
|
||||
expect(thirdQuestionTextField.props().id).toEqual('intent question');
|
||||
//TODO: simulate click on delete icon inside text field and check if text field is removed
|
||||
expect(wrapper.state('intent').questions.length).toBe(1);
|
||||
|
||||
const rightIcon = firstQuestionTextField.props().rightIcon;
|
||||
rightIcon.props.onClick(firstQuestionTextField.props().key);
|
||||
|
||||
expect(wrapper.state('intent').questions.length).toBe(1);
|
||||
expect(firstQuestionTextField.instance().value).toEqual('first question');
|
||||
});
|
||||
|
||||
it ('accepts text without special characters for intent explanation', () => {
|
||||
|
||||
Reference in New Issue
Block a user