@@ -24,123 +24,118 @@ define([
24
24
obj = new Constr ( ) ;
25
25
} ) ;
26
26
27
- describe ( 'wysiwygAdapter' , function ( ) {
28
- describe ( 'encoding and decoding directives' , function ( ) {
29
- /**
30
- * Tests encoding and decoding directives
31
- *
32
- * @param decodedHtml
33
- * @param encodedHtml
34
- */
35
- function runTests ( decodedHtml , encodedHtml ) {
36
- var encodedHtmlWithForwardSlashInImgSrc = encodedHtml . replace ( / s r c = " ( (?: (? ! " | \\ \? ) .) * ) / , 'src="$1/' ) ;
37
-
38
- describe ( '"encodeDirectives" method' , function ( ) {
39
- it ( 'converts media directive img src to directive URL' , function ( ) {
40
- expect ( obj . encodeDirectives ( decodedHtml ) ) . toEqual ( encodedHtml ) ;
41
- } ) ;
42
- } ) ;
27
+ describe ( 'wysiwygAdapter - encoding and decoding directives' , function ( ) {
28
+
29
+ /**
30
+ * Tests encoding and decoding directives
31
+ *
32
+ * @param {string } decodedHtml
33
+ * @param {string } encodedHtml
34
+ */
35
+ function runTests ( decodedHtml , encodedHtml ) {
36
+ var encodedHtmlWithForwardSlashInImgSrc = encodedHtml . replace ( / s r c = " ( (?: (? ! " | \\ \? ) .) * ) / , 'src="$1/' ) ;
43
37
44
- describe ( '"decodeDirectives" method' , function ( ) {
45
- it (
46
- 'converts directive URL img src without a trailing forward slash ' +
47
- 'to media url without a trailing forward slash' ,
48
- function ( ) {
49
- expect ( obj . decodeDirectives ( encodedHtml ) ) . toEqual ( decodedHtml ) ;
50
- }
51
- ) ;
52
-
53
- it ( 'converts directive URL img src with a trailing forward slash ' +
54
- 'to media url without a trailing forward slash' ,
55
- function ( ) {
56
- expect ( encodedHtmlWithForwardSlashInImgSrc ) . not . toEqual ( encodedHtml ) ;
57
- expect ( obj . decodeDirectives ( encodedHtmlWithForwardSlashInImgSrc ) ) . toEqual ( decodedHtml ) ;
58
- }
59
- ) ;
38
+ describe ( '"encodeDirectives" method' , function ( ) {
39
+ it ( 'converts media directive img src to directive URL' , function ( ) {
40
+ expect ( obj . encodeDirectives ( decodedHtml ) ) . toEqual ( encodedHtml ) ;
60
41
} ) ;
61
- }
62
-
63
- describe ( 'without SID in directive query string' , function ( ) {
64
- describe ( 'without secret key' , function ( ) {
65
- var decodedHtml = '<p>' +
66
- '<img src="{{media url="wysiwyg/banana.jpg"}}" alt="" width="612" height="459"></p>' ,
67
- encodedHtml = '<p>' +
68
- '<img src="http://example.com/admin/cms/wysiwyg/directive/___directive' +
69
- '/e3ttZWRpYSB1cmw9Ind5c2l3eWcvYmFuYW5hLmpwZyJ9fQ%2C%2C" alt="" width="612" height="459">' +
70
- '</p>' ;
71
-
72
- beforeEach ( function ( ) {
73
- obj . initialize ( 'id' , {
74
- 'directives_url' : 'http://example.com/admin/cms/wysiwyg/directive/'
75
- } ) ;
76
- } ) ;
77
-
78
- runTests ( decodedHtml , encodedHtml ) ;
42
+ } ) ;
43
+
44
+ describe ( '"decodeDirectives" method' , function ( ) {
45
+ it (
46
+ 'converts directive URL img src without a trailing forward slash ' +
47
+ 'to media url without a trailing forward slash' ,
48
+ function ( ) {
49
+ expect ( obj . decodeDirectives ( encodedHtml ) ) . toEqual ( decodedHtml ) ;
50
+ }
51
+ ) ;
52
+
53
+ it ( 'converts directive URL img src with a trailing forward slash ' +
54
+ 'to media url without a trailing forward slash' ,
55
+ function ( ) {
56
+ expect ( encodedHtmlWithForwardSlashInImgSrc ) . not . toEqual ( encodedHtml ) ;
57
+ expect ( obj . decodeDirectives ( encodedHtmlWithForwardSlashInImgSrc ) ) . toEqual ( decodedHtml ) ;
58
+ }
59
+ ) ;
60
+ } ) ;
61
+ }
62
+
63
+ describe ( 'without SID in directive query string without secret key' , function ( ) {
64
+ var decodedHtml = '<p>' +
65
+ '<img src="{{media url="wysiwyg/banana.jpg"}}" alt="" width="612" height="459"></p>' ,
66
+ encodedHtml = '<p>' +
67
+ '<img src="http://example.com/admin/cms/wysiwyg/directive/___directive' +
68
+ '/e3ttZWRpYSB1cmw9Ind5c2l3eWcvYmFuYW5hLmpwZyJ9fQ%2C%2C" alt="" width="612" height="459">' +
69
+ '</p>' ;
70
+
71
+ beforeEach ( function ( ) {
72
+ obj . initialize ( 'id' , {
73
+ 'directives_url' : 'http://example.com/admin/cms/wysiwyg/directive/'
79
74
} ) ;
75
+ } ) ;
80
76
81
- describe ( 'with secret key' , function ( ) {
82
- var decodedHtml = '<p>' +
83
- '<img src="{{media url="wysiwyg/banana.jpg"}}" alt="" width="612" height="459"></p>' ,
84
- encodedHtml = '<p>' +
85
- '<img src="http://example.com/admin/cms/wysiwyg/directive/___directive' +
86
- '/e3ttZWRpYSB1cmw9Ind5c2l3eWcvYmFuYW5hLmpwZyJ9fQ%2C%2C/key/' +
87
- '5552655d13a141099d27f5d5b0c58869423fd265687167da12cad2bb39aa9a58" ' +
88
- 'alt="" width="612" height="459">' +
89
- '</p>' ,
90
- directiveUrl = 'http://example.com/admin/cms/wysiwyg/directive/key/' +
91
- '5552655d13a141099d27f5d5b0c58869423fd265687167da12cad2bb39aa9a58/' ;
92
-
93
- beforeEach ( function ( ) {
94
- obj . initialize ( 'id' , {
95
- 'directives_url' : directiveUrl
96
- } ) ;
97
- } ) ;
98
-
99
- runTests ( decodedHtml , encodedHtml ) ;
77
+ runTests ( decodedHtml , encodedHtml ) ;
78
+ } ) ;
79
+
80
+ describe ( 'without SID in directive query string with secret key' , function ( ) {
81
+ var decodedHtml = '<p>' +
82
+ '<img src="{{media url="wysiwyg/banana.jpg"}}" alt="" width="612" height="459"></p>' ,
83
+ encodedHtml = '<p>' +
84
+ '<img src="http://example.com/admin/cms/wysiwyg/directive/___directive' +
85
+ '/e3ttZWRpYSB1cmw9Ind5c2l3eWcvYmFuYW5hLmpwZyJ9fQ%2C%2C/key/' +
86
+ '5552655d13a141099d27f5d5b0c58869423fd265687167da12cad2bb39aa9a58" ' +
87
+ 'alt="" width="612" height="459">' +
88
+ '</p>' ,
89
+ directiveUrl = 'http://example.com/admin/cms/wysiwyg/directive/key/' +
90
+ '5552655d13a141099d27f5d5b0c58869423fd265687167da12cad2bb39aa9a58/' ;
91
+
92
+ beforeEach ( function ( ) {
93
+ obj . initialize ( 'id' , {
94
+ 'directives_url' : directiveUrl
100
95
} ) ;
101
96
} ) ;
102
97
103
- describe ( 'with SID in directive query string' , function ( ) {
104
- describe ( 'without secret key' , function ( ) {
105
- var decodedHtml = '<p>' +
106
- '<img src="{{media url="wysiwyg/banana.jpg"}}" alt="" width="612" height="459"></p>' ,
107
- encodedHtml = '<p>' +
108
- '<img src="http://example.com/admin/cms/wysiwyg/directive/___directive' +
109
- '/e3ttZWRpYSB1cmw9Ind5c2l3eWcvYmFuYW5hLmpwZyJ9fQ%2C%2C?SID=something" ' +
110
- 'alt="" width="612" height="459">' +
111
- '</p>' ,
112
- directiveUrl = 'http://example.com/admin/cms/wysiwyg/directive?SID=something' ;
113
-
114
- beforeEach ( function ( ) {
115
- obj . initialize ( 'id' , {
116
- 'directives_url' : directiveUrl
117
- } ) ;
118
- } ) ;
119
-
120
- runTests ( decodedHtml , encodedHtml ) ;
98
+ runTests ( decodedHtml , encodedHtml ) ;
99
+ } ) ;
100
+
101
+ describe ( 'with SID in directive query string without secret key' , function ( ) {
102
+ var decodedHtml = '<p>' +
103
+ '<img src="{{media url="wysiwyg/banana.jpg"}}" alt="" width="612" height="459"></p>' ,
104
+ encodedHtml = '<p>' +
105
+ '<img src="http://example.com/admin/cms/wysiwyg/directive/___directive' +
106
+ '/e3ttZWRpYSB1cmw9Ind5c2l3eWcvYmFuYW5hLmpwZyJ9fQ%2C%2C?SID=something" ' +
107
+ 'alt="" width="612" height="459">' +
108
+ '</p>' ,
109
+ directiveUrl = 'http://example.com/admin/cms/wysiwyg/directive?SID=something' ;
110
+
111
+ beforeEach ( function ( ) {
112
+ obj . initialize ( 'id' , {
113
+ 'directives_url' : directiveUrl
121
114
} ) ;
115
+ } ) ;
116
+
117
+ runTests ( decodedHtml , encodedHtml ) ;
118
+ } ) ;
122
119
123
- describe ( 'with secret key' , function ( ) {
124
- var decodedHtml = '<p>' +
125
- '<img src="{{media url="wysiwyg/banana.jpg"}}" alt="" width="612" height="459"></p>' ,
126
- encodedHtml = '<p>' +
127
- '<img src="http://example.com/admin/cms/wysiwyg/directive/___directive' +
128
- '/e3ttZWRpYSB1cmw9Ind5c2l3eWcvYmFuYW5hLmpwZyJ9fQ%2C%2C/key/' +
129
- '5552655d13a141099d27f5d5b0c58869423fd265687167da12cad2bb39aa9a58?SID=something" ' +
130
- 'alt="" width="612" height="459">' +
131
- '</p>' ,
132
- directiveUrl = 'http://example.com/admin/cms/wysiwyg/directive/key/' +
133
- '5552655d13a141099d27f5d5b0c58869423fd265687167da12cad2bb39aa9a58?SID=something' ;
134
-
135
- beforeEach ( function ( ) {
136
- obj . initialize ( 'id' , {
137
- 'directives_url' : directiveUrl
138
- } ) ;
139
- } ) ;
140
-
141
- runTests ( decodedHtml , encodedHtml ) ;
120
+ describe ( 'with SID in directive query string with secret key' , function ( ) {
121
+ var decodedHtml = '<p>' +
122
+ '<img src="{{media url="wysiwyg/banana.jpg"}}" alt="" width="612" height="459"></p>' ,
123
+ encodedHtml = '<p>' +
124
+ '<img src="http://example.com/admin/cms/wysiwyg/directive/___directive' +
125
+ '/e3ttZWRpYSB1cmw9Ind5c2l3eWcvYmFuYW5hLmpwZyJ9fQ%2C%2C/key/' +
126
+ '5552655d13a141099d27f5d5b0c58869423fd265687167da12cad2bb39aa9a58?SID=something" ' +
127
+ 'alt="" width="612" height="459">' +
128
+ '</p>' ,
129
+ directiveUrl = 'http://example.com/admin/cms/wysiwyg/directive/key/' +
130
+ '5552655d13a141099d27f5d5b0c58869423fd265687167da12cad2bb39aa9a58?SID=something' ;
131
+
132
+ beforeEach ( function ( ) {
133
+ obj . initialize ( 'id' , {
134
+ 'directives_url' : directiveUrl
142
135
} ) ;
143
136
} ) ;
137
+
138
+ runTests ( decodedHtml , encodedHtml ) ;
144
139
} ) ;
145
140
} ) ;
146
141
} ) ;
0 commit comments