mirror of
https://github.com/koel/koel
synced 2024-12-30 06:23:05 +00:00
31 lines
950 B
TypeScript
31 lines
950 B
TypeScript
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'
|
|
])
|
|
})
|
|
})
|
|
})
|