Skip to content

Commit

Permalink
use display tagging functionfor the tagging info url
Browse files Browse the repository at this point in the history
  • Loading branch information
CachedaCodes committed Jan 4, 2024
1 parent cec0e6e commit 25b8e0a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
12 changes: 8 additions & 4 deletions packages/x-adapter-platform/src/mappers/__tests__/url.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { extractUrlParameters, getDisplayClickTagging, getTaggingInfoFromUrl } from '../url.utils';
import {
extractUrlParameters,
getDisplayTaggingInfoFromUrl,
getTaggingInfoFromUrl
} from '../url.utils';

describe('url utils methods tests', () => {
describe('extractUrlParameters', () => {
Expand Down Expand Up @@ -45,14 +49,14 @@ describe('url utils methods tests', () => {

describe('getDisplayClickTagging', () => {
it('should not break when dealing with bad urls', () => {
expect(getDisplayClickTagging('null')).toStrictEqual({
expect(getDisplayTaggingInfoFromUrl('null')).toStrictEqual({
url: 'null',
params: { displayId: 'no_query', follow: false }
});
});

it('should retrieve the tagging info from the url, replacing q with displayId', () => {
const { url, params } = getDisplayClickTagging(
const { url, params } = getDisplayTaggingInfoFromUrl(
'https://api.empathy.co/?q=chips&env=mobile&lang=english&lang=spanish'
);
expect(url).toBe('https://api.empathy.co/');
Expand All @@ -65,7 +69,7 @@ describe('url utils methods tests', () => {
});

it('should set no_query tagging info when no q param exist as in topclicked response', () => {
const { url, params } = getDisplayClickTagging(
const { url, params } = getDisplayTaggingInfoFromUrl(
'https://api.empathy.co/?env=mobile&lang=english&lang=spanish'
);
expect(url).toBe('https://api.empathy.co/');
Expand Down
2 changes: 1 addition & 1 deletion packages/x-adapter-platform/src/mappers/url.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function getTaggingInfoFromUrl(taggingUrl: string): TaggingRequest {
*
* @public
*/
export function getDisplayClickTagging(displayTaggingUrl: string): TaggingRequest {
export function getDisplayTaggingInfoFromUrl(displayTaggingUrl: string): TaggingRequest {
const displayClickTagging = getTaggingInfoFromUrl(displayTaggingUrl);
const displayClickTaggingParams = displayClickTagging.params;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createMutableSchema } from '@empathyco/x-adapter';
import { Result } from '@empathyco/x-types';
import { getDisplayClickTagging, getTaggingInfoFromUrl } from '../../mappers/url.utils';
import { getDisplayTaggingInfoFromUrl, getTaggingInfoFromUrl } from '../../mappers/url.utils';
import { PlatformResult } from '../../types/models/result.model';

/**
Expand Down Expand Up @@ -36,7 +36,7 @@ export const resultSchema = createMutableSchema<PlatformResult, Result>({
add2cart: ({ add2cart }) => getTaggingInfoFromUrl(add2cart),
checkout: ({ checkout }) => getTaggingInfoFromUrl(checkout),
click: ({ click }) => getTaggingInfoFromUrl(click),
displayClick: ({ displayClick }) => getDisplayClickTagging(displayClick)
displayClick: ({ displayClick }) => getDisplayTaggingInfoFromUrl(displayClick)
}
}
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createMutableSchema } from '@empathyco/x-adapter';
import { SearchResponse } from '@empathyco/x-types';
import { getTaggingInfoFromUrl } from '../../mappers/url.utils';
import { getDisplayTaggingInfoFromUrl, getTaggingInfoFromUrl } from '../../mappers/url.utils';
import { PlatformSearchResponse } from '../../types/responses/search-response.model';
import { bannerSchema } from '../models/banner.schema';
import { facetSchema } from '../models/facet.schema';
Expand Down Expand Up @@ -42,5 +42,5 @@ export const searchResponseSchema = createMutableSchema<PlatformSearchResponse,
$subSchema: partialResultsSchema
},
queryTagging: ({ catalog }) => getTaggingInfoFromUrl(catalog?.tagging?.query),
displayTagging: ({ catalog }) => getTaggingInfoFromUrl(catalog?.tagging?.display)
displayTagging: ({ catalog }) => getDisplayTaggingInfoFromUrl(catalog?.tagging?.display)
});

0 comments on commit 25b8e0a

Please sign in to comment.