Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test fix #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions src/App.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import { render } from 'enzyme';
import { shallow } from 'enzyme';
import { mount } from 'enzyme';
import App from './App';

it('renders without crashing', () => {
Expand All @@ -14,16 +15,38 @@ it('renders one ul tag', () => {
expect(wrapper.find('ul').length).toBe(1);
});

it('renders four li tags', () => {
it('renders three li tags at the beggining', () => {
const wrapper = render(<App />);
expect(wrapper.find('li').length).toBe(4);
expect(wrapper.find('li').length).toBe(3);
});

it('rendered the li with correct text', () => {
it('rendered the li with correct text at the beggining', () => {
const wrapper = shallow(<App />);
const techs = ['Javascript', 'CSS', 'HTLM', 'React']
expect(wrapper.find('li').length).toBe(4);
const tasks = ['Sacar la ropa', 'Hacer la cama', 'Leer un rato']
expect(wrapper.find('li').length).toBe(3);
wrapper.find('li').forEach(function(node, i) {
expect(node.text()).toBe(techs[i]);
expect(node.text()).toBe(tasks[i]);
});
});

it('creates a new task with the correct text', () => {
const wrapper = mount(<App />);
const tasks = ['Sacar la ropa', 'Hacer la cama', 'Leer un rato', 'Hola']
const newTask = wrapper.find('#new-task');
newTask.node.value = 'Hola';
newTask.simulate('change', {target: {value: 'Hola'}})
wrapper.find('input').simulate('keyPress', {key: 'Enter'})
expect(wrapper.find('li').length).toBe(4);
wrapper.find('li').forEach(function(node, i) {
expect(node.text()).toBe(tasks[i]);
});
})

it('the text input value is reset after creating task', () => {
const wrapper = mount(<App />);
const newTask = wrapper.find('#new-task');
newTask.node.value = 'Hola';
newTask.simulate('change', {target: {value: 'Hola'}})
wrapper.find('input').simulate('keyPress', {key: 'Enter'})
expect(wrapper.find('#new-task').node.value).toBe('')
})