Skip to content

Commit

Permalink
Migrated SafeCommentsCollection test to vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
marekdedic committed Jan 15, 2025
1 parent de96699 commit 33d63d7
Showing 1 changed file with 25 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { expect, test } from "@jest/globals";
import { mocked } from "jest-mock";
import { expect, test, vi } from "vitest";

import { SafeCommentsCollection_ } from "../../../../src/backend/utils/SafeDriveService/SafeCommentsCollection";
import {
Expand Down Expand Up @@ -48,9 +47,9 @@ test("insert works", () => {
};

global.Drive.Comments = mockedCommentsCollection();
const insert = mocked(global.Drive.Comments).insert.mockReturnValueOnce(
comment,
);
const insert = vi
.mocked(global.Drive.Comments)
.insert.mockReturnValueOnce(comment);

const commentsCollection = new SafeCommentsCollection_();

Expand Down Expand Up @@ -80,9 +79,9 @@ test("insert throws an error on an invalid comment", () => {
};

global.Drive.Comments = mockedCommentsCollection();
const insert = mocked(global.Drive.Comments).insert.mockReturnValueOnce(
comment,
);
const insert = vi
.mocked(global.Drive.Comments)
.insert.mockReturnValueOnce(comment);

const commentsCollection = new SafeCommentsCollection_();

Expand Down Expand Up @@ -134,9 +133,9 @@ test("list works", () => {
};

global.Drive.Comments = mockedCommentsCollection();
const list = mocked(global.Drive.Comments).list.mockReturnValueOnce(
commentList,
);
const list = vi
.mocked(global.Drive.Comments)
.list.mockReturnValueOnce(commentList);

const commentsCollection = new SafeCommentsCollection_();

Expand Down Expand Up @@ -188,9 +187,9 @@ test("list works with optional arguments", () => {
};

global.Drive.Comments = mockedCommentsCollection();
const list = mocked(global.Drive.Comments).list.mockReturnValueOnce(
commentList,
);
const list = vi
.mocked(global.Drive.Comments)
.list.mockReturnValueOnce(commentList);

const commentsCollection = new SafeCommentsCollection_();

Expand Down Expand Up @@ -249,9 +248,9 @@ test("list throws an error on an invalid comment", () => {
};

global.Drive.Comments = mockedCommentsCollection();
const list = mocked(global.Drive.Comments).list.mockReturnValueOnce(
commentList,
);
const list = vi
.mocked(global.Drive.Comments)
.list.mockReturnValueOnce(commentList);

const commentsCollection = new SafeCommentsCollection_();

Expand All @@ -268,9 +267,9 @@ test("list throws an error on an invalid comment list", () => {
};

global.Drive.Comments = mockedCommentsCollection();
const list = mocked(global.Drive.Comments).list.mockReturnValueOnce(
commentList,
);
const list = vi
.mocked(global.Drive.Comments)
.list.mockReturnValueOnce(commentList);

const commentsCollection = new SafeCommentsCollection_();

Expand Down Expand Up @@ -313,9 +312,9 @@ test("list throws an error on missing replies", () => {
};

global.Drive.Comments = mockedCommentsCollection();
const list = mocked(global.Drive.Comments).list.mockReturnValueOnce(
commentList,
);
const list = vi
.mocked(global.Drive.Comments)
.list.mockReturnValueOnce(commentList);

const commentsCollection = new SafeCommentsCollection_();

Expand Down Expand Up @@ -366,9 +365,9 @@ test("list throws an error on an invalid reply", () => {
};

global.Drive.Comments = mockedCommentsCollection();
const list = mocked(global.Drive.Comments).list.mockReturnValueOnce(
commentList,
);
const list = vi
.mocked(global.Drive.Comments)
.list.mockReturnValueOnce(commentList);

const commentsCollection = new SafeCommentsCollection_();

Expand Down

0 comments on commit 33d63d7

Please sign in to comment.