From dc4c97f4121328655dc9e985d0ce11a1afb26fbc Mon Sep 17 00:00:00 2001 From: Clifford Tawiah Date: Mon, 3 Feb 2025 16:55:56 -0600 Subject: [PATCH] fix an issue with prettier --- .../__tests__/LDAIConfigTrackerImpl.test.ts | 128 +++++++++++++++--- 1 file changed, 112 insertions(+), 16 deletions(-) diff --git a/packages/sdk/server-ai/__tests__/LDAIConfigTrackerImpl.test.ts b/packages/sdk/server-ai/__tests__/LDAIConfigTrackerImpl.test.ts index 655cd30b5..483d09788 100644 --- a/packages/sdk/server-ai/__tests__/LDAIConfigTrackerImpl.test.ts +++ b/packages/sdk/server-ai/__tests__/LDAIConfigTrackerImpl.test.ts @@ -21,7 +21,13 @@ beforeEach(() => { }); it('tracks duration', () => { - const tracker = new LDAIConfigTrackerImpl(mockLdClient, configKey, variationKey, version, testContext); + const tracker = new LDAIConfigTrackerImpl( + mockLdClient, + configKey, + variationKey, + version, + testContext, + ); tracker.trackDuration(1000); expect(mockTrack).toHaveBeenCalledWith( @@ -33,7 +39,13 @@ it('tracks duration', () => { }); it('tracks duration of async function', async () => { - const tracker = new LDAIConfigTrackerImpl(mockLdClient, configKey, variationKey, version, testContext); + const tracker = new LDAIConfigTrackerImpl( + mockLdClient, + configKey, + variationKey, + version, + testContext, + ); jest.spyOn(global.Date, 'now').mockReturnValueOnce(1000).mockReturnValueOnce(2000); const result = await tracker.trackDurationOf(async () => 'test-result'); @@ -48,7 +60,13 @@ it('tracks duration of async function', async () => { }); it('tracks time to first token', () => { - const tracker = new LDAIConfigTrackerImpl(mockLdClient, configKey, variationKey, version, testContext); + const tracker = new LDAIConfigTrackerImpl( + mockLdClient, + configKey, + variationKey, + version, + testContext, + ); tracker.trackTimeToFirstToken(1000); expect(mockTrack).toHaveBeenCalledWith( @@ -60,7 +78,13 @@ it('tracks time to first token', () => { }); it('tracks positive feedback', () => { - const tracker = new LDAIConfigTrackerImpl(mockLdClient, configKey, variationKey, version, testContext); + const tracker = new LDAIConfigTrackerImpl( + mockLdClient, + configKey, + variationKey, + version, + testContext, + ); tracker.trackFeedback({ kind: LDFeedbackKind.Positive }); expect(mockTrack).toHaveBeenCalledWith( @@ -72,7 +96,13 @@ it('tracks positive feedback', () => { }); it('tracks negative feedback', () => { - const tracker = new LDAIConfigTrackerImpl(mockLdClient, configKey, variationKey, version, testContext); + const tracker = new LDAIConfigTrackerImpl( + mockLdClient, + configKey, + variationKey, + version, + testContext, + ); tracker.trackFeedback({ kind: LDFeedbackKind.Negative }); expect(mockTrack).toHaveBeenCalledWith( @@ -84,7 +114,13 @@ it('tracks negative feedback', () => { }); it('tracks success', () => { - const tracker = new LDAIConfigTrackerImpl(mockLdClient, configKey, variationKey, version, testContext); + const tracker = new LDAIConfigTrackerImpl( + mockLdClient, + configKey, + variationKey, + version, + testContext, + ); tracker.trackSuccess(); expect(mockTrack).toHaveBeenCalledWith( @@ -96,7 +132,13 @@ it('tracks success', () => { }); it('tracks OpenAI usage', async () => { - const tracker = new LDAIConfigTrackerImpl(mockLdClient, configKey, variationKey, version, testContext); + const tracker = new LDAIConfigTrackerImpl( + mockLdClient, + configKey, + variationKey, + version, + testContext, + ); jest.spyOn(global.Date, 'now').mockReturnValueOnce(1000).mockReturnValueOnce(2000); const TOTAL_TOKENS = 100; @@ -148,7 +190,13 @@ it('tracks OpenAI usage', async () => { }); it('tracks error when OpenAI metrics function throws', async () => { - const tracker = new LDAIConfigTrackerImpl(mockLdClient, configKey, variationKey, version, testContext); + const tracker = new LDAIConfigTrackerImpl( + mockLdClient, + configKey, + variationKey, + version, + testContext, + ); jest.spyOn(global.Date, 'now').mockReturnValueOnce(1000).mockReturnValueOnce(2000); const error = new Error('OpenAI API error'); @@ -181,7 +229,13 @@ it('tracks error when OpenAI metrics function throws', async () => { }); it('tracks Bedrock conversation with successful response', () => { - const tracker = new LDAIConfigTrackerImpl(mockLdClient, configKey, variationKey, version, testContext); + const tracker = new LDAIConfigTrackerImpl( + mockLdClient, + configKey, + variationKey, + version, + testContext, + ); const TOTAL_TOKENS = 100; const PROMPT_TOKENS = 49; @@ -236,7 +290,13 @@ it('tracks Bedrock conversation with successful response', () => { }); it('tracks Bedrock conversation with error response', () => { - const tracker = new LDAIConfigTrackerImpl(mockLdClient, configKey, variationKey, version, testContext); + const tracker = new LDAIConfigTrackerImpl( + mockLdClient, + configKey, + variationKey, + version, + testContext, + ); const response = { $metadata: { httpStatusCode: 400 }, @@ -261,7 +321,13 @@ it('tracks Bedrock conversation with error response', () => { }); it('tracks tokens', () => { - const tracker = new LDAIConfigTrackerImpl(mockLdClient, configKey, variationKey, version, testContext); + const tracker = new LDAIConfigTrackerImpl( + mockLdClient, + configKey, + variationKey, + version, + testContext, + ); const TOTAL_TOKENS = 100; const PROMPT_TOKENS = 49; @@ -296,7 +362,13 @@ it('tracks tokens', () => { }); it('only tracks non-zero token counts', () => { - const tracker = new LDAIConfigTrackerImpl(mockLdClient, configKey, variationKey, version, testContext); + const tracker = new LDAIConfigTrackerImpl( + mockLdClient, + configKey, + variationKey, + version, + testContext, + ); tracker.trackTokens({ total: 0, @@ -327,7 +399,13 @@ it('only tracks non-zero token counts', () => { }); it('returns empty summary when no metrics tracked', () => { - const tracker = new LDAIConfigTrackerImpl(mockLdClient, configKey, variationKey, version, testContext); + const tracker = new LDAIConfigTrackerImpl( + mockLdClient, + configKey, + variationKey, + version, + testContext, + ); const summary = tracker.getSummary(); @@ -335,7 +413,13 @@ it('returns empty summary when no metrics tracked', () => { }); it('summarizes tracked metrics', () => { - const tracker = new LDAIConfigTrackerImpl(mockLdClient, configKey, variationKey, version, testContext); + const tracker = new LDAIConfigTrackerImpl( + mockLdClient, + configKey, + variationKey, + version, + testContext, + ); tracker.trackDuration(1000); tracker.trackTokens({ @@ -363,7 +447,13 @@ it('summarizes tracked metrics', () => { }); it('tracks duration when async function throws', async () => { - const tracker = new LDAIConfigTrackerImpl(mockLdClient, configKey, variationKey, version, testContext); + const tracker = new LDAIConfigTrackerImpl( + mockLdClient, + configKey, + variationKey, + version, + testContext, + ); jest.spyOn(global.Date, 'now').mockReturnValueOnce(1000).mockReturnValueOnce(2000); const error = new Error('test error'); @@ -382,7 +472,13 @@ it('tracks duration when async function throws', async () => { }); it('tracks error', () => { - const tracker = new LDAIConfigTrackerImpl(mockLdClient, configKey, variationKey, version, testContext); + const tracker = new LDAIConfigTrackerImpl( + mockLdClient, + configKey, + variationKey, + version, + testContext, + ); tracker.trackError(); expect(mockTrack).toHaveBeenCalledWith(