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.

929 B
Raw Blame
import { describe, it, expect } from 'vitest'
import {
  NATIVE_CHAT_COMPOSER_SCOPE_CACHE_MAX,
  setBoundedScopeCacheEntry
} from './native-chat-scope-cache'

describe('setBoundedScopeCacheEntry', () => {
  it('bounds the cache with LRU eviction, keeping re-set keys', () => {
    const cache = new Map<string, number>()
    setBoundedScopeCacheEntry(cache, 'keep', 1)

    const total = NATIVE_CHAT_COMPOSER_SCOPE_CACHE_MAX + 20
    for (let i = 0; i < total; i += 1) {
      setBoundedScopeCacheEntry(cache, `scope-${i}`, i)
      if (i % 10 === 0) {
        setBoundedScopeCacheEntry(cache, 'keep', 1)
      }
    }

    expect(cache.size).toBe(NATIVE_CHAT_COMPOSER_SCOPE_CACHE_MAX)
    expect(cache.has('scope-0')).toBe(false) // oldest untouched entry evicted
    expect(cache.has('keep')).toBe(true) // periodically re-set → retained
    expect(cache.has(`scope-${total - 1}`)).toBe(true) // most recent retained
  })
})