Skip to content

Commit

Permalink
adicionando testes de atualização de cliente #88
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelSSan28 committed Jun 24, 2021
1 parent bead134 commit 21299cc
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions backend/__tests__/Client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createConnection, getConnection, getRepository } from "typeorm";
import { Client } from "../src/entities/Client";
import { Professional } from "../src/entities/Professional";
import { User } from "../src/entities/User";
import { ClientService } from "../src/services/ClientService";
import { UserService } from "../src/services/UserService";


Expand Down Expand Up @@ -44,3 +45,38 @@ test("store a Client and fetch it", async () => {

expect(joe.name).toBe("Joe");
});


test("store a Client and update it", async () => {

const newClient = {
name: "Joe",
email:"joe2@gmail.com",
phone:"(86)8988-8989",
password:"doidinho123",
type:0
}

const userService = new UserService();

await userService.createUser(newClient)

let joe = await getRepository(Client).findOne({
where: {
name:"Joe"
}
});

const clientService = new ClientService();

await clientService.update({id:joe.id, name:"Joe Atualizado",phone:"(98)8988-8989"});

let joe2 = await getRepository(Client).findOne({
where: {
name:"Joe Atualizado"
}
});


expect(joe2.phone).toBe("(98)8988-8989");
});

0 comments on commit 21299cc

Please sign in to comment.