Skip to content

Commit

Permalink
Merge branch 'develop' into feat/MKT-7848-event-registration
Browse files Browse the repository at this point in the history
  • Loading branch information
Amitkanswal authored Sep 30, 2024
2 parents 5bc69ec + 5f16a10 commit 0b2e1ca
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
13 changes: 9 additions & 4 deletions __test__/stack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,18 +188,23 @@ describe("Stack", () => {
});

it("getContentTypes", (done) => {
let params: { [key: string]: any } = { sample: "parameter" };
let params: { [key: string]: any } = { sample: "parameter", branch: "sampleBranch" };
let query = { sample: "query" };
let expectedParams = { sample: "parameter", query };

stack.getContentTypes(query, params).then((data) => {
params.query = query;
expect(data).toEqual({});
expect(connection.sendToParent).toHaveBeenCalledWith(
"stackQuery",
{ params, action: "getContentTypes" }
{
params: expectedParams,
action: "getContentTypes",
headers: { branch: "sampleBranch" }
}
);
done();
});
});
});

it("getContentTypes error case", async () => {
let newStack = new Stack(
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/app-sdk",
"version": "2.1.3",
"version": "2.1.0",
"types": "dist/src/index.d.ts",
"description": "The Contentstack App SDK allows you to customize your Contentstack applications.",
"main": "dist/index.js",
Expand Down
12 changes: 10 additions & 2 deletions src/stack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,17 @@ class Stack {
* @return {Object} A promise object which will be resolved with details of the content type.
*/
getContentTypes(query = {}, params: { [key: string]: any } = {}): Promise<{ [key: string]: any }> {
const optionParams = params;
const {branch, ...optionParams} = params;
optionParams.query = query;
const options = { params: optionParams, action: 'getContentTypes' };

const options: any = {
params: optionParams,
action: 'getContentTypes',
};

if (branch) {
options.headers = { branch };
}
return this._connection.sendToParent('stackQuery', options).then(onData).catch(onError);
}

Expand Down

0 comments on commit 0b2e1ca

Please sign in to comment.