Skip to content
This repository was archived by the owner on May 31, 2020. It is now read-only.

Commit dc5925d

Browse files
committed
add test for getLineCount in utils
1 parent a5d0954 commit dc5925d

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed
Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,52 @@
11
import { expect } from 'chai'
22
import { EditorState, ContentState } from 'draft-js'
3-
import { getCharCount, getWordCount } from '../index'
3+
import { getCharCount, getWordCount, getLineCount } from '../index'
44

5-
describe('char Counter(non-unicode)', () => {
5+
describe('Char Counter', () => {
66
const createEditorStateFromText = text => {
77
const contentState = ContentState.createFromText(text)
88
return EditorState.createWithContent(contentState)
99
}
1010

11-
it('create editorState and counts 3 char', () => {
11+
it('create editorState and counts 3 characters', () => {
1212
const editorState = createEditorStateFromText('One')
1313

1414
const result = getCharCount(editorState)
1515
expect(result).to.equal(3)
1616
})
17+
18+
it('create editorState and counts 3 unicode characters', () => {
19+
const editorState = createEditorStateFromText('😁😂😃')
20+
21+
const result = getCharCount(editorState)
22+
expect(result).to.equal(3)
23+
})
1724
})
1825

19-
describe('char Counter(unicode)', () => {
26+
describe('Word Counter', () => {
2027
const createEditorStateFromText = text => {
2128
const contentState = ContentState.createFromText(text)
2229
return EditorState.createWithContent(contentState)
2330
}
2431

25-
it('create editorState and counts 1 char', () => {
26-
const editorState = createEditorStateFromText('')
32+
it('create editorState and counts 3 words', () => {
33+
const editorState = createEditorStateFromText('One two three')
2734

28-
const result = getCharCount(editorState)
29-
expect(result).to.equal(1)
35+
const result = getWordCount(editorState)
36+
expect(result).to.equal(3)
3037
})
3138
})
3239

33-
describe('word Counter', () => {
40+
describe('Line Counter', () => {
3441
const createEditorStateFromText = text => {
3542
const contentState = ContentState.createFromText(text)
3643
return EditorState.createWithContent(contentState)
3744
}
3845

39-
it('create editorState and counts 3 word', () => {
40-
const editorState = createEditorStateFromText('One two three')
46+
it('create editorState and counts 3 lines', () => {
47+
const editorState = createEditorStateFromText('One\ntwo\nthree')
4148

42-
const result = getWordCount(editorState)
49+
const result = getLineCount(editorState)
4350
expect(result).to.equal(3)
4451
})
4552
})

0 commit comments

Comments
 (0)