diff options
| author | Abhi <[email protected]> | 2025-06-08 18:01:02 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-08 18:01:02 -0400 |
| commit | 7868ef82299ae1da5a09334f67d57eb3b472563a (patch) | |
| tree | 68e6a007dc0a762ae868cb7313c700686c4a1857 /packages/cli/src/ui/contexts/SessionContext.test.tsx | |
| parent | 9104ac02f7ac68d84bf9a3a78514bd080c77eec5 (diff) | |
feat: Introduce session context and add session duration stat for `/stats` command (#854)
Diffstat (limited to 'packages/cli/src/ui/contexts/SessionContext.test.tsx')
| -rw-r--r-- | packages/cli/src/ui/contexts/SessionContext.test.tsx | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/packages/cli/src/ui/contexts/SessionContext.test.tsx b/packages/cli/src/ui/contexts/SessionContext.test.tsx new file mode 100644 index 00000000..3b5454cf --- /dev/null +++ b/packages/cli/src/ui/contexts/SessionContext.test.tsx @@ -0,0 +1,29 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import { render } from 'ink-testing-library'; +import { Text } from 'ink'; +import { SessionProvider, useSession } from './SessionContext.js'; +import { describe, it, expect } from 'vitest'; + +const TestComponent = () => { + const { startTime } = useSession(); + return <Text>{startTime.toISOString()}</Text>; +}; + +describe('SessionContext', () => { + it('should provide a start time', () => { + const { lastFrame } = render( + <SessionProvider> + <TestComponent /> + </SessionProvider>, + ); + + const frameText = lastFrame(); + // Check if the output is a valid ISO string, which confirms it's a Date object. + expect(new Date(frameText!).toString()).not.toBe('Invalid Date'); + }); +}); |
