HuggingClaw-MissionControl / src /lib /__tests__ /security-scan-portability.test.ts
nyk
feat(refactor): ready for manual QA after main sync (#274)
b6ecafa unverified
Raw
History Blame Contribute Delete
599 Bytes
import os from 'node:os'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { readSystemUptimeSeconds } from '@/lib/security-scan'
describe('readSystemUptimeSeconds', () => {
afterEach(() => {
vi.restoreAllMocks()
})
it('returns null when uptime is unavailable', () => {
vi.spyOn(os, 'uptime').mockImplementation(() => {
throw new Error('EPERM')
})
expect(readSystemUptimeSeconds()).toBeNull()
})
it('returns uptime when available', () => {
vi.spyOn(os, 'uptime').mockReturnValue(123)
expect(readSystemUptimeSeconds()).toBe(123)
})
})