Skip to content

Commit

Permalink
BC-3577 - adapt unit tests to latest server changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bergatco committed Apr 19, 2024
1 parent bc08106 commit 09c5a0a
Show file tree
Hide file tree
Showing 3 changed files with 365 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const collaborativeTextEditorApi = () => {
): Promise<string | undefined> => {
try {
const response =
await collaborativeTextEditorApi.collaborativeTextEditorControllerGetCollaborativeTextEditorForParent(
await collaborativeTextEditorApi.collaborativeTextEditorControllerGetOrCreateCollaborativeTextEditorForParent(
parentId,
parentType
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe("CollaborativeTextEditorApi Composable", () => {
});

describe("getUrl", () => {
describe("when collaborativeTextEditorApi.collaborativeTextEditorControllerGetCollaborativeTextEditorForParent returns successful", () => {
describe("when collaborativeTextEditorControllerGetOrCreateCollaborativeTextEditorForParent returns successful", () => {
const setup = () => {
const parentId = ObjectIdMock();
const parentType =
Expand All @@ -65,7 +65,7 @@ describe("CollaborativeTextEditorApi Composable", () => {
jest
.spyOn(serverApi, "CollaborativeTextEditorApiFactory")
.mockReturnValue(collaborativeTextEditorApi);
collaborativeTextEditorApi.collaborativeTextEditorControllerGetCollaborativeTextEditorForParent.mockResolvedValueOnce(
collaborativeTextEditorApi.collaborativeTextEditorControllerGetOrCreateCollaborativeTextEditorForParent.mockResolvedValueOnce(
response
);

Expand All @@ -79,17 +79,17 @@ describe("CollaborativeTextEditorApi Composable", () => {
};
};

it("should call collaborativeTextEditorApi.collaborativeTextEditorControllerGetCollaborativeTextEditorForParent", async () => {
it("should call collaborativeTextEditorApi.collaborativeTextEditorControllerGetOrCreateCollaborativeTextEditorForParent", async () => {
const { parentId, parentType, collaborativeTextEditorApi } = setup();
const { getUrl } = useCollaborativeTextEditorApi();

await getUrl(parentId, parentType);

expect(
collaborativeTextEditorApi.collaborativeTextEditorControllerGetCollaborativeTextEditorForParent
collaborativeTextEditorApi.collaborativeTextEditorControllerGetOrCreateCollaborativeTextEditorForParent
).toHaveBeenCalledTimes(1);
expect(
collaborativeTextEditorApi.collaborativeTextEditorControllerGetCollaborativeTextEditorForParent
collaborativeTextEditorApi.collaborativeTextEditorControllerGetOrCreateCollaborativeTextEditorForParent
).toHaveBeenCalledWith(parentId, parentType);
});

Expand All @@ -103,7 +103,7 @@ describe("CollaborativeTextEditorApi Composable", () => {
});
});

describe("when collaborativeTextEditorApi.collaborativeTextEditorControllerGetCollaborativeTextEditorForParent returns error", () => {
describe("when collaborativeTextEditorControllerGetOrCreateCollaborativeTextEditorForParent returns error", () => {
const setup = (message?: string) => {
const parentId = ObjectIdMock();
const parentType =
Expand All @@ -117,7 +117,7 @@ describe("CollaborativeTextEditorApi Composable", () => {
jest
.spyOn(serverApi, "CollaborativeTextEditorApiFactory")
.mockReturnValue(collaborativeTextEditorApi);
collaborativeTextEditorApi.collaborativeTextEditorControllerGetCollaborativeTextEditorForParent.mockRejectedValue(
collaborativeTextEditorApi.collaborativeTextEditorControllerGetOrCreateCollaborativeTextEditorForParent.mockRejectedValue(
responseError
);

Expand Down
Loading

0 comments on commit 09c5a0a

Please sign in to comment.