Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOB-9568] update "criterias" to "criteriaSets" #456

Merged
merged 1 commit into from
Sep 25, 2024
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
16 changes: 8 additions & 8 deletions src/anonymousUserTracking/complexCriteria.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('complexCriteria', () => {
const result = checker.getMatchedCriteria(
JSON.stringify({
count: 1,
criterias: [
criteriaSets: [
{
criteriaId: '98',
name: 'Custom Event',
Expand Down Expand Up @@ -215,7 +215,7 @@ describe('complexCriteria', () => {
const result = checker.getMatchedCriteria(
JSON.stringify({
count: 1,
criterias: [
criteriaSets: [
{
criteriaId: '98',
name: 'Custom Event',
Expand Down Expand Up @@ -378,7 +378,7 @@ describe('complexCriteria', () => {
const result = checker.getMatchedCriteria(
JSON.stringify({
count: 1,
criterias: [
criteriaSets: [
{
criteriaId: '99',
name: 'Custom Event',
Expand Down Expand Up @@ -539,7 +539,7 @@ describe('complexCriteria', () => {
const result = checker.getMatchedCriteria(
JSON.stringify({
count: 1,
criterias: [
criteriaSets: [
{
criteriaId: '99',
name: 'Custom Event',
Expand Down Expand Up @@ -725,7 +725,7 @@ describe('complexCriteria', () => {
const result = checker.getMatchedCriteria(
JSON.stringify({
count: 1,
criterias: [
criteriaSets: [
{
criteriaId: '100',
name: 'Custom Event',
Expand Down Expand Up @@ -893,7 +893,7 @@ describe('complexCriteria', () => {
const result = checker.getMatchedCriteria(
JSON.stringify({
count: 1,
criterias: [
criteriaSets: [
{
criteriaId: '100',
name: 'Custom Event',
Expand Down Expand Up @@ -1044,7 +1044,7 @@ describe('complexCriteria', () => {
const result = checker.getMatchedCriteria(
JSON.stringify({
count: 1,
criterias: [
criteriaSets: [
{
criteriaId: '101',
name: 'Complex Criteria 4: (NOT 9) AND 10',
Expand Down Expand Up @@ -1143,7 +1143,7 @@ describe('complexCriteria', () => {
const result = checker.getMatchedCriteria(
JSON.stringify({
count: 1,
criterias: [
criteriaSets: [
{
criteriaId: '101',
name: 'Complex Criteria 4: (NOT 9) AND 10',
Expand Down
4 changes: 2 additions & 2 deletions src/anonymousUserTracking/criteriaCompletionChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
}

class CriteriaCompletionChecker {
private localStoredEventList: any[];

Check warning on line 39 in src/anonymousUserTracking/criteriaCompletionChecker.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type

constructor(localStoredEventList: string) {
this.localStoredEventList = JSON.parse(localStoredEventList);
Expand All @@ -47,8 +47,8 @@

try {
const json = JSON.parse(criteriaData);
if (json.criterias) {
criteriaId = this.findMatchedCriteria(json.criterias);
if (json.criteriaSets) {
criteriaId = this.findMatchedCriteria(json.criteriaSets);
}
} catch (e) {
this.handleJSONException(e);
Expand All @@ -72,8 +72,8 @@
return matchingCriteria ? matchingCriteria.criteriaId : null;
}

private prepareEventsToProcess(): any[] {

Check warning on line 75 in src/anonymousUserTracking/criteriaCompletionChecker.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
const eventsToProcess: any[] = this.getEventsWithCartItems();

Check warning on line 76 in src/anonymousUserTracking/criteriaCompletionChecker.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
const nonPurchaseEvents: any[] = this.getNonCartEvents();

nonPurchaseEvents.forEach((event) => {
Expand Down
41 changes: 24 additions & 17 deletions src/anonymousUserTracking/tests/anonymousUserEventManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ const localStorageMock = {
removeItem: jest.fn()
};

jest.mock('../criteriaCompletionChecker', () => {
return jest.fn().mockImplementation(() => ({
jest.mock('../criteriaCompletionChecker', () =>
jest.fn().mockImplementation(() => ({
getMatchedCriteria: jest.fn()
}));
});
}))
);

jest.mock('../../request', () => ({
baseIterableRequest: jest.fn()
Expand Down Expand Up @@ -88,7 +88,7 @@ describe('AnonymousUserEventManager', () => {
if (key === 'criteria') {
return JSON.stringify({
count: 1,
criterias: [
criteriaSets: [
{
criteriaId: '6',
name: 'EventCriteria',
Expand Down Expand Up @@ -122,7 +122,8 @@ describe('AnonymousUserEventManager', () => {
}
]
});
} else if (key === SHARED_PREFS_ANON_SESSIONS) {
}
if (key === SHARED_PREFS_ANON_SESSIONS) {
return JSON.stringify(userData);
}
return null;
Expand Down Expand Up @@ -150,7 +151,7 @@ describe('AnonymousUserEventManager', () => {
if (key === 'criteria') {
return JSON.stringify({
count: 1,
criterias: [
criteriaSets: [
{
criteriaId: '6',
name: 'EventCriteria',
Expand Down Expand Up @@ -184,7 +185,8 @@ describe('AnonymousUserEventManager', () => {
}
]
});
} else if (key === SHARED_PREFS_EVENT_LIST_KEY) {
}
if (key === SHARED_PREFS_EVENT_LIST_KEY) {
return JSON.stringify(eventData);
}
return null;
Expand All @@ -210,7 +212,7 @@ describe('AnonymousUserEventManager', () => {
if (key === 'criteria') {
return JSON.stringify({
count: 1,
criterias: [
criteriaSets: [
{
criteriaId: '6',
name: 'EventCriteria',
Expand Down Expand Up @@ -244,7 +246,8 @@ describe('AnonymousUserEventManager', () => {
}
]
});
} else if (key === SHARED_PREFS_EVENT_LIST_KEY) {
}
if (key === SHARED_PREFS_EVENT_LIST_KEY) {
return JSON.stringify(eventData);
}
return null;
Expand All @@ -269,7 +272,8 @@ describe('AnonymousUserEventManager', () => {
(localStorage.getItem as jest.Mock).mockImplementation((key) => {
if (key === 'criteria') {
return null;
} else if (key === SHARED_PREFS_EVENT_LIST_KEY) {
}
if (key === SHARED_PREFS_EVENT_LIST_KEY) {
return JSON.stringify(eventData);
}
return null;
Expand All @@ -295,7 +299,7 @@ describe('AnonymousUserEventManager', () => {
if (key === 'criteria') {
return JSON.stringify({
count: 1,
criterias: [
criteriaSets: [
{
criteriaId: '6',
name: 'UpdateUserCriteria',
Expand Down Expand Up @@ -329,7 +333,8 @@ describe('AnonymousUserEventManager', () => {
}
]
});
} else if (key === SHARED_PREFS_EVENT_LIST_KEY) {
}
if (key === SHARED_PREFS_EVENT_LIST_KEY) {
return JSON.stringify(userData);
}
return null;
Expand Down Expand Up @@ -371,7 +376,7 @@ describe('AnonymousUserEventManager', () => {
if (key === 'criteria') {
return JSON.stringify({
count: 1,
criterias: [
criteriaSets: [
{
criteriaId: '6',
name: 'shoppingCartItemsCriteria',
Expand Down Expand Up @@ -412,7 +417,8 @@ describe('AnonymousUserEventManager', () => {
}
]
});
} else if (key === SHARED_PREFS_EVENT_LIST_KEY) {
}
if (key === SHARED_PREFS_EVENT_LIST_KEY) {
return JSON.stringify(userData);
}
return null;
Expand Down Expand Up @@ -454,7 +460,7 @@ describe('AnonymousUserEventManager', () => {
if (key === 'criteria') {
return JSON.stringify({
count: 1,
criterias: [
criteriaSets: [
{
criteriaId: '6',
name: 'CartUpdateItemsCriteria',
Expand Down Expand Up @@ -495,7 +501,8 @@ describe('AnonymousUserEventManager', () => {
}
]
});
} else if (key === SHARED_PREFS_EVENT_LIST_KEY) {
}
if (key === SHARED_PREFS_EVENT_LIST_KEY) {
return JSON.stringify(userData);
}
return null;
Expand Down
Loading
Loading