File tree Expand file tree Collapse file tree 2 files changed +17
-26
lines changed
Expand file tree Collapse file tree 2 files changed +17
-26
lines changed Original file line number Diff line number Diff line change @@ -19,29 +19,3 @@ $ yarn test
1919```
2020$ yarn start
2121```
22-
23- ## Guideline
24-
25- ``` javascript
26- // Twitter.test.js
27- import React from ' react'
28- import { shallow , mount } from ' enzyme'
29- import Twitter from ' ./Twitter'
30-
31- it (' Contain twitter board.' , () => {
32- const wrapper = shallow (< Twitter / > )
33-
34- expect (wrapper .find (' #twitter-board' )).toHaveLength (1 )
35- })
36-
37- it (' Render a tweet after simulate submit tweet event.' , () => {
38- const event = { target: { value: ' Hello' } }
39- const wrapper = mount (< Twitter / > )
40-
41- wrapper .find (' #tweet-text' ).simulate (' change' , event )
42- wrapper .find (' #tweet-button' ).simulate (' submit' )
43-
44- expect (wrapper .find (' .tweet-item' )).toHaveLength (1 )
45- expect (wrapper .find (' #tweet-text' ).props ().value ).toEqual (' ' )
46- })
47- ```
Original file line number Diff line number Diff line change 11import React from 'react'
22import { shallow , mount } from 'enzyme'
33import Twitter from './Twitter'
4+
5+ it ( 'Contain twitter board.' , ( ) => {
6+ const wrapper = shallow ( < Twitter /> )
7+
8+ expect ( wrapper . find ( '#twitter-board' ) ) . toHaveLength ( 1 )
9+ } )
10+
11+ it ( 'Render a tweet after simulate submit tweet event.' , ( ) => {
12+ const event = { target : { value : 'Hello' } }
13+ const wrapper = mount ( < Twitter /> )
14+
15+ wrapper . find ( '#tweet-text' ) . simulate ( 'change' , event )
16+ wrapper . find ( '#tweet-button' ) . simulate ( 'submit' )
17+
18+ expect ( wrapper . find ( '.tweet-item' ) ) . toHaveLength ( 1 )
19+ expect ( wrapper . find ( '#tweet-text' ) . props ( ) . value ) . toEqual ( '' )
20+ } )
You can’t perform that action at this time.
0 commit comments