@@ -3,80 +3,80 @@ S = require '../../src/layout/SpecialString'
3
3
describe " SpecialString" , ->
4
4
describe ' SpecialString()' , ->
5
5
it ' should return instance' , ->
6
- S (' s' ).should .be .instanceOf S
6
+ new S (' s' ).should .be .instanceOf S
7
7
8
8
describe ' length()' , ->
9
9
it ' should return correct length for normal text' , ->
10
- S (' hello' ).length .should .equal 5
10
+ new S (' hello' ).length .should .equal 5
11
11
12
12
it ' should return correct length for text containing tabs and tags' , ->
13
- S (' <a>he<you />l\t lo</a>' ).length .should .equal 13
13
+ new S (' <a>he<you />l\t lo</a>' ).length .should .equal 13
14
14
15
15
it " shouldn't count empty tags as tags" , ->
16
- S (' <>><' ).length .should .equal 4
16
+ new S (' <>><' ).length .should .equal 4
17
17
18
18
it " should count length of single tag as 0" , ->
19
- S (' <html>' ).length .should .equal 0
19
+ new S (' <html>' ).length .should .equal 0
20
20
21
21
it " should work correctly with html quoted characters" , ->
22
- S (' >< &sp;' ).length .should .equal 5
22
+ new S (' >< &sp;' ).length .should .equal 5
23
23
24
24
describe ' splitIn()' , ->
25
25
it " should work correctly with normal text" , ->
26
- S (" 123456" ).splitIn (3 ).should .be .like [' 123' , ' 456' ]
26
+ new S (" 123456" ).splitIn (3 ).should .be .like [' 123' , ' 456' ]
27
27
28
28
it " should work correctly with normal text containing tabs and tags" , ->
29
- S (" 12\t 3<hello>456" ).splitIn (3 ).should .be .like [' 12' , ' \t ' , ' 3<hello>45' , ' 6' ]
29
+ new S (" 12\t 3<hello>456" ).splitIn (3 ).should .be .like [' 12' , ' \t ' , ' 3<hello>45' , ' 6' ]
30
30
31
31
it " should not trimLeft all lines when trimLeft is no" , ->
32
- S (' abc def' ).splitIn (3 ).should .be .like [' abc' , ' de' , ' f' ]
32
+ new S (' abc def' ).splitIn (3 ).should .be .like [' abc' , ' de' , ' f' ]
33
33
34
34
it " should trimLeft all lines when trimLeft is true" , ->
35
- S (' abc def' ).splitIn (3 , yes ).should .be .like [' abc' , ' def' ]
35
+ new S (' abc def' ).splitIn (3 , yes ).should .be .like [' abc' , ' def' ]
36
36
37
37
describe ' cut()' , ->
38
38
it " should work correctly with text containing tabs and tags" , ->
39
- original = S (" 12\t 3<hello>456" )
39
+ original = new S (" 12\t 3<hello>456" )
40
40
cut = original .cut (2 , 3 )
41
41
original .str .should .equal ' 123<hello>456'
42
42
cut .str .should .equal ' \t '
43
43
44
44
it " should trim left when trimLeft is true" , ->
45
- original = S ' 132'
45
+ original = new S ' 132'
46
46
cut = original .cut 0 , 1 , yes
47
47
original .str .should .equal ' 32'
48
48
cut .str .should .equal ' 1'
49
49
50
50
it " should be greedy" , ->
51
- S (" ab<tag>a" ).cut (0 , 2 ).str .should .equal " ab<tag>"
51
+ new S (" ab<tag>a" ).cut (0 , 2 ).str .should .equal " ab<tag>"
52
52
53
53
describe ' isOnlySpecialChars()' , ->
54
54
it " should work" , ->
55
- S (" 12\t 3<hello>456" ).isOnlySpecialChars ().should .equal no
56
- S (" <hello>" ).isOnlySpecialChars ().should .equal yes
55
+ new S (" 12\t 3<hello>456" ).isOnlySpecialChars ().should .equal no
56
+ new S (" <hello>" ).isOnlySpecialChars ().should .equal yes
57
57
58
58
describe ' clone()' , ->
59
59
it " should return independent instance" , ->
60
- a = S (' hello' )
60
+ a = new S (' hello' )
61
61
b = a .clone ()
62
62
a .str .should .equal b .str
63
63
a .should .not .equal b
64
64
65
65
describe ' trim()' , ->
66
66
it " should return an independent instance" , ->
67
- s = S (' ' )
67
+ s = new S (' ' )
68
68
s .trim ().should .not .equal s
69
69
70
70
it ' should return the same string when trim is not required' , ->
71
- S (' hello' ).trim ().str .should .equal ' hello'
71
+ new S (' hello' ).trim ().str .should .equal ' hello'
72
72
73
73
it ' should return trimmed string' , ->
74
- S (' hello' ).trim ().str .should .equal ' hello'
74
+ new S (' hello' ).trim ().str .should .equal ' hello'
75
75
76
76
describe ' trimLeft()' , ->
77
77
it " should only trim on the left" , ->
78
- S (' hello ' ).trimLeft ().str .should .equal ' hello '
78
+ new S (' hello ' ).trimLeft ().str .should .equal ' hello '
79
79
80
80
describe ' trimRight()' , ->
81
81
it " should only trim on the right" , ->
82
- S (' hello ' ).trimRight ().str .should .equal ' hello'
82
+ new S (' hello ' ).trimRight ().str .should .equal ' hello'
0 commit comments