Files
boc/projects/landvex/api/tests/setup.js
T

36 lines
794 B
JavaScript
Raw Normal View History

/**
* Test-setup för LandveX API Fas 2
*/
const db = require('../src/config/database');
const Bounty = require('../src/models/bounty');
const Identify = require('../src/models/identify');
// Återställ databasen före varje test
beforeEach(() => {
// Rensa testtabeller
const tables = [
'bounties', 'bounty_submissions', 'individregister',
'submission_dubletter', 'zoomer_profiler', 'notifikationer',
'feedback_ko', 'identify_forsok', 'golden_cases', 'konfidenskalibrering'
];
for (const table of tables) {
try {
db.prepare(`DELETE FROM ${table}`).run();
} catch (e) {
// Tabellen kanske inte finns än
}
}
});
// Initiera tabeller
beforeAll(() => {
Bounty.initTables();
Identify.initTables();
});
afterAll(() => {
db.close();
});