An error occurred while loading the file. Please try again.
method.unit.test.ts 1.85 KiB
import methods from '../functions/methods'
describe("DB methohds test", () => {
    it("returns a user from DB by email", async() => {
        const user = await methods.getUserByEmail('litehon958@whipjoy.com')
        expect(user).not.toBeNull()
    })
    it("returns a null user", async() => {
        const user = await methods.getUserByEmail('jondoe@nowhere.com') // a non-exist user
        expect(user).toBeNull()
    it("returns a user's email", async() => {
        const email = await methods.getUserEmailById(1)
        expect(email).not.toBeNull()
    it("returns null instead of a user's email", async() => {
        const email = await methods.getUserEmailById(1005) // no user has this ID
        expect(email).toBeNull()
    it("returns null from DB by token", async() => {
        const user = await methods.getUserByToken('12345678') // unvalid token
        expect(user).toBeNull() // for valid token = expect(user).not.toBeNull()
    it("returns a user's verification token, if any", async() => {
        const token = await methods.getVerificationTokenByUserId(1)
        expect(token).toBeNull()
    it("returns a user's ID, if any", async() => {
        const token = await methods.getUserIdByVerificationToken('12345678') // unvalid token
        expect(token).toBeNull() // for valid token = expect(user).not.toBeNull()
    it("returns a user's GitLab_ID, if any", async() => {
        const id = await methods.getGitlabId(1)
        expect(id).not.toBeNull()
    it("checks user email", async() => {
        const user = await methods.checkUserEmail('litehon958@whipjoy.com')
        expect(user).not.toBeNull()
    it("checks user email and return null", async() => {
        const user = await methods.checkUserEmail('jondoe@nowhere.com') // a non-exist user
        expect(user).toBeNull()