File tree Expand file tree Collapse file tree 8 files changed +227
-11
lines changed
common/js/components/todos Expand file tree Collapse file tree 8 files changed +227
-11
lines changed Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import TodoForm from '../index' ;
3+ import { mount } from 'enzyme' ;
4+
5+ describe ( 'TodoForm' , ( ) => {
6+ it ( 'renders correctly' , ( ) => {
7+ const component = mount ( < TodoForm /> ) ;
8+ expect ( component ) . toMatchSnapshot ( ) ;
9+ } ) ;
10+
11+ describe ( 'clicking on submit button' , ( ) => {
12+ test ( 'calls the onSubmit prop' , ( ) => {
13+ const mockSubmit = jest . fn ( ) ;
14+ const component = mount ( < TodoForm onSubmit = { mockSubmit } /> ) ;
15+
16+ // test form submission
17+ component . setState ( { todoText : 'Foobar' } ) ;
18+ component . find ( 'form' ) . simulate ( 'submit' ) ;
19+
20+ expect ( mockSubmit . mock . calls . length ) . toEqual ( 1 ) ;
21+ } ) ;
22+ } ) ;
23+ } ) ;
Original file line number Diff line number Diff line change 1+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+ exports [` TodoForm renders correctly 1` ] = `
4+ <TodoForm >
5+ <Form
6+ as = " form"
7+ className = " todoForm"
8+ onSubmit = { [Function ]}
9+ >
10+ <form
11+ className = " ui form todoForm"
12+ onSubmit = { [Function ]}
13+ >
14+ <FormGroup >
15+ <div
16+ className = " fields"
17+ >
18+ <FormInput
19+ as = { [Function ]}
20+ control = { [Function ]}
21+ onChange = { [Function ]}
22+ placeholder = " Add a todo..."
23+ type = " text"
24+ value = " "
25+ >
26+ <FormField
27+ control = { [Function ]}
28+ onChange = { [Function ]}
29+ placeholder = " Add a todo..."
30+ type = " text"
31+ value = " "
32+ >
33+ <div
34+ className = " field"
35+ >
36+ <Input
37+ onChange = { [Function ]}
38+ placeholder = " Add a todo..."
39+ type = " text"
40+ value = " "
41+ >
42+ <div
43+ className = " ui input"
44+ >
45+ <input
46+ key = " text"
47+ onChange = { [Function ]}
48+ placeholder = " Add a todo..."
49+ type = " text"
50+ value = " "
51+ />
52+ </div >
53+ </Input >
54+ </div >
55+ </FormField >
56+ </FormInput >
57+ <FormButton
58+ as = { [Function ]}
59+ content = " Add"
60+ control = { [Function ]}
61+ icon = " plus"
62+ >
63+ <FormField
64+ content = " Add"
65+ control = { [Function ]}
66+ icon = " plus"
67+ >
68+ <div
69+ className = " field"
70+ >
71+ <Button
72+ as = " button"
73+ content = " Add"
74+ icon = " plus"
75+ >
76+ <button
77+ className = " ui button"
78+ onClick = { [Function ]}
79+ role = " button"
80+ >
81+ <Icon
82+ as = " i"
83+ key = " plus"
84+ name = " plus"
85+ >
86+ <i
87+ aria-hidden = " true"
88+ className = " plus icon"
89+ />
90+ </Icon >
91+ Add
92+ </button >
93+ </Button >
94+ </div >
95+ </FormField >
96+ </FormButton >
97+ </div >
98+ </FormGroup >
99+ </form >
100+ </Form >
101+ </TodoForm >
102+ ` ;
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import TodoItem from '../index' ;
3+ import { shallow } from 'enzyme' ;
4+
5+ describe ( 'TodoItem' , ( ) => {
6+ it ( 'renders correctly' , ( ) => {
7+ const component = shallow ( < TodoItem todo = { { id : 1 , text : 'Work' } } /> ) ;
8+ expect ( component ) . toMatchSnapshot ( ) ;
9+ } ) ;
10+ } ) ;
Original file line number Diff line number Diff line change 1+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+ exports [` TodoItem renders correctly 1` ] = `
4+ <ListItem
5+ className = " todo extra"
6+ >
7+ <ListContent
8+ floated = " right"
9+ >
10+ <Button
11+ as = " button"
12+ icon = " remove"
13+ onClick = { [Function ]}
14+ size = " mini"
15+ />
16+ </ListContent >
17+ <ListContent
18+ floated = " left"
19+ >
20+ <Checkbox
21+ onChange = { [Function ]}
22+ type = " checkbox"
23+ />
24+ </ListContent >
25+ <ListContent
26+ className = " text"
27+ >
28+ Work
29+ </ListContent >
30+ </ListItem >
31+ ` ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import TodoList from '../index' ;
3+ import { shallow } from 'enzyme' ;
4+
5+ describe ( 'TodoList' , ( ) => {
6+ let todos = {
7+ isFetched : true ,
8+ todos : [
9+ {
10+ id : 1 ,
11+ text : 'Learn React' ,
12+ completed : true
13+ } ,
14+ {
15+ id : 2 ,
16+ text : 'Learn Redux' ,
17+ completed : true
18+ }
19+ ]
20+ } ;
21+
22+
23+ it ( 'renders correctly' , ( ) => {
24+ const component = shallow ( < TodoList todos = { todos } /> ) ;
25+ expect ( component ) . toMatchSnapshot ( ) ;
26+ } ) ;
27+ } ) ;
Original file line number Diff line number Diff line change 1+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+ exports [` TodoList renders correctly 1` ] = `
4+ <List
5+ className = " todos"
6+ divided = { true }
7+ >
8+ <TodoItem
9+ key = " 0"
10+ onChange = { [Function ]}
11+ onRemove = { [Function ]}
12+ todo = {
13+ Object {
14+ " completed" : true ,
15+ " id" : 1 ,
16+ " text" : " Learn React" ,
17+ }
18+ }
19+ />
20+ <TodoItem
21+ key = " 1"
22+ onChange = { [Function ]}
23+ onRemove = { [Function ]}
24+ todo = {
25+ Object {
26+ " completed" : true ,
27+ " id" : 2 ,
28+ " text" : " Learn Redux" ,
29+ }
30+ }
31+ />
32+ </List >
33+ ` ;
Original file line number Diff line number Diff line change 11import request from 'supertest' ;
22import express from 'express' ;
3- import todos from './index' ;
3+ import todos from '.. /index' ;
44
55let app , agent ;
66
You can’t perform that action at this time.
0 commit comments