|
Lines 2-7
const { query } = require("./../../plugins/db.js");
Link Here
|
| 2 |
const { getBasicAuthHeader } = require("./../../plugins/auth.js"); |
2 |
const { getBasicAuthHeader } = require("./../../plugins/auth.js"); |
| 3 |
|
3 |
|
| 4 |
describe("insertData", () => { |
4 |
describe("insertData", () => { |
|
|
5 |
let tablesToCheck = [ |
| 6 |
"borrowers", |
| 7 |
"branches", |
| 8 |
"items", |
| 9 |
"biblio", |
| 10 |
"reserves", |
| 11 |
]; |
| 12 |
beforeEach(() => { |
| 13 |
const counts = {}; |
| 14 |
|
| 15 |
const queries = tablesToCheck.map(table => { |
| 16 |
return cy |
| 17 |
.task("query", { |
| 18 |
sql: `SELECT COUNT(*) as count FROM ${table}`, |
| 19 |
}) |
| 20 |
.then(result => { |
| 21 |
counts[table] = result[0].count; |
| 22 |
}); |
| 23 |
}); |
| 24 |
|
| 25 |
cy.wrap(Promise.all(queries)).then(() => { |
| 26 |
cy.wrap(counts).as("initialCounts"); |
| 27 |
}); |
| 28 |
}); |
| 29 |
|
| 5 |
describe("deleteSampleObjects", () => { |
30 |
describe("deleteSampleObjects", () => { |
| 6 |
it("should delete everything from Object", () => { |
31 |
it("should delete everything from Object", () => { |
| 7 |
cy.task("insertSampleBiblio", { item_count: 2 }).then(objects => { |
32 |
cy.task("insertSampleBiblio", { item_count: 2 }).then(objects => { |
|
Lines 189-192
describe("insertData", () => {
Link Here
|
| 189 |
); |
214 |
); |
| 190 |
}); |
215 |
}); |
| 191 |
}); |
216 |
}); |
|
|
217 |
|
| 218 |
afterEach(function () { |
| 219 |
cy.get("@initialCounts").then(initialCounts => { |
| 220 |
const queries = tablesToCheck.map(table => { |
| 221 |
return cy |
| 222 |
.task("query", { |
| 223 |
sql: `SELECT COUNT(*) as count FROM ${table}`, |
| 224 |
}) |
| 225 |
.then(result => { |
| 226 |
const finalCount = result[0].count; |
| 227 |
expect( |
| 228 |
finalCount, |
| 229 |
`Row count for ${table} should match` |
| 230 |
).to.eq(initialCounts[table]); |
| 231 |
}); |
| 232 |
}); |
| 233 |
|
| 234 |
return Promise.all(queries); |
| 235 |
}); |
| 236 |
}); |
| 192 |
}); |
237 |
}); |
| 193 |
- |
|
|