functions.spec.js 990 B

12345678910111213141516171819202122232425262728293031
  1. import { addWrapper, capitalizePrint, isRawHTML } from '../../src/js/functions'
  2. describe('addWrapper()', () => {
  3. it('add a div wrapper to a raw html', () => {
  4. const params = {
  5. font: 'TimesNewRoman',
  6. font_size: '12px'
  7. }
  8. expect(addWrapper('<span>Test</span>', params)).toBe('<div style="font-family:' + params.font + ' !important; font-size: ' + params.font_size + ' !important; width:100%;"><span>Test</span></div>')
  9. })
  10. })
  11. describe('capitalizePrint()', () => {
  12. it('should capitalize the first letter of a string', () => {
  13. expect(capitalizePrint('test')).toBe('Test')
  14. })
  15. })
  16. describe('isRawHTML()', () => {
  17. it('string `My Header` return `false`', () => {
  18. expect(isRawHTML('My Header')).toBe(false)
  19. })
  20. it('`<h1>My HTML Header</h1>` return `true`', () => {
  21. expect(isRawHTML('<h1>My HTML Header</h1>')).toBe(true)
  22. })
  23. it('`<h1>HTML syntax error` return `false`', () => {
  24. expect(isRawHTML('<h1>HTML syntax error')).toBe(false)
  25. })
  26. })