-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed failing tests for pendingVolunteer collection
- Loading branch information
Showing
8 changed files
with
42 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ const mongoose_1 = __importDefault(require("mongoose")); | |
const supertest_1 = __importDefault(require("supertest")); | ||
const index_1 = require("../index"); // Adjust the import path as needed | ||
const otp_schema_1 = __importDefault(require("../schemas/otp_schema")); | ||
const emails_schema_1 = __importDefault(require("../schemas/emails_schema")); | ||
const pending_volunteer_schema_1 = __importDefault(require("../schemas/pending_volunteer_schema")); | ||
// Mock the auth middleware | ||
jest.mock("../middleware/auth", () => { | ||
return jest.fn((req, res, next) => next()); | ||
|
@@ -36,24 +36,26 @@ describe("Authentication and Signup Route Tests", () => { | |
// Before running any tests, set up the server and clear the emailsToBeApproved collection | ||
beforeAll(() => __awaiter(void 0, void 0, void 0, function* () { | ||
server = index_1.app.listen(); | ||
// Clear the pendingVolunteer collection before running tests | ||
yield otp_schema_1.default.deleteMany({}); | ||
yield pending_volunteer_schema_1.default.deleteMany({}); | ||
// Generate an OTP for testing the login route | ||
const savedOTP = new otp_schema_1.default({ | ||
email: "[email protected]", | ||
otp: "54321", | ||
expiresAt: new Date(Date.now() + 5 * 60000) | ||
}).save(); | ||
testOTP = (yield savedOTP).otp; | ||
// Clear the emailsToBeApproved collection before running tests | ||
yield emails_schema_1.default.deleteMany({}); | ||
})); | ||
// After all tests are done, close the server and disconnect from the database | ||
afterAll((done) => { | ||
afterAll(() => __awaiter(void 0, void 0, void 0, function* () { | ||
yield otp_schema_1.default.deleteMany({}); | ||
yield pending_volunteer_schema_1.default.deleteMany({}); | ||
server.close(() => { | ||
mongoose_1.default.disconnect().then(() => { | ||
done(); | ||
}); | ||
}); | ||
}); | ||
})); | ||
// Test suite for the Signup Route (POST /volunteer/signup) | ||
describe("POST /volunteer/signup", () => { | ||
it("should request signup and return success message", () => __awaiter(void 0, void 0, void 0, function* () { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,23 +29,27 @@ describe("Authentication and Signup Route Tests", () => { | |
beforeAll(async () => { | ||
server = app.listen(); | ||
|
||
// Clear the pendingVolunteer collection before running tests | ||
await OTP.deleteMany({}); | ||
await pendingVolunteer.deleteMany({}); | ||
|
||
// Generate an OTP for testing the login route | ||
const savedOTP = new OTP({ | ||
email:"[email protected]", | ||
otp:"54321", | ||
expiresAt: new Date(Date.now() + 5 * 60000) | ||
const savedOTP = new OTP({ | ||
email: "[email protected]", | ||
otp: "54321", | ||
expiresAt: new Date(Date.now() + 5 * 60000) | ||
}).save(); | ||
testOTP = (await savedOTP).otp; | ||
|
||
// Clear the pendingVolunteer collection before running tests | ||
await pendingVolunteer.deleteMany({}); | ||
|
||
}); | ||
|
||
// After all tests are done, close the server and disconnect from the database | ||
afterAll((done) => { | ||
afterAll(async () => { | ||
await OTP.deleteMany({}); | ||
await pendingVolunteer.deleteMany({}); | ||
server.close(() => { | ||
mongoose.disconnect().then(() => { | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|