formatters.spec.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. import { getInitials, toClassName } from '../formatter'
  3. describe('getInitials', () => {
  4. it('returns ?? initials, if no arguments are present', () => {
  5. expect(getInitials()).toBe('??')
  6. expect(getInitials('', '', '')).toBe('??')
  7. })
  8. it('returns two letters from firstname, if no other are present', () => {
  9. expect(getInitials('John')).toBe('JO')
  10. expect(getInitials('John', '', '')).toBe('JO')
  11. })
  12. it('returns two letters from lastname, if no other are present', () => {
  13. expect(getInitials(undefined, 'Doe')).toBe('DO')
  14. expect(getInitials('', 'Doe', '')).toBe('DO')
  15. })
  16. it('returns two letters from email, if no other are present', () => {
  17. expect(getInitials(undefined, undefined, 'email@mail.com')).toBe('EM')
  18. expect(getInitials('', '', 'email@mail.com')).toBe('EM')
  19. })
  20. it('returns two letters from firstname and lastname', () => {
  21. expect(getInitials('John', 'Doe')).toBe('JD')
  22. expect(getInitials('John', 'Doe', '')).toBe('JD')
  23. expect(getInitials('John', 'Doe', 'email@mail.com')).toBe('JD')
  24. })
  25. })
  26. describe('toClassName', () => {
  27. it('convert relation to class name', () => {
  28. expect(toClassName('TicketState')).toBe('Ticket::State')
  29. })
  30. })