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
No related merge requests found
......@@ -3,6 +3,7 @@ var mysql = require("mysql");
const PersonDao = require("./persondao.js");
const runsqlfile = require("./runsqlfile.js");
// GitLab CI Pool
var pool = mysql.createPool({
connectionLimit: 1,
host: "mysql",
......@@ -22,7 +23,10 @@ beforeAll(done => {
test("get one person from db", done => {
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");
done();
}
......@@ -30,10 +34,39 @@ test("get one person from db", done => {
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 => {
function callback(status, data) {
console.log("Callback: status=" + status + ", data=" + data);
expect(data.length).toBe(2);
console.log(
"Test callback: status=" + status + ", data.length=" + data.length
);
expect(data.length).toBeGreaterThanOrEqual(2);
done();
}
......
{
"name": "myPackage",
"jest": {
"verbose": true,
"collectCoverage": true,
"coverageReporters": ["json", "html"]
},
"version": "0.0.1",
"dependencies": {
"body-parser": "^1.18.3",
"express": "^4.16.3",
"jest": "^23.6.0",
"mysql": "^2.16.0"
},
"scripts": {
"test": "jest"
}
"name": "myPackage",
"jest": {
"verbose": true,
"collectCoverage": true,
"coverageReporters": [
"json",
"html"
]
},
"version": "0.0.1",
"dependencies": {
"body-parser": "^1.18.3",
"express": "^4.16.3",
"fs": "0.0.1-security",
"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