@@ -17,32 +17,42 @@ describe('c3 chart class', function () {
17
17
chart = window . initChart ( chart , args , done ) ;
18
18
} ) ;
19
19
20
- describe ( 'internal.getTargetSelectorSuffix ' , function ( ) {
20
+ describe ( 'internal.generateTargetClass ' , function ( ) {
21
21
22
22
it ( 'should not replace any characters' , function ( ) {
23
23
var input = 'data1' ,
24
24
expected = '-' + input ,
25
- suffix = chart . internal . getTargetSelectorSuffix ( input ) ;
25
+ suffix = chart . internal . generateTargetClass ( input ) ;
26
26
expect ( suffix ) . toBe ( expected ) ;
27
27
} ) ;
28
28
29
29
it ( 'should replace space to "-"' , function ( ) {
30
30
var input = 'data1 suffix' ,
31
31
expected = '-data1-suffix' ,
32
- suffix = chart . internal . getTargetSelectorSuffix ( input ) ;
32
+ suffix = chart . internal . generateTargetClass ( input ) ;
33
33
expect ( suffix ) . toBe ( expected ) ;
34
34
} ) ;
35
35
36
36
it ( 'should replace space to "-" with multibyte characters' , function ( ) {
37
37
var input = 'data1 suffix 日本語' ,
38
38
expected = '-data1-suffix-日本語' ,
39
- suffix = chart . internal . getTargetSelectorSuffix ( input ) ;
39
+ suffix = chart . internal . generateTargetClass ( input ) ;
40
40
expect ( suffix ) . toBe ( expected ) ;
41
41
} ) ;
42
42
43
- it ( 'should replace special charactors to "-"' , function ( ) {
43
+ it ( 'should not replace special characters' , function ( ) {
44
+ var input = 'data1 !@#$%^&*()_=+,.<>"\':;[]/|?~`{}\\' ,
45
+ expected = '-data1-!@#$%^&*()_=+,.<>"\':;[]/|?~`{}\\' ,
46
+ suffix = chart . internal . generateTargetClass ( input ) ;
47
+ expect ( suffix ) . toBe ( expected ) ;
48
+ } ) ;
49
+ } ) ;
50
+
51
+ describe ( 'internal.getTargetSelectorSuffix' , function ( ) {
52
+
53
+ it ( 'should escape special characters' , function ( ) {
44
54
var input = 'data1 !@#$%^&*()_=+,.<>"\':;[]/|?~`{}\\' ,
45
- expected = '-data1-------------------------------- ' ,
55
+ expected = '-data1-\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)\\_\\=\\+\\,\\.\\<\\>\\"\\\'\\:\\;\\[\\]\\/\\|\\?\\~\\`\\{\\}\\\\ ' ,
46
56
suffix = chart . internal . getTargetSelectorSuffix ( input ) ;
47
57
expect ( suffix ) . toBe ( expected ) ;
48
58
} ) ;
0 commit comments