40 lines
1022 B
TypeScript
40 lines
1022 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { buildOpenAIUsageRefreshKey } from '../accountUsageRefresh'
|
|
|
|
describe('buildOpenAIUsageRefreshKey', () => {
|
|
it('会在 codex 快照变化时生成不同 key', () => {
|
|
const base = {
|
|
id: 1,
|
|
platform: 'openai',
|
|
type: 'oauth',
|
|
updated_at: '2026-03-07T10:00:00Z',
|
|
extra: {
|
|
codex_usage_updated_at: '2026-03-07T10:00:00Z',
|
|
codex_5h_used_percent: 0,
|
|
codex_7d_used_percent: 0
|
|
}
|
|
} as any
|
|
|
|
const next = {
|
|
...base,
|
|
extra: {
|
|
...base.extra,
|
|
codex_usage_updated_at: '2026-03-07T10:01:00Z',
|
|
codex_5h_used_percent: 100
|
|
}
|
|
}
|
|
|
|
expect(buildOpenAIUsageRefreshKey(base)).not.toBe(buildOpenAIUsageRefreshKey(next))
|
|
})
|
|
|
|
it('非 OpenAI OAuth 账号返回空 key', () => {
|
|
expect(buildOpenAIUsageRefreshKey({
|
|
id: 2,
|
|
platform: 'anthropic',
|
|
type: 'oauth',
|
|
updated_at: '2026-03-07T10:00:00Z',
|
|
extra: {}
|
|
} as any)).toBe('')
|
|
})
|
|
})
|