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.

2.1 KB
Raw Blame
import { describe, expect, it } from 'vitest'
import { comparePublishedFieldOccurrences, comparePublishedFields } from './published-field-shape'

describe('published field shape', () => {
  it('detects a field removed from only one corresponding occurrence', () => {
    expect(
      comparePublishedFieldOccurrences({
        older: [
          { kind: 'scrollback', seq: 0 },
          { kind: 'scrollback', seq: 27, requestId: 1 },
          { kind: 'scrollback', seq: 27 }
        ],
        newer: [
          { kind: 'scrollback', seq: 0 },
          { kind: 'scrollback', requestId: 1 },
          { kind: 'scrollback', seq: 27 }
        ]
      })
    ).toEqual([
      { added: [], removed: [] },
      { added: [], removed: ['seq'] },
      { added: [], removed: [] }
    ])
  })

  it('rejects unequal occurrence counts instead of truncating the comparison', () => {
    expect(() =>
      comparePublishedFieldOccurrences({
        older: [{ kind: 'scrollback' }, { kind: 'scrollback' }],
        newer: [{ kind: 'scrollback' }]
      })
    ).toThrow(/occurrence count differs: older 2, newer 1/)
  })

  it('reports an added field as added and nothing as removed', () => {
    expect(
      comparePublishedFields({
        older: ['cols', 'kind', 'rows'],
        newer: ['alternateScreen', 'cols', 'kind', 'rows', 'terminalOwner']
      })
    ).toEqual({ added: ['alternateScreen', 'terminalOwner'], removed: [] })
  })

  it('reports a field the newer side stopped publishing as removed', () => {
    expect(
      comparePublishedFields({
        older: ['cols', 'kind', 'rows', 'source'],
        newer: ['cols', 'kind', 'rows']
      })
    ).toEqual({ added: [], removed: ['source'] })
  })

  it('is silent when both sides publish the same names in a different order', () => {
    expect(comparePublishedFields({ older: ['rows', 'cols'], newer: ['cols', 'rows'] })).toEqual({
      added: [],
      removed: []
    })
  })

  it('does not repeat a name a caller passed twice', () => {
    expect(comparePublishedFields({ older: [], newer: ['seq', 'seq'] })).toEqual({
      added: ['seq'],
      removed: []
    })
  })
})