From 1923ed84d451011df42e47a85060cc754a011e27 Mon Sep 17 00:00:00 2001
From: Henry Jameson <me@hjkos.com>
Date: Mon, 7 Jun 2021 16:15:32 +0300
Subject: [PATCH] more tests

---
 .../mini_post_html_processor.spec.js          | 35 ++++++++++++-------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/test/unit/specs/services/tiny_post_html_processor/mini_post_html_processor.spec.js b/test/unit/specs/services/tiny_post_html_processor/mini_post_html_processor.spec.js
index c4e3f688..b42f5f35 100644
--- a/test/unit/specs/services/tiny_post_html_processor/mini_post_html_processor.spec.js
+++ b/test/unit/specs/services/tiny_post_html_processor/mini_post_html_processor.spec.js
@@ -1,10 +1,10 @@
-import { convertHtml, processTextForEmoji } from 'src/services/mini_html_converter/mini_html_converter.service.js'
+import { convertHtml, processTextForEmoji, getAttrs } from 'src/services/mini_html_converter/mini_html_converter.service.js'
 
 describe('MiniHtmlConverter', () => {
   describe('convertHtml', () => {
     it('converts html into a tree structure', () => {
-      const inputOutput = '1 <p>2</p> <b>3<img src="a">4</b>5'
-      expect(convertHtml(inputOutput)).to.eql([
+      const input = '1 <p>2</p> <b>3<img src="a">4</b>5'
+      expect(convertHtml(input)).to.eql([
         '1 ',
         [
           '<p>',
@@ -25,8 +25,8 @@ describe('MiniHtmlConverter', () => {
       ])
     })
     it('converts html to tree while preserving tag formatting', () => {
-      const inputOutput = '1 <p >2</p><b >3<img   src="a">4</b>5'
-      expect(convertHtml(inputOutput)).to.eql([
+      const input = '1 <p >2</p><b >3<img   src="a">4</b>5'
+      expect(convertHtml(input)).to.eql([
         '1 ',
         [
           '<p >',
@@ -46,8 +46,8 @@ describe('MiniHtmlConverter', () => {
       ])
     })
     it('converts semi-broken html', () => {
-      const inputOutput = '1 <br> 2 <p> 42'
-      expect(convertHtml(inputOutput)).to.eql([
+      const input = '1 <br> 2 <p> 42'
+      expect(convertHtml(input)).to.eql([
         '1 ',
         ['<br>'],
         ' 2 ',
@@ -58,8 +58,8 @@ describe('MiniHtmlConverter', () => {
       ])
     })
     it('realistic case 1', () => {
-      const inputOutput = '<p><span class="h-card"><a class="u-url mention" data-user="9wRC6T2ZZiKWJ0vUi8" href="https://cawfee.club/users/benis" rel="ugc">@<span>benis</span></a></span> <span class="h-card"><a class="u-url mention" data-user="194" href="https://shigusegubu.club/users/hj" rel="ugc">@<span>hj</span></a></span> nice</p>'
-      expect(convertHtml(inputOutput)).to.eql([
+      const input = '<p><span class="h-card"><a class="u-url mention" data-user="9wRC6T2ZZiKWJ0vUi8" href="https://cawfee.club/users/benis" rel="ugc">@<span>benis</span></a></span> <span class="h-card"><a class="u-url mention" data-user="194" href="https://shigusegubu.club/users/hj" rel="ugc">@<span>hj</span></a></span> nice</p>'
+      expect(convertHtml(input)).to.eql([
         [
           '<p>',
           [
@@ -129,15 +129,16 @@ describe('MiniHtmlConverter', () => {
       ])
     })
   })
+
   describe('processTextForEmoji', () => {
     it('processes all emoji in text', () => {
-      const inputOutput = 'Hello from finland! :lol: We have best water! :lmao:'
+      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(inputOutput, emojis, processor)).to.eql([
+      expect(processTextForEmoji(input, emojis, processor)).to.eql([
         'Hello from finland! ',
         { shortcode: 'lol', src: 'LOL' },
         ' We have best water! ',
@@ -145,13 +146,21 @@ describe('MiniHtmlConverter', () => {
       ])
     })
     it('leaves text as is', () => {
-      const inputOutput = 'Number one: that\'s terror'
+      const input = 'Number one: that\'s terror'
       const emojis = []
       const processor = ({ shortcode, src }) => ({ shortcode, src })
-      expect(processTextForEmoji(inputOutput, emojis, processor)).to.eql([
+      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)
+    })
   })
 })