Skip to content

Commit 93e0d36

Browse files
author
Rose Robertson
committed
Add test for surrogate pair bug with trailing links
As outlined in this issue: Rosey#122
1 parent 9be3aa7 commit 93e0d36

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

test/draft-to-markdown.spec.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,31 @@ describe('draftToMarkdown', function () {
218218
expect(markdown).toEqual('This is a test of [a link](https://google.com)\n\nAnd [perhaps](https://facebook.github.io/draft-js/) we should test once more.');
219219
});
220220

221+
it('renders links with surrogate pairs (e.g. some emoji) correctly', function () {
222+
/* eslint-disable */
223+
var rawObject = {
224+
"blocks": [{
225+
"key": "eubc2",
226+
"text": "🙋 link link",
227+
"type": "unstyled",
228+
"depth": 0,
229+
"inlineStyleRanges": [],
230+
"entityRanges": [{"offset": 2, "length": 4, "key": 0}, {"offset": 7, "length": 4, "key": 1}],
231+
"data": {}
232+
}],
233+
"entityMap": {
234+
"0": {
235+
"type": "LINK",
236+
"mutability": "MUTABLE",
237+
"data": {"url": "https://link.com", "href": "https://link.com"}
238+
}, "1": {"type": "LINK", "mutability": "MUTABLE", "data": {"url": "https://link.com"}}
239+
}
240+
}
241+
/* eslint-enable */
242+
var markdown = draftToMarkdown(rawObject);
243+
expect(markdown).toEqual('🙋 [link](https://link.com) [link](https://link.com)');
244+
});
245+
221246
it('renders links with a HREF correctly', function () {
222247
/* eslint-disable */
223248
var rawObject = {"entityMap":{"0":{"type":"LINK","mutability":"MUTABLE","data":{"href":"https://google.com"}},"1":{"type":"LINK","mutability":"MUTABLE","data":{"href":"https://facebook.github.io/draft-js/"}}},"blocks":[{"key":"58spd","text":"This is a test of a link","type":"unstyled","depth":0,"inlineStyleRanges":[],"entityRanges":[{"offset":18,"length":6,"key":0}],"data":{}},{"key":"9ln6g","text":"","type":"unstyled","depth":0,"inlineStyleRanges":[],"entityRanges":[],"data":{}},{"key":"3euar","text":"And perhaps we should test once more.","type":"unstyled","depth":0,"inlineStyleRanges":[],"entityRanges":[{"offset":4,"length":7,"key":1}],"data":{}}]};

0 commit comments

Comments
 (0)