Skip to content

Commit

Permalink
wrote a test case for taskRequestById
Browse files Browse the repository at this point in the history
  • Loading branch information
Akshat187 committed Dec 27, 2024
1 parent 9675144 commit 6b28054
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/unit/models/task-requests.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {
fetchTaskRequests,
approveTaskRequest,
fetchPaginatedTaskRequests,
fetchTaskRequestById,
addNewFields,
removeOldField,
addUsersCountAndCreatedAt,
Expand Down Expand Up @@ -197,6 +198,31 @@ describe("Task requests | models", function () {
});
});

describe("fetchTaskRequestById", function () {
afterEach(async function () {
await cleanDb();
});

it("should return task request data when task request exists", async function () {
const requestData = mockData.taskRequestData;
const addedTaskRequest = await createRequest(requestData, "testUser");
const result = await fetchTaskRequestById(addedTaskRequest.id);
const assert = require("chai").assert;
assert.isTrue(result.taskRequestExists, "Task request should exist");

expect(result.taskRequestExists).to.be.equal(true);
expect(result.taskRequestData.id).to.equal(addedTaskRequest.id);
});

it("should return taskRequestExists as false when task request does not exist", async function () {
const mockTaskRequestId = "taskRequest1234";
const requestData = mockData.taskRequestData;
await createRequest(requestData, "testUser");
const result = await fetchTaskRequestById(mockTaskRequestId);
expect(result.taskRequestExists).to.be.equal(false);
});
});

describe("fetchTaskRequests", function () {
beforeEach(async function () {
const approvedTaskRequest = {
Expand Down

0 comments on commit 6b28054

Please sign in to comment.