27 lines
1.1 KiB
JavaScript
27 lines
1.1 KiB
JavaScript
import { executionLogQuery, executionStatusMeta, jobLogRoute } from '@/views/schedule/execution-log'
|
|
|
|
describe('scheduled job execution log helpers', () => {
|
|
test('only one valid selection can navigate to JobLog', () => {
|
|
expect(jobLogRoute([])).toBeNull()
|
|
expect(jobLogRoute([1, 2])).toBeNull()
|
|
expect(jobLogRoute(['invalid'])).toBeNull()
|
|
expect(jobLogRoute([5])).toEqual({ name: 'JobLog', query: { jobId: '5' }})
|
|
})
|
|
|
|
test('builds RFC3339 date filters without mutating paging', () => {
|
|
const from = new Date('2026-09-02T10:00:00+08:00')
|
|
const to = new Date('2026-09-02T11:00:00+08:00')
|
|
expect(executionLogQuery({ pageIndex: 2, pageSize: 20, status: 'failed' }, [from, to])).toEqual({
|
|
pageIndex: 2, pageSize: 20, status: 'failed',
|
|
startedFrom: from.toISOString(), startedTo: to.toISOString()
|
|
})
|
|
})
|
|
|
|
test('maps all persisted statuses', () => {
|
|
expect(executionStatusMeta('running').label).toBe('执行中')
|
|
expect(executionStatusMeta('succeeded').type).toBe('success')
|
|
expect(executionStatusMeta('failed').type).toBe('danger')
|
|
expect(executionStatusMeta('interrupted').label).toBe('已中断')
|
|
})
|
|
})
|