Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions __tests__/bundle/cronJobsInput.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { FakeGithub } from './fakeGithub'
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest'

import { start } from './fakeGithub'
import { token } from './helpers'
import { runBundle } from './runBundle'

vi.setConfig({ testTimeout: 30_000 })

// the `jobs` input validation of the cron dispatcher, driven through dist/index.js: the push event routes to the
// cron jobs like schedule and workflow_dispatch do, and a blank list fails the run before anything talks to the api
describe('dist/index.js cron jobs input', () => {
let gh: FakeGithub

beforeAll(async () => {
gh = await start()
})
afterEach(() => gh.reset())
afterAll(() => gh.close())

it('push without a jobs input fails the run naming the missing list and calls no api', async () => {
const result = await runBundle({ eventName: 'push', payload: {}, inputs: token, apiUrl: gh.url })

expect(result.status, result.stdout).toBe(1)
expect(result.errors.some(e => /please provide a list of space delimited/.test(e))).toBe(true)
expect(gh.requests).toEqual([])
})

it('a jobs input of only whitespace is treated as missing', async () => {
const result = await runBundle({ eventName: 'schedule', payload: {}, inputs: { ...token, jobs: ' \n\t ' }, apiUrl: gh.url })

expect(result.status, result.stdout).toBe(1)
expect(result.errors.some(e => /please provide a list of space delimited/.test(e))).toBe(true)
expect(gh.requests).toEqual([])
})
})
Loading