Skip to content

Commit

Permalink
refactor: Migrate Instance Manager Tests to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
alexs-mparticle committed Nov 25, 2024
1 parent b6883b6 commit 254cdd0
Show file tree
Hide file tree
Showing 3 changed files with 231 additions and 148 deletions.
17 changes: 13 additions & 4 deletions src/sdkRuntimeModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@mparticle/web-sdk';
import { IStore } from './store';
import Validators from './validators';
import { Dictionary } from './utils';
import { Dictionary, valueof } from './utils';
import { IServerModel } from './serverModel';
import { IKitConfigs } from './configAPIClient';
import { SDKConsentApi, SDKConsentState } from './consent';
Expand All @@ -29,7 +29,12 @@ import {
IdentityCallback,
ISDKUserAttributes,
} from './identity-user-interfaces';
import { IIdentityType } from './types.interfaces';
import {
CommerceEventType,
EventType,
IdentityType,
PromotionActionType,
} from './types';
import IntegrationCapture from './integrationCapture';
import { INativeSdkHelpers } from './nativeSdkHelpers.interfaces';
import { ICookieSyncManager, IPixelConfiguration } from './cookieSyncManager.interfaces';
Expand Down Expand Up @@ -154,7 +159,10 @@ interface IEvents {
export interface MParticleWebSDK {
addForwarder(mockForwarder: MPForwarder): void;
_IntegrationCapture: IntegrationCapture;
IdentityType: IIdentityType;
IdentityType: valueof<typeof IdentityType>;
CommerceEventType: valueof<typeof CommerceEventType>;
EventType: valueof<typeof EventType>;
PromotionType: valueof<typeof PromotionActionType>;
_Identity: IIdentity;
Identity: SDKIdentityApi;
Logger: SDKLoggerApi;
Expand Down Expand Up @@ -189,7 +197,7 @@ export interface MParticleWebSDK {
getDeviceId(): string;
setDeviceId(deviceId: string): void;
setSessionAttribute(key: string, value: string): void;
getInstance(): MParticleWebSDK; // TODO: Create a new type for MParticleWebSDKInstance
getInstance(instanceName?: string): MParticleWebSDK; // TODO: Create a new type for MParticleWebSDKInstance
ServerModel();
upload();
setLogLevel(logLevel: LogLevelType): void;
Expand All @@ -207,6 +215,7 @@ export interface MParticleWebSDK {
ProductActionType: SDKProductActionType;
generateHash(value: string): string;
isIOS?: boolean;
sessionManager: Pick<ISessionManager, 'getSession'>;
}

// Used in cases where server requires booleans as strings
Expand Down
2 changes: 1 addition & 1 deletion test/src/_test.index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import './config/setup';

// Import each test module
import './tests-mparticle-instance-manager';
import './tests-identity';
import './tests-batchUploader';
import './tests-core-sdk';
Expand All @@ -23,7 +24,6 @@ import './tests-mParticleUser';
import './tests-self-hosting-specific';
import './tests-runtimeToBatchEventsDTO';
import './tests-apiClient';
import './tests-mparticle-instance-manager';
import './tests-queue-public-methods';
import './tests-batchUploader_3';
import './tests-validators';
Expand Down
Loading

0 comments on commit 254cdd0

Please sign in to comment.