diff --git a/components/comment/__tests__/__snapshots__/index.test.js.snap b/components/comment/__tests__/__snapshots__/index.test.js.snap new file mode 100644 index 000000000..f026ca90b --- /dev/null +++ b/components/comment/__tests__/__snapshots__/index.test.js.snap @@ -0,0 +1,52 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Comment Comment can be used as editor, user can customize the editor component. 1`] = ` +
+
+
1 reply
+
+
+
+
+
+
+
+
+ +
222
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+`; diff --git a/components/comment/__tests__/index.test.js b/components/comment/__tests__/index.test.js new file mode 100644 index 000000000..0ac0cc7ca --- /dev/null +++ b/components/comment/__tests__/index.test.js @@ -0,0 +1,107 @@ +import { mount } from '@vue/test-utils'; +import moment from 'moment'; +import { asyncExpect } from '@/tests/utils'; +import Comment from '..'; +import List from '../../list'; +import Form from '../../form'; +import Button from '../../button'; +import Input from '../../input'; + +const CommentTest = { + data() { + return { + comments: [], + submitting: false, + value: '', + moment, + }; + }, + methods: { + handleSubmit() { + if (!this.value) { + return; + } + + this.submitting = true; + + setTimeout(() => { + this.submitting = false; + this.comments = [ + { + author: 'Han Solo', + avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png', + content: this.value, + datetime: moment().fromNow(), + }, + ...this.comments, + ]; + this.value = ''; + }, 1000); + }, + handleChange(e) { + this.value = e.target.value; + }, + }, + render() { + return ( +
+ {this.comments.length ? ( + 1 ? 'replies' : 'reply'}`} + itemLayout="horizontal" + renderItem={item => { + return ( + + + + ); + }} + /> + ) : null} + +
+ + + + + + +
+
+
+ ); + }, +}; + +describe('Comment', () => { + it('Comment can be used as editor, user can customize the editor component.', async () => { + const wrapper = mount(CommentTest, { + sync: false, + }); + await asyncExpect(() => { + wrapper.find('textarea').element.value = '222'; + wrapper.find('textarea').trigger('input'); + }); + await asyncExpect(() => { + wrapper.find('Button').trigger('click'); + }); + + await asyncExpect(() => { + expect(wrapper.findAll('.ant-list-header').wrappers[0].element.innerHTML).toBe('1 reply'); + expect(wrapper.html()).toMatchSnapshot(); + }, 2000); + }); +}); diff --git a/components/locale-provider/__tests__/__snapshots__/index.test.js.snap b/components/locale-provider/__tests__/__snapshots__/index.test.js.snap index 5116d8b94..7ef979cbb 100644 --- a/components/locale-provider/__tests__/__snapshots__/index.test.js.snap +++ b/components/locale-provider/__tests__/__snapshots__/index.test.js.snap @@ -12177,7 +12177,7 @@ exports[`Locale Provider should display the text as pt 1`] = `
-
set
+
Set
@@ -12199,43 +12199,43 @@ exports[`Locale Provider should display the text as pt 1`] = ` - +
28
- +
29
- +
30
- +
31
- +
01
- +
02
- +
03
@@ -12243,43 +12243,43 @@ exports[`Locale Provider should display the text as pt 1`] = ` - +
04
- +
05
- +
06
- +
07
- +
08
- +
09
- +
10
@@ -12287,43 +12287,43 @@ exports[`Locale Provider should display the text as pt 1`] = ` - +
11
- +
12
- +
13
- +
14
- +
15
- +
16
- +
17
@@ -12331,43 +12331,43 @@ exports[`Locale Provider should display the text as pt 1`] = ` - +
18
- +
19
- +
20
- +
21
- +
22
- +
23
- +
24
@@ -12375,43 +12375,43 @@ exports[`Locale Provider should display the text as pt 1`] = ` - +
25
- +
26
- +
27
- +
28
- +
29
- +
30
- +
01
@@ -12419,43 +12419,43 @@ exports[`Locale Provider should display the text as pt 1`] = ` - +
02
- +
03
- +
04
- +
05
- +
06
- +
07
- +
08
@@ -12576,7 +12576,7 @@ exports[`Locale Provider should display the text as pt-br 1`] = `
-
set
+
Set
@@ -12598,43 +12598,43 @@ exports[`Locale Provider should display the text as pt-br 1`] = ` - +
27
- +
28
- +
29
- +
30
- +
31
- +
01
- +
02
@@ -12642,43 +12642,43 @@ exports[`Locale Provider should display the text as pt-br 1`] = ` - +
03
- +
04
- +
05
- +
06
- +
07
- +
08
- +
09
@@ -12686,43 +12686,43 @@ exports[`Locale Provider should display the text as pt-br 1`] = ` - +
10
- +
11
- +
12
- +
13
- +
14
- +
15
- +
16
@@ -12730,43 +12730,43 @@ exports[`Locale Provider should display the text as pt-br 1`] = ` - +
17
- +
18
- +
19
- +
20
- +
21
- +
22
- +
23
@@ -12774,43 +12774,43 @@ exports[`Locale Provider should display the text as pt-br 1`] = ` - +
24
- +
25
- +
26
- +
27
- +
28
- +
29
- +
30
@@ -12818,43 +12818,43 @@ exports[`Locale Provider should display the text as pt-br 1`] = ` - +
01
- +
02
- +
03
- +
04
- +
05
- +
06
- +
07