UserError.spec.ts 710 B

123456789101112131415161718192021222324252627282930
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import UserError from '../UserError.ts'
  3. const errors = [
  4. {
  5. message: 'A problem example.',
  6. },
  7. {
  8. field: 'title',
  9. message: 'A problem with the title.',
  10. },
  11. ]
  12. const userError = new UserError(errors)
  13. describe('UserError', () => {
  14. it('should construct itself correctly', () => {
  15. expect(userError.generalErrors).toEqual(['A problem example.'])
  16. expect(userError.fieldErrors).toEqual([
  17. { field: 'title', message: 'A problem with the title.' },
  18. ])
  19. })
  20. it('get field error list', () => {
  21. expect(userError.getFieldErrorList()).toEqual({
  22. title: 'A problem with the title.',
  23. })
  24. })
  25. })