Skip to content

Commit 7e469c9

Browse files
committed
refactor: unify import statements for consistency in test files
1 parent fd989ab commit 7e469c9

3 files changed

Lines changed: 44 additions & 64 deletions

File tree

test/config/llm.test.ts

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { beforeEach, describe, expect, it, vi } from "vitest";
2-
import type { EngineState } from "../../src/state";
1+
import { beforeEach, describe, expect, it, vi } from 'vitest';
2+
import type { EngineState } from '../../src/state';
33

44
const completionsMock = vi.fn();
55

6-
vi.mock("openai", () => {
6+
vi.mock('openai', () => {
77
return {
88
default: vi.fn().mockImplementation(() => ({
99
chat: {
@@ -15,55 +15,49 @@ vi.mock("openai", () => {
1515
};
1616
});
1717

18-
const { OpenAIFeedbackClient } = await import("../../src/config/llm");
18+
const { OpenAIFeedbackClient } = await import('../../src/config/llm');
1919

20-
describe("OpenAIFeedbackClient", () => {
20+
describe('OpenAIFeedbackClient', () => {
2121
const baseState: EngineState = {
22-
sessionId: "llm-test",
23-
uploadUrl: "https://example.com/file.wav",
22+
sessionId: 'llm-test',
23+
uploadUrl: 'https://example.com/file.wav',
2424
};
2525

2626
beforeEach(() => {
2727
vi.clearAllMocks();
2828
delete process.env.OPENAI_API_KEY;
2929
});
3030

31-
it("throws when API key missing", () => {
31+
it('throws when API key missing', () => {
3232
expect(() => new OpenAIFeedbackClient()).toThrow(/OPENAI_API_KEY/);
3333
});
3434

35-
it("calls OpenAI chat completions and returns parsed payload", async () => {
36-
process.env.OPENAI_API_KEY = "test-key";
35+
it('calls OpenAI chat completions and returns parsed payload', async () => {
36+
process.env.OPENAI_API_KEY = 'test-key';
3737

3838
completionsMock.mockResolvedValueOnce({
3939
choices: [
4040
{
4141
message: {
4242
content: JSON.stringify({
43-
feedbackText: "Solid balance.",
44-
suggestions: [
45-
"Ease 2kHz",
46-
"Add saturation",
47-
"Use multiband compression",
48-
],
43+
feedbackText: 'Solid balance.',
44+
suggestions: ['Ease 2kHz', 'Add saturation', 'Use multiband compression'],
4945
}),
5046
},
5147
},
5248
],
5349
});
5450

55-
const client = new OpenAIFeedbackClient({ model: "gpt-test" });
51+
const client = new OpenAIFeedbackClient({ model: 'gpt-test' });
5652
const response = await client.generateFeedback(baseState);
5753

58-
expect(response.feedbackText).toContain("Solid");
54+
expect(response.feedbackText).toContain('Solid');
5955
expect(response.suggestions).toHaveLength(3);
60-
expect(completionsMock).toHaveBeenCalledWith(
61-
expect.objectContaining({ model: "gpt-test" }),
62-
);
56+
expect(completionsMock).toHaveBeenCalledWith(expect.objectContaining({ model: 'gpt-test' }));
6357
});
6458

65-
it("throws when OpenAI returns empty content", async () => {
66-
process.env.OPENAI_API_KEY = "test-key";
59+
it('throws when OpenAI returns empty content', async () => {
60+
process.env.OPENAI_API_KEY = 'test-key';
6761

6862
completionsMock.mockResolvedValueOnce({
6963
choices: [
@@ -79,14 +73,14 @@ describe("OpenAIFeedbackClient", () => {
7973
await expect(client.generateFeedback(baseState)).rejects.toThrow(/empty response/);
8074
});
8175

82-
it("throws when OpenAI returns invalid JSON", async () => {
83-
process.env.OPENAI_API_KEY = "test-key";
76+
it('throws when OpenAI returns invalid JSON', async () => {
77+
process.env.OPENAI_API_KEY = 'test-key';
8478

8579
completionsMock.mockResolvedValueOnce({
8680
choices: [
8781
{
8882
message: {
89-
content: "not-json",
83+
content: 'not-json',
9084
},
9185
},
9286
],
@@ -96,8 +90,8 @@ describe("OpenAIFeedbackClient", () => {
9690
await expect(client.generateFeedback(baseState)).rejects.toThrow(/Failed to parse/);
9791
});
9892

99-
it("throws when OpenAI omits content", async () => {
100-
process.env.OPENAI_API_KEY = "test-key";
93+
it('throws when OpenAI omits content', async () => {
94+
process.env.OPENAI_API_KEY = 'test-key';
10195

10296
completionsMock.mockResolvedValueOnce({
10397
choices: [

test/graph/auralyze-graph.unit.test.ts

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -201,18 +201,14 @@ describe('Auralyze LangGraph', () => {
201201
it('metadata step short-circuits when upload is missing or state errored', async () => {
202202
const metadataClient = { getMetadata: vi.fn() };
203203

204-
const missingUpload = await metadataStepNode(
205-
{ audioMetadataClient: metadataClient },
206-
{ sessionId: 'missing-upload' } as EngineState,
207-
);
208-
const upstreamError = await metadataStepNode(
209-
{ audioMetadataClient: metadataClient },
210-
{
211-
sessionId: 'errored',
212-
uploadUrl: 'https://example.com/file.wav',
213-
error: 'metadata blocked',
214-
} as EngineState,
215-
);
204+
const missingUpload = await metadataStepNode({ audioMetadataClient: metadataClient }, {
205+
sessionId: 'missing-upload',
206+
} as EngineState);
207+
const upstreamError = await metadataStepNode({ audioMetadataClient: metadataClient }, {
208+
sessionId: 'errored',
209+
uploadUrl: 'https://example.com/file.wav',
210+
error: 'metadata blocked',
211+
} as EngineState);
216212

217213
expect(missingUpload).toEqual({});
218214
expect(upstreamError).toEqual({});
@@ -222,18 +218,14 @@ describe('Auralyze LangGraph', () => {
222218
it('analysis step short-circuits when upload missing or error set', async () => {
223219
const analysisClient = { analyze: vi.fn() };
224220

225-
const missingUpload = await analysisStepNode(
226-
{ audioAnalysisClient: analysisClient },
227-
{ sessionId: 'missing-upload' } as EngineState,
228-
);
229-
const upstreamError = await analysisStepNode(
230-
{ audioAnalysisClient: analysisClient },
231-
{
232-
sessionId: 'errored',
233-
uploadUrl: 'https://example.com/file.wav',
234-
error: 'analysis blocked',
235-
} as EngineState,
236-
);
221+
const missingUpload = await analysisStepNode({ audioAnalysisClient: analysisClient }, {
222+
sessionId: 'missing-upload',
223+
} as EngineState);
224+
const upstreamError = await analysisStepNode({ audioAnalysisClient: analysisClient }, {
225+
sessionId: 'errored',
226+
uploadUrl: 'https://example.com/file.wav',
227+
error: 'analysis blocked',
228+
} as EngineState);
237229

238230
expect(missingUpload).toEqual({});
239231
expect(upstreamError).toEqual({});
@@ -243,14 +235,11 @@ describe('Auralyze LangGraph', () => {
243235
it('feedback step ignores execution when error present', async () => {
244236
const feedbackClient = { generateFeedback: vi.fn() };
245237

246-
const result = await feedbackStepNode(
247-
{ feedbackClient },
248-
{
249-
sessionId: 'errored',
250-
uploadUrl: 'https://example.com/file.wav',
251-
error: 'halt',
252-
} as EngineState,
253-
);
238+
const result = await feedbackStepNode({ feedbackClient }, {
239+
sessionId: 'errored',
240+
uploadUrl: 'https://example.com/file.wav',
241+
error: 'halt',
242+
} as EngineState);
254243

255244
expect(result).toEqual({});
256245
expect(feedbackClient.generateFeedback).not.toHaveBeenCalled();

test/tools.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ import {
88
createAudioAnalysisTool,
99
} from '../src/tools/audio-analysis-tool';
1010
import { type EngineState } from '../src/state';
11-
import {
12-
type FeedbackClient,
13-
type FeedbackResult,
14-
} from '../src/tools/llm-feedback-tool';
11+
import { type FeedbackClient, type FeedbackResult } from '../src/tools/llm-feedback-tool';
1512

1613
describe('audio-metadata-tool', () => {
1714
it('validates metadata schema', () => {

0 commit comments

Comments
 (0)