This commit is contained in:
parent
cbf7a66390
commit
050b759cce
@ -13,7 +13,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "ts-node ./src/main.ts",
|
"dev": "ts-node ./src/main.ts",
|
||||||
"migrate": "prisma migrate dev --name add-profile --preview-feature",
|
"migrate": "prisma migrate dev --name add-profile --preview-feature",
|
||||||
"test": "jest"
|
"test": "jest --detectOpenHandles"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@prisma/client": "2.18.0"
|
"@prisma/client": "2.18.0"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { PrismaClient } from "@prisma/client";
|
||||||
import {
|
import {
|
||||||
createUser,
|
createUser,
|
||||||
findOneByEmail,
|
findOneByEmail,
|
||||||
@ -5,6 +6,8 @@ import {
|
|||||||
findOneProfileByEmail,
|
findOneProfileByEmail,
|
||||||
} from "../src/User/UserService";
|
} from "../src/User/UserService";
|
||||||
|
|
||||||
|
const prisma = new PrismaClient();
|
||||||
|
|
||||||
// all tests about user
|
// all tests about user
|
||||||
describe("user", function () {
|
describe("user", function () {
|
||||||
const email = "sombochea@cubetiqs.com";
|
const email = "sombochea@cubetiqs.com";
|
||||||
@ -18,7 +21,7 @@ describe("user", function () {
|
|||||||
email: email,
|
email: email,
|
||||||
name: name,
|
name: name,
|
||||||
})
|
})
|
||||||
.then((user) => {
|
.then(async (user) => {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw Error("user is null");
|
throw Error("user is null");
|
||||||
}
|
}
|
||||||
@ -28,7 +31,7 @@ describe("user", function () {
|
|||||||
expect(name).toBe(user.name);
|
expect(name).toBe(user.name);
|
||||||
|
|
||||||
// create profile
|
// create profile
|
||||||
createProfile(user, {
|
await createProfile(user, {
|
||||||
bio: "Software Developer",
|
bio: "Software Developer",
|
||||||
})
|
})
|
||||||
.then((profile) => {
|
.then((profile) => {
|
||||||
@ -39,9 +42,11 @@ describe("user", function () {
|
|||||||
expect(profile).not.toBeNull();
|
expect(profile).not.toBeNull();
|
||||||
expect(bio).toBe(profile.bio);
|
expect(bio).toBe(profile.bio);
|
||||||
})
|
})
|
||||||
.catch((e) => console.error(e));
|
.catch((e) => console.error(e))
|
||||||
|
.finally(() => done());
|
||||||
})
|
})
|
||||||
.catch((e) => console.error(e));
|
.catch((e) => console.error(e))
|
||||||
|
.finally(() => done());
|
||||||
});
|
});
|
||||||
|
|
||||||
// check user test
|
// check user test
|
||||||
@ -56,9 +61,8 @@ describe("user", function () {
|
|||||||
expect(email).toBe(user.email);
|
expect(email).toBe(user.email);
|
||||||
expect(name).toBe(user.name);
|
expect(name).toBe(user.name);
|
||||||
})
|
})
|
||||||
.catch((e) => console.error(e));
|
.catch((e) => console.error(e))
|
||||||
|
.finally(() => done());
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// check profile included user test
|
// check profile included user test
|
||||||
@ -74,8 +78,16 @@ describe("user", function () {
|
|||||||
expect(email).toBe(profile.user.email);
|
expect(email).toBe(profile.user.email);
|
||||||
expect(name).toBe(profile.user.name);
|
expect(name).toBe(profile.user.name);
|
||||||
})
|
})
|
||||||
.catch((e) => console.error(e));
|
.catch((e) => console.error(e))
|
||||||
|
.finally(() => done());
|
||||||
|
});
|
||||||
|
|
||||||
|
// try to finish
|
||||||
|
afterAll(async (done) => {
|
||||||
|
await prisma.$disconnect();
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// after all
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user