Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

1.3 KB
Raw Blame
import { describe, expect, it, vi } from 'vitest'
import { hasNoChangedFiles } from './vitest-changed-precheck.mjs'

const clean = () => vi.fn(async () => ({ code: 0, stdout: '' }))

describe('hasNoChangedFiles', () => {
  it('also checks commits since the ref', async () => {
    const runProcess = clean()
    await expect(
      hasNoChangedFiles(['run', '--changed=origin/main'], '/repo', runProcess)
    ).resolves.toBe(true)
    expect(runProcess.mock.calls.map(([spec]) => spec.args)).toContainEqual([
      'diff',
      '--name-only',
      '-z',
      'origin/main...HEAD'
    ])
  })

  it('starts Vitest when Git reports a file or cannot answer', async () => {
    for (const result of [
      { code: 0, stdout: '?? src/a.ts\0' },
      { code: 128, stdout: '' }
    ]) {
      const runProcess = vi.fn(async () => result)
      await expect(hasNoChangedFiles(['run', '--changed'], '/repo', runProcess)).resolves.toBe(
        false
      )
    }
  })

  it.each([
    [['run', 'src/a']],
    [['run', '--changed', 'src/a']],
    [['run', '--changed', '--watch']],
    [['related', '--changed']]
  ])('leaves %j to Vitest', async (args) => {
    const runProcess = clean()
    await expect(hasNoChangedFiles(args, '/repo', runProcess)).resolves.toBe(false)
    expect(runProcess).not.toHaveBeenCalled()
  })
})