Skip to content

Commit 254cdd0

Browse files
refactor: Migrate Instance Manager Tests to TypeScript
1 parent b6883b6 commit 254cdd0

File tree

3 files changed

+231
-148
lines changed

3 files changed

+231
-148
lines changed

src/sdkRuntimeModels.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from '@mparticle/web-sdk';
99
import { IStore } from './store';
1010
import Validators from './validators';
11-
import { Dictionary } from './utils';
11+
import { Dictionary, valueof } from './utils';
1212
import { IServerModel } from './serverModel';
1313
import { IKitConfigs } from './configAPIClient';
1414
import { SDKConsentApi, SDKConsentState } from './consent';
@@ -29,7 +29,12 @@ import {
2929
IdentityCallback,
3030
ISDKUserAttributes,
3131
} from './identity-user-interfaces';
32-
import { IIdentityType } from './types.interfaces';
32+
import {
33+
CommerceEventType,
34+
EventType,
35+
IdentityType,
36+
PromotionActionType,
37+
} from './types';
3338
import IntegrationCapture from './integrationCapture';
3439
import { INativeSdkHelpers } from './nativeSdkHelpers.interfaces';
3540
import { ICookieSyncManager, IPixelConfiguration } from './cookieSyncManager.interfaces';
@@ -154,7 +159,10 @@ interface IEvents {
154159
export interface MParticleWebSDK {
155160
addForwarder(mockForwarder: MPForwarder): void;
156161
_IntegrationCapture: IntegrationCapture;
157-
IdentityType: IIdentityType;
162+
IdentityType: valueof<typeof IdentityType>;
163+
CommerceEventType: valueof<typeof CommerceEventType>;
164+
EventType: valueof<typeof EventType>;
165+
PromotionType: valueof<typeof PromotionActionType>;
158166
_Identity: IIdentity;
159167
Identity: SDKIdentityApi;
160168
Logger: SDKLoggerApi;
@@ -189,7 +197,7 @@ export interface MParticleWebSDK {
189197
getDeviceId(): string;
190198
setDeviceId(deviceId: string): void;
191199
setSessionAttribute(key: string, value: string): void;
192-
getInstance(): MParticleWebSDK; // TODO: Create a new type for MParticleWebSDKInstance
200+
getInstance(instanceName?: string): MParticleWebSDK; // TODO: Create a new type for MParticleWebSDKInstance
193201
ServerModel();
194202
upload();
195203
setLogLevel(logLevel: LogLevelType): void;
@@ -207,6 +215,7 @@ export interface MParticleWebSDK {
207215
ProductActionType: SDKProductActionType;
208216
generateHash(value: string): string;
209217
isIOS?: boolean;
218+
sessionManager: Pick<ISessionManager, 'getSession'>;
210219
}
211220

212221
// Used in cases where server requires booleans as strings

test/src/_test.index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import './config/setup';
33

44
// Import each test module
5+
import './tests-mparticle-instance-manager';
56
import './tests-identity';
67
import './tests-batchUploader';
78
import './tests-core-sdk';
@@ -23,7 +24,6 @@ import './tests-mParticleUser';
2324
import './tests-self-hosting-specific';
2425
import './tests-runtimeToBatchEventsDTO';
2526
import './tests-apiClient';
26-
import './tests-mparticle-instance-manager';
2727
import './tests-queue-public-methods';
2828
import './tests-batchUploader_3';
2929
import './tests-validators';

0 commit comments

Comments
 (0)