diff options
| author | Henry Jameson <me@hjkos.com> | 2021-06-12 19:47:23 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2021-06-12 19:54:30 +0300 |
| commit | cd4455675024a3dfc8930184114d5f92438d0466 (patch) | |
| tree | 14a11f546ab86fc1f5a2d288344f3ff7c7e246a5 /test/unit/specs/services/html_converter/utility.spec.js | |
| parent | ca6c7d5b10e48299dcb0ee65248de14f27ed78c8 (diff) | |
restructure and tests
squash! restructure and tests
Diffstat (limited to 'test/unit/specs/services/html_converter/utility.spec.js')
| -rw-r--r-- | test/unit/specs/services/html_converter/utility.spec.js | 37 |
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) + }) + }) +}) |
