logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

utility.spec.js (1287B)


  1. import { processTextForEmoji, getAttrs } from 'src/services/html_converter/utility.service.js'
  2. describe('html_converter utility', () => {
  3. describe('processTextForEmoji', () => {
  4. it('processes all emoji in text', () => {
  5. const input = 'Hello from finland! :lol: We have best water! :lmao:'
  6. const emojis = [
  7. { shortcode: 'lol', src: 'LOL' },
  8. { shortcode: 'lmao', src: 'LMAO' }
  9. ]
  10. const processor = ({ shortcode, src }) => ({ shortcode, src })
  11. expect(processTextForEmoji(input, emojis, processor)).to.eql([
  12. 'Hello from finland! ',
  13. { shortcode: 'lol', src: 'LOL' },
  14. ' We have best water! ',
  15. { shortcode: 'lmao', src: 'LMAO' }
  16. ])
  17. })
  18. it('leaves text as is', () => {
  19. const input = 'Number one: that\'s terror'
  20. const emojis = []
  21. const processor = ({ shortcode, src }) => ({ shortcode, src })
  22. expect(processTextForEmoji(input, emojis, processor)).to.eql([
  23. 'Number one: that\'s terror'
  24. ])
  25. })
  26. })
  27. describe('getAttrs', () => {
  28. it('extracts arguments from tag', () => {
  29. const input = '<img src="boop" cool ebin=\'true\'>'
  30. const output = { src: 'boop', cool: true, ebin: 'true' }
  31. expect(getAttrs(input)).to.eql(output)
  32. })
  33. })
  34. })