Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 921ba4b6 authored by a's avatar a
Browse files

add base mongo tests

parent c83445be
No related branches found
No related tags found
No related merge requests found
Pipeline #598354 canceled
......@@ -2,6 +2,7 @@ const chai = require('chai');
const chaiHttp = require("chai-http");
const express = require("../src/servers/serverTwitter");
const databaseManager = require('../src/mongoose');
const mongoose = require('mongoose');
chai.should();
chai.use(chaiHttp);
......@@ -29,3 +30,29 @@ describe("test twitter webhook", function () {
})
})
describe("test database communication and queries", function(){
let user;
beforeEach(async function() {
// runs before each test in this block
user = await databaseManager.createBlankUser();
});
afterEach(async function(){
await databaseManager.deleteUserByUserID(user._id);
})
it("Should access created user by ID", async function()
{
const foundUser = await databaseManager.findUserByUserID(user._id);
const foundUserID = foundUser._id.toString();
foundUserID.should.equal(user._id.toString());
})
it("Should not find user by bogus ID", async function(){
const bogusID = new mongoose.Types.ObjectId();
console.log("bogusID:", bogusID);
bogusID.should.not.equal(user._id);
})
})
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment