Skip to content

Commit 3bfa644

Browse files
Merge pull request #1026 from contentstack/bugfix/cmg-865
refactor: update client import and variable naming in market-app.util…
2 parents 8c4e12d + 08e818a commit 3bfa644

2 files changed

Lines changed: 9 additions & 11 deletions

File tree

api/src/utils/market-app.utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import contentstack from '@contentstack/marketplace-sdk';
1+
import {client} from '@contentstack/marketplace-sdk';
22
import { DEVURLS } from '../constants/index.js';
33

44

55

66

77
export const getAllApps = async ({ organizationUid, authtoken, region }: any) => {
88
try {
9-
const client = contentstack.client({ authtoken, host: DEVURLS?.[region] ?? DEVURLS?.NA });
10-
const data = await client.marketplace(organizationUid).findAllApps();
9+
const contentstackclient = client({ authtoken, host: DEVURLS?.[region] ?? DEVURLS?.NA });
10+
const data = await contentstackclient.marketplace(organizationUid).findAllApps();
1111
return data?.items;
1212
} catch (err) {
1313
console.info("🚀 ~ getAllApps ~ err:", err)
@@ -16,8 +16,8 @@ export const getAllApps = async ({ organizationUid, authtoken, region }: any) =>
1616

1717
export const getAppManifestAndAppConfig = async ({ organizationUid, authtoken, region, manifestUid }: any) => {
1818
try {
19-
const client = contentstack.client({ authtoken, host: DEVURLS?.[region] ?? DEVURLS?.NA });
20-
const data = await client.marketplace(organizationUid).app(manifestUid).fetch();
19+
const contentstackclient = client({ authtoken, host: DEVURLS?.[region] ?? DEVURLS?.NA });
20+
const data = await contentstackclient.marketplace(organizationUid).app(manifestUid).fetch();
2121
return data;
2222
} catch (err: any) {
2323
console.info("🚀 ~ getAppManifestAndAppConfig ~ err:", err)

api/tests/unit/utils/market-app.utils.test.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ const mockClient = {
55
};
66

77
vi.mock('@contentstack/marketplace-sdk', () => ({
8-
default: {
9-
client: vi.fn(() => mockClient),
10-
},
8+
client: vi.fn(() => mockClient),
119
}));
1210

1311
vi.mock('../../../src/constants/index.js', () => ({
@@ -17,7 +15,7 @@ vi.mock('../../../src/constants/index.js', () => ({
1715
},
1816
}));
1917

20-
import contentstack from '@contentstack/marketplace-sdk';
18+
import { client as marketplaceClient } from '@contentstack/marketplace-sdk';
2119
import {
2220
getAllApps,
2321
getAppManifestAndAppConfig,
@@ -48,7 +46,7 @@ describe('market-app.utils', () => {
4846
});
4947

5048
expect(result).toEqual(mockItems);
51-
expect(contentstack.client).toHaveBeenCalledWith({
49+
expect(marketplaceClient).toHaveBeenCalledWith({
5250
authtoken: 'token-xyz',
5351
host: 'developerhub-api.contentstack.com',
5452
});
@@ -66,7 +64,7 @@ describe('market-app.utils', () => {
6664
region: 'EU',
6765
});
6866

69-
expect(contentstack.client).toHaveBeenCalledWith({
67+
expect(marketplaceClient).toHaveBeenCalledWith({
7068
authtoken: 'token',
7169
host: 'eu-developerhub-api.contentstack.com',
7270
});

0 commit comments

Comments
 (0)