aboutsummaryrefslogtreecommitdiff
path: root/test/unit/specs/services/html_converter/utility.spec.js
diff options
context:
space:
mode:
authorIlja <ilja@ilja.space>2022-02-26 02:08:13 +0100
committerIlja <ilja@ilja.space>2022-02-26 02:08:13 +0100
commitd0c4ad22cd5a93f69c689f3c8c75546c35861740 (patch)
tree15b535925b4ce0ea851e27ace32afde9db6a29c1 /test/unit/specs/services/html_converter/utility.spec.js
parent819b76026101ddc0363118f240049a0019ebb4d6 (diff)
parent0300db6c6356c536694a9fcbb32a52abc81c52d5 (diff)
Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma-fe into feat/report-notification
Diffstat (limited to 'test/unit/specs/services/html_converter/utility.spec.js')
-rw-r--r--test/unit/specs/services/html_converter/utility.spec.js37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/unit/specs/services/html_converter/utility.spec.js b/test/unit/specs/services/html_converter/utility.spec.js
new file mode 100644
index 00000000..cf6fd99b
--- /dev/null
+++ b/test/unit/specs/services/html_converter/utility.spec.js
@@ -0,0 +1,37 @@
+import { processTextForEmoji, getAttrs } from 'src/services/html_converter/utility.service.js'
+
+describe('html_converter utility', () => {
+ describe('processTextForEmoji', () => {
+ it('processes all emoji in text', () => {
+ const input = 'Hello from finland! :lol: We have best water! :lmao:'
+ const emojis = [
+ { shortcode: 'lol', src: 'LOL' },
+ { shortcode: 'lmao', src: 'LMAO' }
+ ]
+ const processor = ({ shortcode, src }) => ({ shortcode, src })
+ expect(processTextForEmoji(input, emojis, processor)).to.eql([
+ 'Hello from finland! ',
+ { shortcode: 'lol', src: 'LOL' },
+ ' We have best water! ',
+ { shortcode: 'lmao', src: 'LMAO' }
+ ])
+ })
+ it('leaves text as is', () => {
+ const input = 'Number one: that\'s terror'
+ const emojis = []
+ const processor = ({ shortcode, src }) => ({ shortcode, src })
+ expect(processTextForEmoji(input, emojis, processor)).to.eql([
+ 'Number one: that\'s terror'
+ ])
+ })
+ })
+
+ describe('getAttrs', () => {
+ it('extracts arguments from tag', () => {
+ const input = '<img src="boop" cool ebin=\'true\'>'
+ const output = { src: 'boop', cool: true, ebin: 'true' }
+
+ expect(getAttrs(input)).to.eql(output)
+ })
+ })
+})