add project creation and listing
This commit is contained in:
28
server/src/entity/__test__/project.entity.spec.ts
Normal file
28
server/src/entity/__test__/project.entity.spec.ts
Normal 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)
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user