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.2 KB
Raw Blame
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { loadAppUpdatePreferences } from './app-update-preferences'

const stored = new Map<string, string>()
vi.mock('@react-native-async-storage/async-storage', () => ({
  default: {
    multiGet: async (keys: string[]) => keys.map((key) => [key, stored.get(key) ?? null])
  }
}))

beforeEach(() => stored.clear())

describe('loadAppUpdatePreferences', () => {
  it('drops only a corrupt update record, keeping the check time and dismissal beside it', async () => {
    stored.set('orca:appUpdate:lastCheckedAt', '1700000000000')
    stored.set('orca:appUpdate:latest', '{not json')
    stored.set('orca:appUpdate:dismissedVersion', '0.0.51')
    await expect(loadAppUpdatePreferences()).resolves.toEqual({
      lastCheckedAt: 1700000000000,
      latest: null,
      dismissedVersion: '0.0.51'
    })
  })

  it('reads a well-formed update record', async () => {
    stored.set(
      'orca:appUpdate:latest',
      JSON.stringify({ version: '0.0.52', url: 'https://x.test' })
    )
    await expect(loadAppUpdatePreferences()).resolves.toEqual({
      lastCheckedAt: null,
      latest: { version: '0.0.52', url: 'https://x.test' },
      dismissedVersion: null
    })
  })
})