Skip to content

Commit e5e5a6c

Browse files
committed
test: email comments test case
1 parent d536f08 commit e5e5a6c

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/component/comment.spec.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import { shallow } from 'enzyme'
2+
import { shallow, mount } from 'enzyme'
33

44
import Comment from './comment'
55
import Avatar from './avatar'
@@ -15,6 +15,17 @@ const comment = {
1515
}
1616
}
1717

18+
const emailComment = {
19+
html_url: 'https://github.com/xxxx/xxxxx/issues/1#issuecomment-xxxxx',
20+
body_html: '<div class="email-fragment">email response</div>↵<span class="email-hidden-toggle"><a href="#">…</a></span><div class="email-hidden-reply">↵<div class="email-signature-reply">------------------&amp;nbsp;原始邮件&amp;nbsp;------------------↵发件人:&amp;nbsp;↵↵↵↵↵xxxxxxxxxxxxxx↵↵—↵You are receiving this because you commented.↵Reply to this email directly, view it on GitHub, or unsubscribe.</div>↵</div>',
21+
created_at: '2017-06-30T09:01:19Z',
22+
user: {
23+
login: 'booxood',
24+
avatar_url: 'https://avatars0.githubusercontent.com/u/2151410?v=3',
25+
html_url: 'https://github.com/booxood'
26+
}
27+
}
28+
1829
describe('Comment', function () {
1930
it('render with no user', function () {
2031
const props = {
@@ -124,4 +135,19 @@ describe('Comment', function () {
124135
const wrapper = shallow(<Comment {...props} />)
125136
expect(wrapper.render().find('.gt-ico-heart .gt-ico-text').text()).toEqual('100+')
126137
})
138+
139+
it('render extended emailed comment and add event listener', function () {
140+
const props = {
141+
comment: emailComment
142+
}
143+
const wrapper = mount(<Comment {...props} />)
144+
expect(wrapper.render().find('.gt-comment-body > .email-fragment')).toHaveLength(1)
145+
expect(wrapper.render().find('.gt-comment-body > .email-hidden-toggle')).toHaveLength(1)
146+
expect(wrapper.render().find('.gt-comment-body > .email-hidden-reply')).toHaveLength(1)
147+
148+
// TODO: test click
149+
// enzyme don't support simulate click after render()
150+
// wrapper.render().find('.email-hidden-toggle > a').simulate('click')
151+
// expect(wrapper.render().find('.gt-comment-body > .email-hidden-reply.expanded')).toHaveLength(1)
152+
})
127153
})

0 commit comments

Comments
 (0)