Skip to content

Commit f5f0bff

Browse files
committed
MAGETWO-88232: Images from WYSIWYG (Text, Slider) do not show up on admin preview nor storefront
Add wysiwygAdapter.test.js
1 parent 4f9e106 commit f5f0bff

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
/* eslint-disable max-nested-callbacks */
7+
define([
8+
'wysiwygAdapter'
9+
], function (wysiwygAdapter) {
10+
'use strict';
11+
12+
var obj;
13+
14+
beforeEach(function () {
15+
var Constr = function () {};
16+
17+
Constr.prototype = wysiwygAdapter;
18+
19+
obj = new Constr();
20+
obj.initialize('id', {
21+
'directives_url': 'http://example.com/admin/cms/wysiwyg/directive/'
22+
});
23+
});
24+
25+
describe('wysiwygAdapter', function () {
26+
var decodedHtml = '<p>' +
27+
'<img src="{{media url=&quot;wysiwyg/banana.jpg&quot;}}" alt="" width="612" height="459"></p>',
28+
encodedHtml = '<p>' +
29+
'<img src="http://example.com/admin/cms/wysiwyg/directive/' +
30+
'___directive/e3ttZWRpYSB1cmw9Ind5c2l3eWcvYmFuYW5hLmpwZyJ9fQ%2C%2C" alt="" width="612" height="459">' +
31+
'</p>',
32+
encodedHtmlWithForwardSlashInImgSrc = encodedHtml.replace('%2C%2C', '%2C%2C/');
33+
34+
describe('"encodeDirectives" method', function () {
35+
it('converts media directive img src to directive URL', function () {
36+
expect(obj.encodeDirectives(decodedHtml)).toEqual(encodedHtml);
37+
});
38+
});
39+
40+
describe('"decodeDirectives" method', function () {
41+
it(
42+
'converts directive URL img src without a trailing forward slash ' +
43+
'to media url without a trailing forward slash',
44+
function () {
45+
expect(obj.decodeDirectives(encodedHtml)).toEqual(decodedHtml);
46+
}
47+
);
48+
49+
it('converts directive URL img src with a trailing forward slash ' +
50+
'to media url without a trailing forward slash',
51+
function () {
52+
expect(obj.decodeDirectives(encodedHtmlWithForwardSlashInImgSrc)).toEqual(decodedHtml);
53+
}
54+
);
55+
});
56+
});
57+
});

0 commit comments

Comments
 (0)