Commit f769db08 authored by Lucas Fernandes de Oliveira's avatar Lucas Fernandes de Oliveira

Merge branch 'issue/2' into 'develop'

issue/2

See merge request !2
parents 36f53882 94eb7aff
node_modules/
.nyc_output/
coverage/
*.swp
*.swo
*.tmp
......
This diff is collapsed.
......@@ -6,7 +6,7 @@
"scripts": {
"start": "node index",
"lint": "tslint -s node_modules/tslint_stylish -t stylish src/**/*.ts",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "ts-node node_modules/nyc/bin/nyc.js mocha"
},
"repository": {
"type": "git",
......@@ -15,6 +15,24 @@
"keywords": [
"blendb"
],
"nyc": {
"include": [
"src/**/*.ts"
],
"extension": [
".ts"
],
"require": [
"ts-node/register"
],
"reporter": [
"text-summary",
"text",
"lcov"
],
"sourceMap": true,
"instrument": true
},
"author": "Lucas Fernandes de Oliveira",
"license": "ISC",
"dependencies": {
......@@ -27,6 +45,12 @@
"typescript": "^3.6.3"
},
"devDependencies": {
"@types/mocha": "^5.2.7",
"@types/supertest": "^2.0.8",
"chai": "^4.2.0",
"mocha": "^6.2.1",
"nyc": "^14.1.1",
"supertest": "^4.0.2",
"tslint": "^5.20.0"
}
}
......@@ -7,7 +7,10 @@ export class DBHandler {
private jogos: Jogo[];
private compras: Compra[];
constructor() {
this.jogadores = [];
this.jogadores = [
new Jogador("Player1", [], [], 0.0)
, new Jogador("Player2", [], [], 100.0)
];
this.jogos = [];
this.compras = [];
}
......
import { expect } from "chai";
import * as request from "supertest";
import * as server from "./main";
describe("Arquivo main.ts", () => {
it("Deveria listar os jogadores com sucesso", (done) => {
request(server)
.get("/jogadores")
.expect(200)
.expect((res: any) => {
expect(res.body).to.be.an("array");
expect(res.body).to.have.length(2);
for (let i =0; i < 2; ++i) {
expect(res.body[i]).to.be.eql("Player" + (i+1));
}
})
.end(done);
});
});
......@@ -20,7 +20,7 @@ function dbhMW(): Middleware {
};
}
const app = express();
const app = module.exports = express();
app.use("/", bodyParser.json());
app.use("/", dbhMW());
......
process.env.NODE_ENV = "test";
--require ./test/global.ts
--reporter spec
--ui bdd
--recursive
--colors
--timeout 60000
--slow 300
--check-leaks
--globals expect
./src/**/*.spec.ts
--exit
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment