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 c4e3f68885..b42f5f35fe 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

2

345' - expect(convertHtml(inputOutput)).to.eql([ + const input = '1

2

345' + expect(convertHtml(input)).to.eql([ '1 ', [ '

', @@ -25,8 +25,8 @@ describe('MiniHtmlConverter', () => { ]) }) it('converts html to tree while preserving tag formatting', () => { - const inputOutput = '1

2

345' - expect(convertHtml(inputOutput)).to.eql([ + const input = '1

2

345' + expect(convertHtml(input)).to.eql([ '1 ', [ '

', @@ -46,8 +46,8 @@ describe('MiniHtmlConverter', () => { ]) }) it('converts semi-broken html', () => { - const inputOutput = '1
2

42' - expect(convertHtml(inputOutput)).to.eql([ + const input = '1
2

42' + expect(convertHtml(input)).to.eql([ '1 ', ['
'], ' 2 ', @@ -58,8 +58,8 @@ describe('MiniHtmlConverter', () => { ]) }) it('realistic case 1', () => { - const inputOutput = '

@benis @hj nice

' - expect(convertHtml(inputOutput)).to.eql([ + const input = '

@benis @hj nice

' + expect(convertHtml(input)).to.eql([ [ '

', [ @@ -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 = '' + const output = { src: 'boop', cool: true, ebin: 'true' } + + expect(getAttrs(input)).to.eql(output) + }) }) })