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.

813 B
Raw Blame
import { describe, expect, it } from 'vitest'
import { deconflictCopyName } from './import-copy-name'

function takenFrom(names: string[]): (name: string) => Promise<boolean> {
  return async (name) => names.includes(name)
}

describe('deconflictCopyName', () => {
  it('keeps a free original name', async () => {
    expect(await deconflictCopyName('a.txt', takenFrom([]))).toBe('a.txt')
  })

  it('inserts the copy suffix before the extension', async () => {
    expect(await deconflictCopyName('a.txt', takenFrom(['a.txt']))).toBe('a copy.txt')
    expect(await deconflictCopyName('a.txt', takenFrom(['a.txt', 'a copy.txt']))).toBe(
      'a copy 2.txt'
    )
  })

  it('treats a dotfile as all stem', async () => {
    expect(await deconflictCopyName('.env', takenFrom(['.env']))).toBe('.env copy')
  })
})