Skip to content

Commit e493dca

Browse files
authoredApr 10, 2024
Merge pull request #17 from Mermaid-Chart/fix/setDocument-specify-that-projectID-is-required
fix(sdk): fix the required params of the `setDocument()` command
2 parents 75439f4 + 766066b commit e493dca

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed
 

‎packages/sdk/src/index.e2e.test.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe('setDocument', () => {
8484

8585
await client.setDocument({
8686
documentID: newDocument.documentID,
87-
id: newDocument.id, // diagram ID
87+
projectID: newDocument.projectID,
8888
title: "@mermaidchart/sdk E2E test diagram",
8989
code,
9090
});
@@ -98,15 +98,14 @@ describe('setDocument', () => {
9898
});
9999
});
100100

101-
// TODO: this function never seems to return an error, see MC-1060
102-
it.skip('should throw an error on invalid data', async() => {
101+
it('should throw an error on invalid data', async() => {
103102
const newDocument = await client.createDocument(testProjectId);
104103
documentsToDelete.add(newDocument.documentID);
105104

106105
await expect(client.setDocument({
107106
documentID: newDocument.documentID,
108-
// @ts-expect-error not setting diagram `id` should throw an error
109-
id: null,
107+
// @ts-expect-error not setting diagram `projectID` should throw an error
108+
projectID: null,
110109
})).rejects.toThrowError("400"); // should throw HTTP 400 error
111110
});
112111
});

‎packages/sdk/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export class MermaidChart {
210210
* @param document The document to update.
211211
*/
212212
public async setDocument(
213-
document: Pick<MCDocument, 'id' | 'documentID'> & Partial<MCDocument>,
213+
document: Pick<MCDocument, 'documentID' | 'projectID'> & Partial<MCDocument>,
214214
) {
215215
const {data} = await this.axios.put<{result: "ok"} | {result: "failed", error: any}>(
216216
URLS.rest.documents.pick(document).self,

0 commit comments

Comments
 (0)
Failed to load comments.