Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/core/__tests__/IdentityTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Identity', () => {
let identifiers = {"testKey": "testValue"};
let authState = MobileVisitorAuthenticationState.LOGGED_OUT;
await Identity.syncIdentifiersWithAuthState(identifiers, authState);
expect(spy).toHaveBeenCalledWith(identifiers, authState);
expect(spy).toHaveBeenCalledWith(identifiers, 'VISITOR_AUTH_STATE_LOGGED_OUT');
});

test('syncIdentifier is called with correct parameters', async () => {
Expand All @@ -45,7 +45,7 @@ describe('Identity', () => {
let identifierType = "testIdType"
let authState = MobileVisitorAuthenticationState.AUTHENTICATED;
await Identity.syncIdentifier(identifier, identifierType, authState);
expect(spy).toHaveBeenCalledWith(identifier, identifierType, authState);
expect(spy).toHaveBeenCalledWith(identifier, identifierType, 'VISITOR_AUTH_STATE_AUTHENTICATED');
});

test('appendVisitorInfoForURL is called with correct parameters', async () => {
Expand Down
10 changes: 6 additions & 4 deletions packages/core/__tests__/MobileCoreTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ describe('MobileCore', () => {
const spy = jest.spyOn(NativeModules.AEPCore, 'setLogLevel');
let logLevel = LogLevel.DEBUG;
await MobileCore.setLogLevel(logLevel);
expect(spy).toHaveBeenCalledWith(logLevel);
expect(spy).toHaveBeenCalledWith("DEBUG");
});

it('getLogLevel is called', async () => {
const spy = jest.spyOn(NativeModules.AEPCore, 'getLogLevel');
await MobileCore.getLogLevel();
const logLevel = await MobileCore.getLogLevel();
expect(spy).toHaveBeenCalled();
expect(logLevel).toEqual(LogLevel.DEBUG);
});

it('log is called with correct parameters', async () => {
Expand All @@ -63,13 +64,14 @@ describe('MobileCore', () => {
const spy = jest.spyOn(NativeModules.AEPCore, 'setPrivacyStatus');
let privacyStatus = PrivacyStatus.UNKNOWN;
await MobileCore.setPrivacyStatus(privacyStatus);
expect(spy).toHaveBeenCalledWith(privacyStatus);
expect(spy).toHaveBeenCalledWith("UNKNOWN");
});

it('getPrivacyStatus is called', async () => {
const spy = jest.spyOn(NativeModules.AEPCore, 'getPrivacyStatus');
await MobileCore.getPrivacyStatus();
const privacyStatus = await MobileCore.getPrivacyStatus();
expect(spy).toHaveBeenCalled();
expect(privacyStatus).toEqual('OPT_OUT');
});

it('getSdkIdentities is called', async () => {
Expand Down
38 changes: 19 additions & 19 deletions packages/core/js/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export class MobileCore{
static extensionVersion(): Promise<string>;
static configureWithAppId(appId?: string);
static updateConfiguration(configMap?: Map);
static setLogLevel(mode: string);
static getLogLevel(): Promise<string>;
static setLogLevel(mode: LogLevel);
static getLogLevel(): Promise<LogLevel>;
static log(logLevel: string, tag: string, message: string);
static setPrivacyStatus(privacyStatus: string);
static getPrivacyStatus(): Promise<string>;
static setPrivacyStatus(privacyStatus: PrivacyStatus);
static getPrivacyStatus(): Promise<PrivacyStatus>;
static getSdkIdentities(): Promise<?string>;
static dispatchEvent(event: Event): Promise<boolean>;
static dispatchEventWithResponseCallback(event: Event): Promise<Event>;
Expand All @@ -39,8 +39,8 @@ export class Lifecycle{
export class Identity{
static extensionVersion(): Promise<string>;
static syncIdentifiers(identifiers?: Map);
static syncIdentifiersWithAuthState(identifiers?: Map, authenticationState: string);
static syncIdentifier(identifierType: string, identifier: string, authenticationState: string);
static syncIdentifiersWithAuthState(identifiers?: Map, authenticationState: MobileVisitorAuthenticationState);
static syncIdentifier(identifierType: string, identifier: string, authenticationState: MobileVisitorAuthenticationState);
static appendVisitorInfoForURL(baseURL?: string): Promise<?string>;
static getUrlVariables(): Promise<?string>;
static getIdentifiers(): Promise<Array<?VisitorID>>;
Expand All @@ -50,21 +50,21 @@ export class Signal{
static extensionVersion(): Promise<string>;
}

export class PrivacyStatus{
static OPT_IN: string;
static OPT_OUT: string;
static UNKNOWN: string;
export enum PrivacyStatus{
OPT_IN = "OPT_IN",
OPT_OUT = "OPT_OUT",
UNKNOWN = "UNKNOWN",
}
export class LogLevel{
static ERROR: string;
static WARNING: string;
static DEBUG: string;
static VERBOSE: string;
export enum LogLevel{
ERROR = "ERROR",
WARNING = "WARNING",
DEBUG = "DEBUG",
VERBOSE = "VERBOSE",
}
export class MobileVisitorAuthenticationState{
static AUTHENTICATED: string;
static LOGGED_OUT: string;
static UNKNOWN: string;
export enum MobileVisitorAuthenticationState{
AUTHENTICATED = "VISITOR_AUTH_STATE_AUTHENTICATED",
LOGGED_OUT = "VISITOR_AUTH_STATE_LOGGED_OUT",
UNKNOWN = "VISITOR_AUTH_STATE_UNKNOWN",
}
export class VisitorID{
idOrigin: string;
Expand Down
4 changes: 2 additions & 2 deletions tests/jest/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ jest.doMock('react-native', () => {
configureWithAppId: jest.fn(),
updateConfiguration: jest.fn(),
setLogLevel: jest.fn(),
getLogLevel: jest.fn(() => new Promise(resolve => resolve(''))),
getLogLevel: jest.fn(() => new Promise(resolve => resolve('DEBUG'))),
log: jest.fn(),
setPrivacyStatus: jest.fn(),
getPrivacyStatus: jest.fn(() => new Promise(resolve => resolve(''))),
getPrivacyStatus: jest.fn(() => new Promise(resolve => resolve('OPT_OUT'))),
getSdkIdentities: jest.fn(() => new Promise(resolve => resolve(''))),
dispatchEvent: jest.fn(),
dispatchEventWithResponseCallback: jest.fn(() => new Promise(resolve => resolve(null))),
Expand Down