import { convertHtml, processTextForEmoji } 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([ '1 ', [ '

', ['2'], '

' ], ' ', [ '', [ '3', [''], '4' ], '' ], '5' ]) }) it('converts html to tree while preserving tag formatting', () => { const inputOutput = '1

2

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

', ['2'], '

' ], [ '', [ '3', [''], '4' ], '' ], '5' ]) }) it('converts semi-broken html', () => { const inputOutput = '1
2

42' expect(convertHtml(inputOutput)).to.eql([ '1 ', ['
'], ' 2 ', [ '

', [' 42'] ] ]) }) it('realistic case', () => { const inputOutput = '

@benis @hj nice

' expect(convertHtml(inputOutput)).to.eql([ [ '

', [ [ '', [ [ '', [ '@', [ '', [ 'benis' ], '' ] ], '' ] ], '' ], ' ', [ '', [ [ '', [ '@', [ '', [ 'hj' ], '' ] ], '' ] ], '' ], ' nice' ], '

' ] ]) }) }) describe('processTextForEmoji', () => { it('processes all emoji in text', () => { const inputOutput = '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([ 'Hello from finland! ', { shortcode: 'lol', src: 'LOL' }, ' We have best water! ', { shortcode: 'lmao', src: 'LMAO' } ]) }) }) })