add project creation and listing

This commit is contained in:
João Geonizeli
2022-07-09 10:05:01 -03:00
parent c3fe6e6f1c
commit e0dd6c2307
27 changed files with 256 additions and 26 deletions

View File

@@ -0,0 +1,28 @@
import { AppDataSource } from "../../infra/dataSource";
import { projectRepository } from "../../repository/project.repository";
import { userRepository } from "../../repository/user.repository";
import { cleanDataSource } from "../../utils/cleanDataSource";
describe("Project", () => {
beforeAll(async () => {
await AppDataSource.initialize();
await cleanDataSource(AppDataSource, ["project", "user"]);
});
describe("relations", () => {
it("should have many projects", async () => {
const user = await userRepository.save({
name: "John Doe",
email: "john.doe@example.com",
encryptedPassword: 'encryptedPassword'
})
const project = await projectRepository.save({
name: "My first project",
user,
})
expect(project.user.id).toBe(user.id)
});
});
});