Skip to content

Commit

Permalink
feat(rest-api-client): add a method of app.addPlugins
Browse files Browse the repository at this point in the history
  • Loading branch information
shabaraba committed Jul 30, 2024
1 parent a832ac8 commit 1eb54fb
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/rest-api-client/src/client/AppClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,4 +667,16 @@ export class AppClient extends BaseClient {
});
return this.client.get(path, rest);
}

public addPlugins(params: {
app: AppID;
ids: string[];
revision?: Revision;
}): Promise<{ revision: string }> {
const path = this.buildPathWithGuestSpaceId({
endpointName: "app/plugins",
preview: true,
});
return this.client.post(path, params);
}
}
18 changes: 18 additions & 0 deletions packages/rest-api-client/src/client/__tests__/app/Plugins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,22 @@ describe("AppClient: plugins", () => {
});
});
});

describe("addPlugins", () => {
const params = { app: APP_ID, ids: ["abc", "xyz"], revision: 1 };
beforeEach(async () => {
await appClient.addPlugins(params);
});
it("should pass the path to the http client", () => {
expect(mockClient.getLogs()[0].path).toBe(
"/k/v1/preview/app/plugins.json",
);
});
it("should send a post request", () => {
expect(mockClient.getLogs()[0].method).toBe("post");
});
it("should pass the param to the http client", () => {
expect(mockClient.getLogs()[0].params).toEqual(params);
});
});
});

0 comments on commit 1eb54fb

Please sign in to comment.