Skip to content

Commit d9640e6

Browse files
committed
👌 🧪 test: tests completed
1 parent 61dcf3b commit d9640e6

File tree

3 files changed

+185
-0
lines changed

3 files changed

+185
-0
lines changed

.eslintrc.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"env": {
3+
"commonjs": true,
4+
"es2021": true,
5+
"node": true
6+
},
7+
"extends": [
8+
"airbnb-base"
9+
],
10+
"parserOptions": {
11+
"ecmaVersion": "latest"
12+
},
13+
"rules": {
14+
}
15+
}

test/courses.test.js

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
const coursesModel = require("../src/models/coursesModel")
2+
3+
describe("GET route", () => {
4+
const course = new coursesModel({
5+
courseTitle: "teste back-end",
6+
affirmativePolicies: ["mulheres trans"],
7+
available: true,
8+
startDate: "22-06-2022",
9+
finishDate: "22-09-2022",
10+
category: ["tecnologia"],
11+
description: "curso voltado a mulheres",
12+
institutionID: "62c88976289c610293bc2cd1"
13+
});
14+
it("Deve chamar o schema e retornar o nome correto do curso", () => {
15+
expect(course.courseTitle).toBe("teste back-end");
16+
});
17+
it("Deve chamar o schema e retornar a politica afirmativa correta", () => {
18+
expect(course.affirmativePolicies).toStrictEqual(["mulheres trans"]);
19+
});
20+
it("Deve chamar o schema e retornar se esta disponivel", () => {
21+
expect(course.available).toBe(true);
22+
});
23+
it("Deve chamar o schema e retornar a data inicial", () => {
24+
expect(course.startDate).toBe("22-06-2022");
25+
});
26+
it("Deve chamar o schema e retornar a data final", () => {
27+
expect(course.finishDate).toBe("22-09-2022");
28+
});
29+
it("Deve chamar o schema e retornar a categoria correta", () => {
30+
expect(course.category).toStrictEqual(["tecnologia"]);;
31+
});
32+
it("Deve chamar o schema e retornar a descrição correta", () => {
33+
expect(course.description).toBe("curso voltado a mulheres");
34+
});
35+
it("Deve chamar o schema e retornar o id da instituição correto", () => {
36+
expect(JSON.stringify(course.institutionID).substring(1, (JSON.stringify(course.institutionID)).length - 1)).toBe("62c88976289c610293bc2cd1");;
37+
});
38+
});
39+
40+
describe("CREATE route test", () => {
41+
const course = new coursesModel({
42+
courseTitle: "teste back-end",
43+
affirmativePolicies: ["mulheres trans"],
44+
available: true,
45+
startDate: "22-06-2022",
46+
finishDate: "22-09-2022",
47+
category: ["tecnologia"],
48+
description: "curso voltado a mulheres",
49+
institutionID: "62c88976289c610293bc2cd1"
50+
});
51+
it("Deve salvar no banco de dados o novo curso", () => {
52+
course.save().then((dados) => {
53+
expect(dados.title).toBe("teste back-end");
54+
});
55+
56+
});
57+
})
58+
59+
60+
describe("UPDATE route test", () => {
61+
it("Deve editar o titulo do curso", () => {
62+
const course = new coursesModel({
63+
courseTitle: "teste back-end",
64+
affirmativePolicies: ["mulheres trans"],
65+
available: true,
66+
startDate: "22-06-2022",
67+
finishDate: "22-09-2022",
68+
category: ["tecnologia"],
69+
description: "curso voltado a mulheres",
70+
institutionID: "62c88976289c610293bc2cd1"
71+
});
72+
course.title = "novo curso teste"
73+
course.save().then((dados) => {
74+
expect(dados.title).toBe("novo curso teste");
75+
});
76+
77+
});
78+
})
79+
80+
describe("DELETE route test", () => {
81+
it("Deve excluir o curso", () => {
82+
const course = new coursesModel({
83+
courseTitle: "teste back-end",
84+
affirmativePolicies: ["mulheres trans"],
85+
available: true,
86+
startDate: "22-06-2022",
87+
finishDate: "22-09-2022",
88+
category: ["tecnologia"],
89+
description: "curso voltado a mulheres",
90+
institutionID: "62c88976289c610293bc2cd1"
91+
});
92+
course.save().then((dados) => {
93+
course.delete().then((novosdados) =>{
94+
expect(dados.title).toBe(null);
95+
})
96+
});
97+
98+
});
99+
})

test/institutions.test.js

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
const institutionsModel = require("../src/models/institutionsModel")
2+
3+
describe("GET route", () => {
4+
const institution = new institutionsModel({
5+
institution: "nome teste",
6+
site: "http://localhost:3301/my-documentation/#/",
7+
email: "http://emailteste@gmail.com",
8+
description: "instituição de tecnologia"
9+
});
10+
it("Deve chamar o schema e retornar o nome correto do curso", () => {
11+
expect(institution.institution).toBe("nome teste");
12+
});
13+
it("Deve chamar o schema e retornar o site", () => {
14+
expect(institution.site).toBe("http://localhost:3301/my-documentation/#/");
15+
});
16+
it("Deve chamar o schema e retornar o email", () => {
17+
expect(institution.email).toBe("http://emailteste@gmail.com");
18+
});
19+
it("Deve chamar o schema e retornar a descrição correta", () => {
20+
expect(institution.description).toBe("instituição de tecnologia");
21+
});
22+
});
23+
24+
describe("CREATE route test", () => {
25+
const institution = new institutionsModel({
26+
institution: "nome teste",
27+
site: "http://localhost:3301/my-documentation/#/",
28+
email: "http://emailteste@gmail.com",
29+
description: "instituição de tecnologia"
30+
});
31+
it("Deve salvar no banco de dados a nova instituição", () => {
32+
institution.save().then((dados) => {
33+
expect(dados.title).toBe("nome teste");
34+
});
35+
36+
});
37+
})
38+
39+
40+
describe("UPDATE route test", () => {
41+
it("Deve editar o titulo da instituição", () => {
42+
const institution = new institutionsModel({
43+
institution: "nome teste",
44+
site: "http://localhost:3301/my-documentation/#/",
45+
email: "http://emailteste@gmail.com",
46+
description: "instituição de tecnologia"
47+
});
48+
institution.title = "nova instituição"
49+
institution.save().then((dados) => {
50+
expect(dados.title).toBe("nova instituição");
51+
});
52+
53+
});
54+
})
55+
56+
describe("DELETE route test", () => {
57+
it("Deve excluir a instituição", () => {
58+
const institution = new institutionsModel({
59+
institution: "nome teste",
60+
site: "http://localhost:3301/my-documentation/#/",
61+
email: "http://emailteste@gmail.com",
62+
description: "instituição de tecnologia"
63+
});
64+
institution.save().then((dados) => {
65+
institution.delete().then((novosdados) =>{
66+
expect(dados.title).toBe(null);
67+
})
68+
});
69+
70+
});
71+
})

0 commit comments

Comments
 (0)