Skip to content

Commit f6bcc5d

Browse files
committed
✅ Add twitter test.
1 parent 7186557 commit f6bcc5d

File tree

2 files changed

+17
-26
lines changed

2 files changed

+17
-26
lines changed

twitter/README.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff 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-
```

twitter/src/Twitter.test.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
11
import React from 'react'
22
import { shallow, mount } from 'enzyme'
33
import 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+
})

0 commit comments

Comments
 (0)