Skip to content

Commit

Permalink
MV #41 : Incluyendo tests para api
Browse files Browse the repository at this point in the history
  • Loading branch information
LCinder committed Dec 6, 2021
1 parent 05a6cd8 commit 2392666
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/api-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

import "mocha";
import {assert} from "chai";
import {server} from "../src/routes";


describe("GET /status", () => {
it("Deberia devolver en body 'Ok'", async () => {
const res = await server.inject({
url: "/status"
});
assert.include(res.body, "Ok");
assert.equal(res.statusCode, 200);
});
});

describe("GET /movies", () => {
it("Deberia ser un array con varios elementos", async () => {
const res = await server.inject({
url: "/movies"
});
assert.isAbove(res.body.length, 2);
assert.equal(res.statusCode, 200);
});
});

describe("GET /movies/Hobbit", () => {
it("Deberia ser una pelicula", async () => {
const res = await server.inject({
url: "/movies/Hobbit(2012)"
});
assert.equal(JSON.parse(res.body)._title, "The Hobbit: An Unexpected Journey");
assert.equal(res.statusCode, 200);
});
});

describe("GET /movies/Hobbit/keywords", () => {
it("Deberia devolver un array de palabras clave 'string'", async () => {
const res = await server.inject({
url: "/movies/Hobbit(2012)/keywords"
});
assert.isArray(JSON.parse(res.body));
assert.isAbove(res.body.length, 2);
assert.equal(res.statusCode, 200);
});
});

0 comments on commit 2392666

Please sign in to comment.