-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy pathisEmptyTextNode.spec.js
More file actions
32 lines (24 loc) · 894 Bytes
/
Copy pathisEmptyTextNode.spec.js
File metadata and controls
32 lines (24 loc) · 894 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import isEmptyTextNode from 'utils/isEmptyTextNode';
describe('Testing `utils/isEmptyTextNode`', () => {
it('should return true for text nodes that contain a line break', () => {
const nodes = [
{ type: 'text', data:'\n' },
{ type: 'text', data:' \n' },
{ type: 'text', data:'\n ' },
{ type: 'text', data:' \n ' },
{ type: 'text', data:'\r\n' },
{ type: 'text', data:' \r\n' },
{ type: 'text', data:'\r\n ' },
{ type: 'text', data:' \r\n ' }
];
nodes.forEach(node => {
expect(isEmptyTextNode(node)).toBe(true);
});
});
it('should return false for text nodes not containing a line break', () => {
expect(isEmptyTextNode({ type:'text', data: '' })).toBe(false);
});
it('should return false for non text nodes', () => {
expect(isEmptyTextNode({ type:'tag' })).toBe(false);
});
});