-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Expand file tree
/
Copy pathms-list-converter.js
More file actions
57 lines (53 loc) · 1.95 KB
/
ms-list-converter.js
File metadata and controls
57 lines (53 loc) · 1.95 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
* Internal dependencies
*/
import msListConverter from '../ms-list-converter';
import { deepFilterHTML } from '../utils';
describe( 'msListConverter', () => {
it( 'should convert unordered list', () => {
const input =
'<p style="mso-list:l0 level1 lfo1"><span style="mso-list:Ignore">* </span>test</p>';
const output = '<ul><li>test</li></ul>';
expect( deepFilterHTML( input, [ msListConverter ] ) ).toEqual(
output
);
} );
it( 'should convert ordered list', () => {
const input =
'<p style="mso-list:l0 level1 lfo1"><span style="mso-list:Ignore">1 </span>test</p>';
const output = '<ol type="1"><li>test</li></ol>';
expect( deepFilterHTML( input, [ msListConverter ] ) ).toEqual(
output
);
} );
it( 'should convert indented list', () => {
const input1 =
'<p style="mso-list:l0 level1 lfo1"><span style="mso-list:Ignore">* </span>test</p>';
const input2 =
'<p style="mso-list:l0 level2 lfo1"><span style="mso-list:Ignore">* </span>test</p>';
const input3 =
'<p style="mso-list:l0 level1 lfo1"><span style="mso-list:Ignore">* </span>test</p>';
const output =
'<ul><li>test<ul><li>test</li></ul></li><li>test</li></ul>';
expect(
deepFilterHTML( input1 + input2 + input3, [ msListConverter ] )
).toEqual( output );
} );
it( 'should convert deep indented list', () => {
const input1 =
'<p style="mso-list:l0 level1 lfo1"><span style="mso-list:Ignore">* </span>test</p>';
const input2 =
'<p style="mso-list:l0 level2 lfo1"><span style="mso-list:Ignore">* </span>test</p>';
const input3 =
'<p style="mso-list:l0 level3 lfo1"><span style="mso-list:Ignore">* </span>test</p>';
const input4 =
'<p style="mso-list:l0 level1 lfo1"><span style="mso-list:Ignore">* </span>test</p>';
const output =
'<ul><li>test<ul><li>test<ul><li>test</li></ul></li></ul></li><li>test</li></ul>';
expect(
deepFilterHTML( input1 + input2 + input3 + input4, [
msListConverter,
] )
).toEqual( output );
} );
} );