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

Commit fceb64e

Browse files
committed
add test for getCharCount in utils
1 parent fedec94 commit fceb64e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"plugins": ["prettier", "flowtype", "react", "standard"],
2424
"env": {
2525
"es6": true,
26-
"browser": true
26+
"browser": true,
27+
"mocha": true
2728
},
2829
"rules": {
2930
"prettier/prettier": "error"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { expect } from 'chai'
2+
import { EditorState, ContentState } from 'draft-js'
3+
import { getCharCount } from '../index'
4+
5+
describe('char Counter', () => {
6+
const createEditorStateFromText = text => {
7+
const contentState = ContentState.createFromText(text)
8+
return EditorState.createWithContent(contentState)
9+
}
10+
11+
it('create editorState and counts 3 char', () => {
12+
const editorState = createEditorStateFromText('One')
13+
14+
const result = getCharCount(editorState)
15+
expect(result).to.equal(3)
16+
})
17+
})

0 commit comments

Comments
 (0)