Skip to content
Snippets Groups Projects
Commit de88a348 authored by nilstes's avatar nilstes
Browse files

Flere tester

parent 4626f295
No related branches found
No related tags found
Loading
...@@ -3,6 +3,7 @@ var mysql = require("mysql"); ...@@ -3,6 +3,7 @@ var mysql = require("mysql");
const PersonDao = require("./persondao.js"); const PersonDao = require("./persondao.js");
const runsqlfile = require("./runsqlfile.js"); const runsqlfile = require("./runsqlfile.js");
// GitLab CI Pool
var pool = mysql.createPool({ var pool = mysql.createPool({
connectionLimit: 1, connectionLimit: 1,
host: "mysql", host: "mysql",
...@@ -22,7 +23,10 @@ beforeAll(done => { ...@@ -22,7 +23,10 @@ beforeAll(done => {
test("get one person from db", done => { test("get one person from db", done => {
function callback(status, data) { function callback(status, data) {
console.log("Callback: status=" + status + ", data=" + data); console.log(
"Test callback: status=" + status + ", data=" + JSON.stringify(data)
);
expect(data.length).toBe(1);
expect(data[0].navn).toBe("Hei Sveisen"); expect(data[0].navn).toBe("Hei Sveisen");
done(); done();
} }
...@@ -30,10 +34,39 @@ test("get one person from db", done => { ...@@ -30,10 +34,39 @@ test("get one person from db", done => {
personDao.getOne(1, callback); personDao.getOne(1, callback);
}); });
test("get unknown person from db", done => {
function callback(status, data) {
console.log(
"Test callback: status=" + status + ", data=" + JSON.stringify(data)
);
expect(data.length).toBe(0);
done();
}
personDao.getOne(0, callback);
});
test("get add person to db", done => {
function callback(status, data) {
console.log(
"Test callback: status=" + status + ", data=" + JSON.stringify(data)
);
expect(data.affectedRows).toBeGreaterThanOrEqual(1);
done();
}
personDao.createOne(
{ navn: "Nils Nilsen", alder: 34, adresse: "Gata 3" },
callback
);
});
test("get all persons from db", done => { test("get all persons from db", done => {
function callback(status, data) { function callback(status, data) {
console.log("Callback: status=" + status + ", data=" + data); console.log(
expect(data.length).toBe(2); "Test callback: status=" + status + ", data.length=" + data.length
);
expect(data.length).toBeGreaterThanOrEqual(2);
done(); done();
} }
......
{ {
"name": "myPackage", "name": "myPackage",
"jest": { "jest": {
"verbose": true, "verbose": true,
"collectCoverage": true, "collectCoverage": true,
"coverageReporters": ["json", "html"] "coverageReporters": [
}, "json",
"version": "0.0.1", "html"
"dependencies": { ]
"body-parser": "^1.18.3", },
"express": "^4.16.3", "version": "0.0.1",
"jest": "^23.6.0", "dependencies": {
"mysql": "^2.16.0" "body-parser": "^1.18.3",
}, "express": "^4.16.3",
"scripts": { "fs": "0.0.1-security",
"test": "jest" "jest": "^23.6.0",
} "mysql": "^2.16.0"
},
"scripts": {
"test": "jest"
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment