Skip to content

Commit 5d0f08d

Browse files
committed
refactor(tests): update imports to use @launchdarkly/js-client-sdk
- Changed import paths in test files to reflect the new SDK structure. - Updated mock implementations to align with the new SDK methods. - Ensured compatibility with existing tests by adjusting mock behavior.
1 parent 7e8f370 commit 5d0f08d

9 files changed

Lines changed: 26 additions & 16 deletions

File tree

packages/demo/src/hooks/useLaunchDarklyProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useState, useEffect, useRef } from 'react';
2-
import { asyncWithLDProvider} from 'launchdarkly-react-client-sdk';
2+
import { asyncWithLDProvider } from 'launchdarkly-react-client-sdk';
33
import type { LDPlugin } from '@launchdarkly/js-client-sdk';
44
import { DEMO_CONFIG, demoLog } from '../config/demo';
55
import { startMockWorker, stopMockWorker } from '../mocks';

packages/toolbar/src/core/tests/ContextItem.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
22
import { expect, test, describe, vi, beforeEach } from 'vitest';
3-
import type { LDContext } from 'launchdarkly-js-client-sdk';
3+
import type { LDContext } from '@launchdarkly/js-client-sdk';
44
import { ContextItem } from '../ui/Toolbar/components/new/Contexts/ContextItem';
55
import { ContextsProvider } from '../ui/Toolbar/context/api/ContextsProvider';
66
import '@testing-library/jest-dom/vitest';

packages/toolbar/src/core/tests/ContextsProvider.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { render, screen, waitFor, act } from '@testing-library/react';
22
import { expect, test, describe, vi, beforeEach } from 'vitest';
3-
import type { LDContext } from 'launchdarkly-js-client-sdk';
3+
import type { LDContext } from '@launchdarkly/js-client-sdk';
44
import { ContextsProvider, useContextsContext } from '../ui/Toolbar/context/api/ContextsProvider';
55
import '@testing-library/jest-dom/vitest';
66
import React from 'react';

packages/toolbar/src/core/tests/createToolbarFlagFunction.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, test, expect, vi, beforeEach } from 'vitest';
2-
import type { LDClient } from 'launchdarkly-js-client-sdk';
2+
import type { LDClient } from '@launchdarkly/js-client-sdk';
33
import {
44
createToolbarFlagFunction,
55
setToolbarFlagClient,

packages/toolbar/src/core/tests/hooks/AfterEvaluationHook.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, it, expect, beforeEach, vi } from 'vitest';
22
import { AfterEvaluationHook, type AfterEvaluationHookConfig } from '../../../types/hooks/AfterEvaluationHook';
3-
import type { EvaluationSeriesData, EvaluationSeriesContext, LDEvaluationDetail } from 'launchdarkly-js-sdk-common';
3+
import type { EvaluationSeriesData, EvaluationSeriesContext, LDEvaluationDetail } from '@launchdarkly/js-client-sdk';
44
import { EventFilter, ProcessedEvent } from '../../../types';
55

66
// Mock console methods to avoid noise in test output

packages/toolbar/src/core/tests/hooks/AfterIdentifyHook.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, it, expect, beforeEach, vi } from 'vitest';
22
import { AfterIdentifyHook, type AfterIdentifyHookConfig } from '../../../types/hooks/AfterIdentifyHook';
3-
import type { IdentifySeriesData, IdentifySeriesContext, IdentifySeriesResult } from 'launchdarkly-js-sdk-common';
3+
import type { IdentifySeriesData, IdentifySeriesContext, IdentifySeriesResult } from '@launchdarkly/js-client-sdk';
44
import { EventFilter, ProcessedEvent } from '../../../types';
55

66
// Mock console methods to avoid noise in test output
@@ -106,7 +106,7 @@ describe('AfterIdentifyHook', () => {
106106

107107
it('should handle contexts without key', () => {
108108
const contextWithoutKey = {
109-
context: { kind: 'user', name: 'No Key User' },
109+
context: { kind: 'user', name: 'No Key User', key: '' },
110110
};
111111
hook.afterIdentify(contextWithoutKey, mockData, mockResult);
112112

packages/toolbar/src/core/ui/Toolbar/context/telemetry/InternalClientProvider.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,20 @@ export function InternalClientProvider({
183183

184184
// Wrap identify in a Promise that resolves when the onDone callback fires
185185
// This ensures flags have been re-evaluated before we return
186-
return client.identify({
186+
return client
187+
.identify({
187188
kind: 'multi',
188189
account: {
189190
key: accountId,
190191
},
191192
user: {
192193
key: memberId,
193194
},
194-
}
195-
).then(() => {})
196-
.catch((err) => {
197-
console.error('[InternalClientProvider] Failed to update context:', err);
198-
});
195+
})
196+
.then(() => {})
197+
.catch((err) => {
198+
console.error('[InternalClientProvider] Failed to update context:', err);
199+
});
199200
},
200201
[client],
201202
);

packages/toolbar/src/types/hooks/AfterEvaluationHook.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import type { Hook, HookMetadata, EvaluationSeriesData, LDEvaluationDetail, EvaluationSeriesContext } from '@launchdarkly/js-client-sdk';
1+
import type {
2+
Hook,
3+
HookMetadata,
4+
EvaluationSeriesData,
5+
LDEvaluationDetail,
6+
EvaluationSeriesContext,
7+
} from '@launchdarkly/js-client-sdk';
28
import type { EventFilter, ProcessedEvent, SyntheticEventContext } from '../events';
39

410
export type AfterEvaluationHookConfig = {

packages/toolbar/src/types/hooks/AfterIdentifyHook.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import type { Hook, HookMetadata,
1+
import type {
2+
Hook,
3+
HookMetadata,
24
IdentifySeriesContext,
35
IdentifySeriesData,
46
IdentifySeriesResult,
5-
LDContext, } from '@launchdarkly/js-client-sdk';
7+
LDContext,
8+
} from '@launchdarkly/js-client-sdk';
69

710
import type { EventFilter, ProcessedEvent, SyntheticEventContext } from '../events';
811

0 commit comments

Comments
 (0)