summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/contexts/SessionContext.test.tsx
blob: 3b5454cf65e2cd620faa874c16c554666d2682c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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');
  });
});