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.6 KB
Raw Blame
import { describe, expect, it } from 'vitest'
import { appendReturnedDraftText } from './returned-draft-text'

describe('appendReturnedDraftText', () => {
  it('fills an empty composer with the returned text as it was typed', () => {
    expect(appendReturnedDraftText('', 'ping  ')).toBe('ping  ')
    expect(appendReturnedDraftText(' \n', 'ping')).toBe('ping')
  })

  it('puts the returned text after a draft, a blank line apart', () => {
    expect(appendReturnedDraftText('newer edit\n', 'ping')).toBe('newer edit\n\nping')
  })

  it('adds nothing when the draft already ends with that text', () => {
    expect(appendReturnedDraftText('ping', 'ping')).toBe('ping')
    expect(appendReturnedDraftText('first\n\nping\n', 'ping ')).toBe('first\n\nping\n')
    expect(appendReturnedDraftText('ping', '')).toBe('ping')
  })

  it('still appends text that only ends a line of the draft', () => {
    expect(appendReturnedDraftText('say ping', 'ping')).toBe('say ping\n\nping')
  })

  it('a lone conversation command gives way to the message handed back, which it could not carry', () => {
    expect(appendReturnedDraftText('/compact', 'my message')).toBe('my message')
    expect(appendReturnedDraftText(' /clear\n', 'my message')).toBe('my message')
    expect(appendReturnedDraftText('/compact now', 'my message')).toBe('/compact now\n\nmy message')
    expect(appendReturnedDraftText('a/b', 'my message')).toBe('a/b\n\nmy message')
    expect(appendReturnedDraftText('/clearly', 'my message')).toBe('/clearly\n\nmy message')
    expect(appendReturnedDraftText('/tmp', 'my message')).toBe('/tmp\n\nmy message')
  })
})