2
0
Fork 0
mirror of https://github.com/koel/koel synced 2025-01-02 15:58:46 +00:00
koel/resources/assets/js/__tests__/utils/utils.spec.ts

32 lines
950 B
TypeScript
Raw Normal View History

2022-04-15 14:24:30 +00:00
import { secondsToHis, parseValidationError, ServerValidationError } from '@/utils'
describe('services/utils', () => {
describe('#secondsToHis', () => {
it('formats a duration to H:i:s', () => expect(secondsToHis(7547)).toBe('02:05:47'))
it('omits hours from short duration when formats to H:i:s', () => expect(secondsToHis(314)).toBe('05:14'))
})
describe('#parseValidationError', () => {
it('parses validation error', () => {
const error: ServerValidationError = {
message: 'The given data was invalid',
errors: {
email: [
'The email has already been taken',
'The domain is blacklisted'
],
name: [
'The name is required'
]
}
}
expect(parseValidationError(error)).toEqual([
'The email has already been taken',
'The domain is blacklisted',
'The name is required'
])
})
})
})