From 6799e03d2c6db3326786ac7a1f5b91b5e4257ded Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Wed, 5 Jun 2019 10:59:00 +0200 Subject: [PATCH] Refactor tests --- package.json | 3 +- test.js | 214 +++++++++++++++++++++ test/fixture/emoji.json | 378 ------------------------------------- test/fixture/emoticon.json | 290 ---------------------------- test/fixture/gemoji.json | 290 ---------------------------- test/index.js | 111 ----------- 6 files changed, 216 insertions(+), 1070 deletions(-) create mode 100644 test.js delete mode 100644 test/fixture/emoji.json delete mode 100644 test/fixture/emoticon.json delete mode 100644 test/fixture/gemoji.json delete mode 100644 test/index.js diff --git a/package.json b/package.json index a8a860c..383ba71 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "retext": "^6.0.0", "tape": "^4.0.0", "tinyify": "^2.0.0", + "unist-builder": "^1.0.4", "xo": "^0.24.0" }, "scripts": { @@ -46,7 +47,7 @@ "build-mangle": "browserify . -s retextEmoji -p tinyify > retext-emoji.min.js", "build": "npm run build-bundle && npm run build-mangle", "test-api": "node test", - "test-coverage": "nyc --reporter lcov tape test/index.js", + "test-coverage": "nyc --reporter lcov tape test.js", "test": "npm run format && npm run build && npm run test-coverage" }, "nyc": { diff --git a/test.js b/test.js new file mode 100644 index 0000000..6c97c3d --- /dev/null +++ b/test.js @@ -0,0 +1,214 @@ +'use strict' + +var test = require('tape') +var retext = require('retext') +var visit = require('unist-util-visit') +var u = require('unist-builder') +var emoji = require('.') + +test('emoji', function(t) { + var processor = retext().use(emoji) + var fixture = 'It’s raining 🐱s and :dog:s. Now :3.' + + t.throws( + function() { + retext() + .use(emoji, {convert: false}) + .freeze() + }, + /Illegal invocation: `false` is not a valid value/, + 'should throw when given invalid `convert`' + ) + + t.deepEqual( + processor.runSync(processor.parse('This makes me feel :).')), + u('RootNode', {position: p(1, 1, 0, 1, 23, 22)}, [ + u('ParagraphNode', {position: p(1, 1, 0, 1, 23, 22)}, [ + u('SentenceNode', {position: p(1, 1, 0, 1, 23, 22)}, [ + u('WordNode', {position: p(1, 1, 0, 1, 5, 4)}, [ + u('TextNode', {position: p(1, 1, 0, 1, 5, 4)}, 'This') + ]), + u('WhiteSpaceNode', {position: p(1, 5, 4, 1, 6, 5)}, ' '), + u('WordNode', {position: p(1, 6, 5, 1, 11, 10)}, [ + u('TextNode', {position: p(1, 6, 5, 1, 11, 10)}, 'makes') + ]), + u('WhiteSpaceNode', {position: p(1, 11, 10, 1, 12, 11)}, ' '), + u('WordNode', {position: p(1, 12, 11, 1, 14, 13)}, [ + u('TextNode', {position: p(1, 12, 11, 1, 14, 13)}, 'me') + ]), + u('WhiteSpaceNode', {position: p(1, 14, 13, 1, 15, 14)}, ' '), + u('WordNode', {position: p(1, 15, 14, 1, 19, 18)}, [ + u('TextNode', {position: p(1, 15, 14, 1, 19, 18)}, 'feel') + ]), + u('WhiteSpaceNode', {position: p(1, 19, 18, 1, 20, 19)}, ' '), + u( + 'EmoticonNode', + { + position: p(1, 20, 19, 1, 22, 21), + data: { + names: ['smiley'], + description: 'smiling face with open mouth', + tags: ['happy', 'joy', 'haha'] + } + }, + ':)' + ), + u('PunctuationNode', {position: p(1, 22, 21, 1, 23, 22)}, '.') + ]) + ]) + ]), + 'should classify emoticons' + ) + + t.deepEqual( + processor.runSync(processor.parse('This makes me feel :sob:.')), + u('RootNode', {position: p(1, 1, 0, 1, 26, 25)}, [ + u('ParagraphNode', {position: p(1, 1, 0, 1, 26, 25)}, [ + u('SentenceNode', {position: p(1, 1, 0, 1, 26, 25)}, [ + u('WordNode', {position: p(1, 1, 0, 1, 5, 4)}, [ + u('TextNode', {position: p(1, 1, 0, 1, 5, 4)}, 'This') + ]), + u('WhiteSpaceNode', {position: p(1, 5, 4, 1, 6, 5)}, ' '), + u('WordNode', {position: p(1, 6, 5, 1, 11, 10)}, [ + u('TextNode', {position: p(1, 6, 5, 1, 11, 10)}, 'makes') + ]), + u('WhiteSpaceNode', {position: p(1, 11, 10, 1, 12, 11)}, ' '), + u('WordNode', {position: p(1, 12, 11, 1, 14, 13)}, [ + u('TextNode', {position: p(1, 12, 11, 1, 14, 13)}, 'me') + ]), + u('WhiteSpaceNode', {position: p(1, 14, 13, 1, 15, 14)}, ' '), + u('WordNode', {position: p(1, 15, 14, 1, 19, 18)}, [ + u('TextNode', {position: p(1, 15, 14, 1, 19, 18)}, 'feel') + ]), + u('WhiteSpaceNode', {position: p(1, 19, 18, 1, 20, 19)}, ' '), + u( + 'EmoticonNode', + { + position: p(1, 20, 19, 1, 25, 24), + data: { + names: ['sob'], + description: 'loudly crying face', + tags: ['sad', 'cry', 'bawling'] + } + }, + ':sob:' + ), + u('PunctuationNode', {position: p(1, 25, 24, 1, 26, 25)}, '.') + ]) + ]) + ]), + 'should classify gemoji' + ) + + t.deepEqual( + processor.runSync(processor.parse('It’s raining 🐱s and 🐶s.')), + u('RootNode', {position: p(1, 1, 0, 1, 26, 25)}, [ + u('ParagraphNode', {position: p(1, 1, 0, 1, 26, 25)}, [ + u('SentenceNode', {position: p(1, 1, 0, 1, 26, 25)}, [ + u('WordNode', {position: p(1, 1, 0, 1, 5, 4)}, [ + u('TextNode', {position: p(1, 1, 0, 1, 3, 2)}, 'It'), + u('PunctuationNode', {position: p(1, 3, 2, 1, 4, 3)}, '’'), + u('TextNode', {position: p(1, 4, 3, 1, 5, 4)}, 's') + ]), + u('WhiteSpaceNode', {position: p(1, 5, 4, 1, 6, 5)}, ' '), + u('WordNode', {position: p(1, 6, 5, 1, 13, 12)}, [ + u('TextNode', {position: p(1, 6, 5, 1, 13, 12)}, 'raining') + ]), + u('WhiteSpaceNode', {position: p(1, 13, 12, 1, 14, 13)}, ' '), + u( + 'EmoticonNode', + { + position: p(1, 14, 13, 1, 16, 15), + data: {names: ['cat'], description: 'cat face', tags: ['pet']} + }, + '🐱' + ), + u('WordNode', {position: p(1, 16, 15, 1, 17, 16)}, [ + u('TextNode', {position: p(1, 16, 15, 1, 17, 16)}, 's') + ]), + u('WhiteSpaceNode', {position: p(1, 17, 16, 1, 18, 17)}, ' '), + u('WordNode', {position: p(1, 18, 17, 1, 21, 20)}, [ + u('TextNode', {position: p(1, 18, 17, 1, 21, 20)}, 'and') + ]), + u('WhiteSpaceNode', {position: p(1, 21, 20, 1, 22, 21)}, ' '), + u( + 'EmoticonNode', + { + position: p(1, 22, 21, 1, 24, 23), + data: {names: ['dog'], description: 'dog face', tags: ['pet']} + }, + '🐶' + ), + u('WordNode', {position: p(1, 24, 23, 1, 26, 25)}, [ + u('TextNode', {position: p(1, 24, 23, 1, 25, 24)}, 's'), + u('PunctuationNode', {position: p(1, 25, 24, 1, 26, 25)}, '.') + ]) + ]) + ]) + ]), + 'should classify emoji' + ) + + retext() + .use(emoji) + .process(fixture, function(err, file) { + t.deepEqual( + [err, String(file)], + [null, fixture], + 'should not transform without `convert`' + ) + }) + + retext() + .use(emoji, {convert: 'encode'}) + .process(fixture, function(err, file) { + t.deepEqual( + [err, String(file)], + [null, 'It’s raining 🐱s and 🐶s. Now 👨.'], + 'should encode' + ) + }) + + retext() + .use(emoji, {convert: 'decode'}) + .process(fixture, function(err, file) { + t.deepEqual( + [err, String(file)], + [null, 'It’s raining :cat:s and :dog:s. Now :man:.'], + 'should decode' + ) + }) + + retext() + .use(data) + .use(emoji) + .process(fixture, function(err, file) { + t.deepEqual( + [err, String(file)], + [null, fixture], + 'should not overwrite existing data' + ) + }) + + function data() { + return transformer + function transformer(node) { + visit(node, visitor) + } + + function visitor(child) { + child.data = {} + } + } + + t.end() +}) + +// eslint-disable-next-line max-params +function p(sl, sc, so, el, ec, eo) { + return {start: point(sl, sc, so), end: point(el, ec, eo)} +} + +function point(l, c, o) { + return {line: l, column: c, offset: o} +} diff --git a/test/fixture/emoji.json b/test/fixture/emoji.json deleted file mode 100644 index 2ba28d3..0000000 --- a/test/fixture/emoji.json +++ /dev/null @@ -1,378 +0,0 @@ -{ - "type": "RootNode", - "children": [ - { - "type": "ParagraphNode", - "children": [ - { - "type": "SentenceNode", - "children": [ - { - "type": "WordNode", - "children": [ - { - "type": "TextNode", - "value": "It", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 3, - "offset": 2 - } - } - }, - { - "type": "PunctuationNode", - "value": "’", - "position": { - "start": { - "line": 1, - "column": 3, - "offset": 2 - }, - "end": { - "line": 1, - "column": 4, - "offset": 3 - } - } - }, - { - "type": "TextNode", - "value": "s", - "position": { - "start": { - "line": 1, - "column": 4, - "offset": 3 - }, - "end": { - "line": 1, - "column": 5, - "offset": 4 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 5, - "offset": 4 - } - } - }, - { - "type": "WhiteSpaceNode", - "value": " ", - "position": { - "start": { - "line": 1, - "column": 5, - "offset": 4 - }, - "end": { - "line": 1, - "column": 6, - "offset": 5 - } - } - }, - { - "type": "WordNode", - "children": [ - { - "type": "TextNode", - "value": "raining", - "position": { - "start": { - "line": 1, - "column": 6, - "offset": 5 - }, - "end": { - "line": 1, - "column": 13, - "offset": 12 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 6, - "offset": 5 - }, - "end": { - "line": 1, - "column": 13, - "offset": 12 - } - } - }, - { - "type": "WhiteSpaceNode", - "value": " ", - "position": { - "start": { - "line": 1, - "column": 13, - "offset": 12 - }, - "end": { - "line": 1, - "column": 14, - "offset": 13 - } - } - }, - { - "type": "EmoticonNode", - "value": "🐱", - "position": { - "start": { - "line": 1, - "column": 14, - "offset": 13 - }, - "end": { - "line": 1, - "column": 16, - "offset": 15 - } - }, - "data": { - "names": [ - "cat" - ], - "description": "cat face", - "tags": [ - "pet" - ] - } - }, - { - "type": "WordNode", - "children": [ - { - "type": "TextNode", - "value": "s", - "position": { - "start": { - "line": 1, - "column": 16, - "offset": 15 - }, - "end": { - "line": 1, - "column": 17, - "offset": 16 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 16, - "offset": 15 - }, - "end": { - "line": 1, - "column": 17, - "offset": 16 - } - } - }, - { - "type": "WhiteSpaceNode", - "value": " ", - "position": { - "start": { - "line": 1, - "column": 17, - "offset": 16 - }, - "end": { - "line": 1, - "column": 18, - "offset": 17 - } - } - }, - { - "type": "WordNode", - "children": [ - { - "type": "TextNode", - "value": "and", - "position": { - "start": { - "line": 1, - "column": 18, - "offset": 17 - }, - "end": { - "line": 1, - "column": 21, - "offset": 20 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 18, - "offset": 17 - }, - "end": { - "line": 1, - "column": 21, - "offset": 20 - } - } - }, - { - "type": "WhiteSpaceNode", - "value": " ", - "position": { - "start": { - "line": 1, - "column": 21, - "offset": 20 - }, - "end": { - "line": 1, - "column": 22, - "offset": 21 - } - } - }, - { - "type": "EmoticonNode", - "value": "🐶", - "position": { - "start": { - "line": 1, - "column": 22, - "offset": 21 - }, - "end": { - "line": 1, - "column": 24, - "offset": 23 - } - }, - "data": { - "names": [ - "dog" - ], - "description": "dog face", - "tags": [ - "pet" - ] - } - }, - { - "type": "WordNode", - "children": [ - { - "type": "TextNode", - "value": "s", - "position": { - "start": { - "line": 1, - "column": 24, - "offset": 23 - }, - "end": { - "line": 1, - "column": 25, - "offset": 24 - } - } - }, - { - "type": "PunctuationNode", - "value": ".", - "position": { - "start": { - "line": 1, - "column": 25, - "offset": 24 - }, - "end": { - "line": 1, - "column": 26, - "offset": 25 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 24, - "offset": 23 - }, - "end": { - "line": 1, - "column": 26, - "offset": 25 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 26, - "offset": 25 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 26, - "offset": 25 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 26, - "offset": 25 - } - } -} diff --git a/test/fixture/emoticon.json b/test/fixture/emoticon.json deleted file mode 100644 index 0069e4d..0000000 --- a/test/fixture/emoticon.json +++ /dev/null @@ -1,290 +0,0 @@ -{ - "type": "RootNode", - "children": [ - { - "type": "ParagraphNode", - "children": [ - { - "type": "SentenceNode", - "children": [ - { - "type": "WordNode", - "children": [ - { - "type": "TextNode", - "value": "This", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 5, - "offset": 4 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 5, - "offset": 4 - } - } - }, - { - "type": "WhiteSpaceNode", - "value": " ", - "position": { - "start": { - "line": 1, - "column": 5, - "offset": 4 - }, - "end": { - "line": 1, - "column": 6, - "offset": 5 - } - } - }, - { - "type": "WordNode", - "children": [ - { - "type": "TextNode", - "value": "makes", - "position": { - "start": { - "line": 1, - "column": 6, - "offset": 5 - }, - "end": { - "line": 1, - "column": 11, - "offset": 10 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 6, - "offset": 5 - }, - "end": { - "line": 1, - "column": 11, - "offset": 10 - } - } - }, - { - "type": "WhiteSpaceNode", - "value": " ", - "position": { - "start": { - "line": 1, - "column": 11, - "offset": 10 - }, - "end": { - "line": 1, - "column": 12, - "offset": 11 - } - } - }, - { - "type": "WordNode", - "children": [ - { - "type": "TextNode", - "value": "me", - "position": { - "start": { - "line": 1, - "column": 12, - "offset": 11 - }, - "end": { - "line": 1, - "column": 14, - "offset": 13 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 12, - "offset": 11 - }, - "end": { - "line": 1, - "column": 14, - "offset": 13 - } - } - }, - { - "type": "WhiteSpaceNode", - "value": " ", - "position": { - "start": { - "line": 1, - "column": 14, - "offset": 13 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - } - } - }, - { - "type": "WordNode", - "children": [ - { - "type": "TextNode", - "value": "feel", - "position": { - "start": { - "line": 1, - "column": 15, - "offset": 14 - }, - "end": { - "line": 1, - "column": 19, - "offset": 18 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 15, - "offset": 14 - }, - "end": { - "line": 1, - "column": 19, - "offset": 18 - } - } - }, - { - "type": "WhiteSpaceNode", - "value": " ", - "position": { - "start": { - "line": 1, - "column": 19, - "offset": 18 - }, - "end": { - "line": 1, - "column": 20, - "offset": 19 - } - } - }, - { - "type": "EmoticonNode", - "value": ":)", - "position": { - "start": { - "line": 1, - "column": 20, - "offset": 19 - }, - "end": { - "line": 1, - "column": 22, - "offset": 21 - } - }, - "data": { - "names": [ - "smiley" - ], - "description": "smiling face with open mouth", - "tags": [ - "happy", - "joy", - "haha" - ] - } - }, - { - "type": "PunctuationNode", - "value": ".", - "position": { - "start": { - "line": 1, - "column": 22, - "offset": 21 - }, - "end": { - "line": 1, - "column": 23, - "offset": 22 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 23, - "offset": 22 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 23, - "offset": 22 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 23, - "offset": 22 - } - } -} diff --git a/test/fixture/gemoji.json b/test/fixture/gemoji.json deleted file mode 100644 index 1825df0..0000000 --- a/test/fixture/gemoji.json +++ /dev/null @@ -1,290 +0,0 @@ -{ - "type": "RootNode", - "children": [ - { - "type": "ParagraphNode", - "children": [ - { - "type": "SentenceNode", - "children": [ - { - "type": "WordNode", - "children": [ - { - "type": "TextNode", - "value": "This", - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 5, - "offset": 4 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 5, - "offset": 4 - } - } - }, - { - "type": "WhiteSpaceNode", - "value": " ", - "position": { - "start": { - "line": 1, - "column": 5, - "offset": 4 - }, - "end": { - "line": 1, - "column": 6, - "offset": 5 - } - } - }, - { - "type": "WordNode", - "children": [ - { - "type": "TextNode", - "value": "makes", - "position": { - "start": { - "line": 1, - "column": 6, - "offset": 5 - }, - "end": { - "line": 1, - "column": 11, - "offset": 10 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 6, - "offset": 5 - }, - "end": { - "line": 1, - "column": 11, - "offset": 10 - } - } - }, - { - "type": "WhiteSpaceNode", - "value": " ", - "position": { - "start": { - "line": 1, - "column": 11, - "offset": 10 - }, - "end": { - "line": 1, - "column": 12, - "offset": 11 - } - } - }, - { - "type": "WordNode", - "children": [ - { - "type": "TextNode", - "value": "me", - "position": { - "start": { - "line": 1, - "column": 12, - "offset": 11 - }, - "end": { - "line": 1, - "column": 14, - "offset": 13 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 12, - "offset": 11 - }, - "end": { - "line": 1, - "column": 14, - "offset": 13 - } - } - }, - { - "type": "WhiteSpaceNode", - "value": " ", - "position": { - "start": { - "line": 1, - "column": 14, - "offset": 13 - }, - "end": { - "line": 1, - "column": 15, - "offset": 14 - } - } - }, - { - "type": "WordNode", - "children": [ - { - "type": "TextNode", - "value": "feel", - "position": { - "start": { - "line": 1, - "column": 15, - "offset": 14 - }, - "end": { - "line": 1, - "column": 19, - "offset": 18 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 15, - "offset": 14 - }, - "end": { - "line": 1, - "column": 19, - "offset": 18 - } - } - }, - { - "type": "WhiteSpaceNode", - "value": " ", - "position": { - "start": { - "line": 1, - "column": 19, - "offset": 18 - }, - "end": { - "line": 1, - "column": 20, - "offset": 19 - } - } - }, - { - "type": "EmoticonNode", - "value": ":sob:", - "position": { - "start": { - "line": 1, - "column": 20, - "offset": 19 - }, - "end": { - "line": 1, - "column": 25, - "offset": 24 - } - }, - "data": { - "names": [ - "sob" - ], - "description": "loudly crying face", - "tags": [ - "sad", - "cry", - "bawling" - ] - } - }, - { - "type": "PunctuationNode", - "value": ".", - "position": { - "start": { - "line": 1, - "column": 25, - "offset": 24 - }, - "end": { - "line": 1, - "column": 26, - "offset": 25 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 26, - "offset": 25 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 26, - "offset": 25 - } - } - } - ], - "position": { - "start": { - "line": 1, - "column": 1, - "offset": 0 - }, - "end": { - "line": 1, - "column": 26, - "offset": 25 - } - } -} diff --git a/test/index.js b/test/index.js deleted file mode 100644 index f687699..0000000 --- a/test/index.js +++ /dev/null @@ -1,111 +0,0 @@ -'use strict' - -var test = require('tape') -var retext = require('retext') -var visit = require('unist-util-visit') -var emoji = require('..') - -var emoticon = require('./fixture/emoticon') -var emojis = require('./fixture/emoji') -var gemoji = require('./fixture/gemoji') - -test('toString()', function(t) { - t.test('should throw when given invalid `convert`', function(st) { - st.throws(function() { - retext() - .use(emoji, {convert: false}) - .freeze() - }, /Illegal invocation: `false` is not a valid value/) - - st.end() - }) - - t.test('should classify emoticons', function(st) { - var processor = retext().use(emoji) - var tree = processor.parse('This makes me feel :).') - - processor.run(tree) - - st.deepEqual(tree, emoticon) - - st.end() - }) - - t.test('should classify gemoji', function(st) { - var processor = retext().use(emoji) - var tree = processor.parse('This makes me feel :sob:.') - - processor.run(tree) - - st.deepEqual(tree, gemoji) - - st.end() - }) - - t.test('should classify emoji', function(st) { - var processor = retext().use(emoji) - var tree = processor.parse('It’s raining 🐱s and 🐶s.') - - processor.run(tree) - - st.deepEqual(tree, emojis) - - st.end() - }) - - t.test('should not transform without `convert`', function(st) { - var processor = retext().use(emoji) - var input = 'It’s raining 🐱s and :dog:s. Now :3.' - var output = processor.processSync(input).toString() - - st.equal(output, input) - - st.end() - }) - - t.test('should encode', function(st) { - var processor = retext().use(emoji, {convert: 'encode'}) - - st.equal( - processor.processSync('It’s raining 🐱s and :dog:s. Now :3.').toString(), - 'It’s raining 🐱s and 🐶s. Now 👨.' - ) - - st.end() - }) - - t.test('should decode', function(st) { - var processor = retext().use(emoji, {convert: 'decode'}) - - st.equal( - processor.processSync('It’s raining 🐱s and :dog:s. Now :3.').toString(), - 'It’s raining :cat:s and :dog:s. Now :man:.' - ) - - st.end() - }) - - t.test('should not overwrite existing data', function(st) { - var processor = retext() - .use(function() { - return transformer - function transformer(node) { - visit(node, visitor) - } - - function visitor(child) { - child.data = {} - } - }) - .use(emoji) - - st.equal( - processor.processSync('It’s raining 🐱s and :dog:s. Now :3.').toString(), - 'It’s raining 🐱s and :dog:s. Now :3.' - ) - - st.end() - }) - - t.end() -})