Skip to content

Commit

Permalink
test: coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jeasonstudio committed Aug 8, 2024
1 parent 52d57cd commit 968bd0b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/language-model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,15 @@ describe('language-model', () => {

it('should do generate text', async () => {
const canCreateSession = vi.fn(async () => 'readily');
const getOptions = vi.fn(async () => ({ temperature: 1, topK: 10 }));
const getOptions = vi.fn(async () => ({
defaultTemperature: 1,
defaultTopK: 10,
}));
const prompt = vi.fn(async (prompt: string) => prompt);
const createSession = vi.fn(async () => ({ prompt }));
vi.stubGlobal('ai', {
canCreateTextSession: canCreateSession,
defaultTextSessionOptions: getOptions,
textModelInfo: getOptions,
createTextSession: createSession,
});

Expand Down Expand Up @@ -104,7 +107,7 @@ describe('language-model', () => {
});
vi.stubGlobal('ai', {
canCreateTextSession: vi.fn(async () => 'readily'),
defaultTextSessionOptions: vi.fn(async () => ({})),
textModelInfo: vi.fn(async () => ({})),
createTextSession: vi.fn(async () => ({ promptStreaming })),
});

Expand All @@ -121,7 +124,7 @@ describe('language-model', () => {
const prompt = vi.fn(async (prompt: string) => '{"hello":"world"}');
vi.stubGlobal('ai', {
canCreateTextSession: vi.fn(async () => 'readily'),
defaultTextSessionOptions: vi.fn(async () => ({})),
textModelInfo: vi.fn(async () => ({})),
createTextSession: vi.fn(async () => ({ prompt })),
});

Expand All @@ -140,7 +143,7 @@ describe('language-model', () => {
const prompt = vi.fn(async (prompt: string) => prompt);
vi.stubGlobal('ai', {
canCreateTextSession: vi.fn(async () => 'readily'),
defaultTextSessionOptions: vi.fn(async () => ({})),
textModelInfo: vi.fn(async () => ({})),
createTextSession: vi.fn(async () => ({ prompt })),
});
await expect(() =>
Expand Down

0 comments on commit 968bd0b

Please sign in to comment.