-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathsetup.spec.js
More file actions
87 lines (82 loc) · 2.52 KB
/
setup.spec.js
File metadata and controls
87 lines (82 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
"use strict";
const winston = require("winston");
winston.remove(winston.transports.Console);
const server = require("../app.js");
const Util = {
Account: require("./util/account.test.util"),
Bus: require("./util/bus.test.util"),
Hacker: require("./util/hacker.test.util"),
Role: require("./util/role.test.util"),
RoleBinding: require("./util/roleBinding.test.util"),
Settings: require("./util/settings.test.util"),
Sponsor: require("./util/sponsor.test.util"),
Admin: require("./util/admin.test.util"),
Team: require("./util/team.test.util"),
Volunteer: require("./util/volunteer.test.util"),
AccountConfirmation: require("./util/accountConfirmation.test.util"),
ResetPassword: require("./util/resetPassword.test.util.js")
};
const logger = require("../services/logger.service");
//make sure that we are connected to the database
before(function(done) {
this.timeout(60000);
server.app.on("event:connected to db", () => {
/**
* Give the database time to create an index on existing schemas before we delete them.
* Hacky way to get around a new error.
*/
setTimeout(() => {
dropAll()
.then(done)
.catch(done);
}, 1000);
});
});
beforeEach(function(done) {
this.timeout(60000);
storeAll()
.then(() => {
done();
})
.catch((error) => {
done(error);
});
});
afterEach(function(done) {
this.timeout(60000);
dropAll()
.then(() => {
done();
})
.catch((error) => {
done(error);
});
});
async function storeAll() {
await Util.Account.storeAll();
await Util.Settings.storeAll();
await Util.Hacker.storeAll();
await Util.Sponsor.storeAll();
await Util.Team.storeAll();
await Util.Admin.storeAll();
await Util.AccountConfirmation.storeAll();
await Util.ResetPassword.storeAll();
await Util.Bus.storeAll();
await Util.Volunteer.storeAll();
await Util.Role.storeAll();
await Util.RoleBinding.storeAll();
}
async function dropAll() {
await Util.RoleBinding.dropAll();
await Util.Role.dropAll();
await Util.ResetPassword.dropAll();
await Util.AccountConfirmation.dropAll();
await Util.Volunteer.dropAll();
await Util.Settings.dropAll();
await Util.Admin.dropAll();
await Util.Team.dropAll();
await Util.Sponsor.dropAll();
await Util.Bus.dropAll();
await Util.Hacker.dropAll();
await Util.Account.dropAll();
}