datetime.spec.ts 919 B

1234567891011121314151617181920212223242526272829303132333435
  1. // Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. import { validDateTime, isDateString } from '../datetime.ts'
  3. describe('validDateTime', () => {
  4. it('is a valid date with time', () => {
  5. expect(validDateTime('2024-10-10T06:00:00Z')).toBe(true)
  6. })
  7. it('is a valid date', () => {
  8. expect(validDateTime('2024-10-10')).toBe(true)
  9. })
  10. it('is a valid date with time', () => {
  11. expect(validDateTime('2024-02-20 14:29:07 UTC')).toBe(true)
  12. })
  13. it('is a invalid date', () => {
  14. expect(validDateTime('2024+10-10T06:00:00Z')).toBe(false)
  15. })
  16. it('is also an invalid date', () => {
  17. expect(validDateTime('Test 456')).toBe(false)
  18. })
  19. })
  20. describe('isDateString', () => {
  21. it('is a valid date string only', () => {
  22. expect(isDateString('2024-10-10')).toBe(true)
  23. })
  24. it('is a valid date', () => {
  25. expect(isDateString('2024-10-10T06:00:00Z')).toBe(false)
  26. })
  27. })