Skip to content

Commit b36b79d

Browse files
committed
chore: fix tests and unmaintained package (closes #421)
1 parent b2322ef commit b36b79d

File tree

6 files changed

+3369
-2930
lines changed

6 files changed

+3369
-2930
lines changed

template/app/controllers/web/my-account.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,10 @@ async function update(ctx) {
9191
ctx.state.user[config.userFields.changeEmailTokenExpiresAt] = dayjs()
9292
.add(config.changeEmailTokenTimeoutMs, 'milliseconds')
9393
.toDate();
94-
ctx.state.user[
95-
config.userFields.changeEmailToken
96-
] = await cryptoRandomString.async({
97-
length: 32
98-
});
94+
ctx.state.user[config.userFields.changeEmailToken] =
95+
await cryptoRandomString.async({
96+
length: 32
97+
});
9998
ctx.state.user[config.userFields.changeEmailNewAddress] = body.email;
10099
}
101100

template/app/models/user.js

+12-18
Original file line numberDiff line numberDiff line change
@@ -267,29 +267,23 @@ User.methods.sendVerificationEmail = async function (ctx, reset = false) {
267267
return this;
268268

269269
if (reset) {
270-
this[config.userFields.verificationPinExpiresAt] = this[
271-
`__${config.userFields.verificationPinExpiresAt}`
272-
];
273-
this[config.userFields.verificationPinSentAt] = this[
274-
`__${config.userFields.verificationPinSentAt}`
275-
];
276-
this[config.userFields.verificationPin] = this[
277-
`__${config.userFields.verificationPin}`
278-
];
270+
this[config.userFields.verificationPinExpiresAt] =
271+
this[`__${config.userFields.verificationPinExpiresAt}`];
272+
this[config.userFields.verificationPinSentAt] =
273+
this[`__${config.userFields.verificationPinSentAt}`];
274+
this[config.userFields.verificationPin] =
275+
this[`__${config.userFields.verificationPin}`];
279276
await this.save();
280277
return this;
281278
}
282279

283280
// store old values in case we have to reset
284-
this[`__${config.userFields.verificationPinExpiresAt}`] = this[
285-
config.userFields.verificationPinExpiresAt
286-
];
287-
this[`__${config.userFields.verificationPinSentAt}`] = this[
288-
config.userFields.verificationPinSentAt
289-
];
290-
this[`__${config.userFields.verificationPin}`] = this[
291-
config.userFields.verificationPin
292-
];
281+
this[`__${config.userFields.verificationPinExpiresAt}`] =
282+
this[config.userFields.verificationPinExpiresAt];
283+
this[`__${config.userFields.verificationPinSentAt}`] =
284+
this[config.userFields.verificationPinSentAt];
285+
this[`__${config.userFields.verificationPin}`] =
286+
this[config.userFields.verificationPin];
293287

294288
const diff =
295289
this[config.userFields.verificationPinExpiresAt] &&

template/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"del": "^6.0.0",
7171
"email-templates": "^8.0.3",
7272
"fast-safe-stringify": "^2.0.7",
73-
"font-awesome-assets": "^0.0.8",
73+
"font-awesome-assets": "^0.0.9",
7474
"gemoji": "^6.1.0",
7575
"github-markdown-css": "^4.0.0",
7676
"hasha": "^5.2.2",

template/test/_utils.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Necessary utils for testing
22
// Librarires required for testing
3-
const MongodbMemoryServer = require('mongodb-memory-server').default;
3+
const { MongoMemoryServer } = require('mongodb-memory-server');
44
const mongoose = require('mongoose');
55
const request = require('supertest');
66
const sinon = require('sinon');
@@ -11,12 +11,13 @@ const { factory, MongooseAdapter } = require('factory-girl');
1111
const config = require('../config');
1212
const { Users } = require('../app/models');
1313

14-
const mongod = new MongodbMemoryServer();
14+
let mongod;
1515
const adapter = new MongooseAdapter();
1616

1717
// create connection to mongoose before all tests
1818
exports.before = async () => {
19-
const uri = await mongod.getConnectionString();
19+
mongod = await MongoMemoryServer.create();
20+
const uri = mongod.getUri();
2021
await mongoose.connect(uri);
2122

2223
factory.setAdapter(adapter);

template/test/utils.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Necessary utils for testing
22
// Librarires required for testing
3-
const MongodbMemoryServer = require('mongodb-memory-server').default;
3+
const { MongoMemoryServer } = require('mongodb-memory-server');
44
const mongoose = require('mongoose');
55
const request = require('supertest');
66
const { factory, MongooseAdapter } = require('factory-girl');
@@ -12,13 +12,14 @@ factory.setAdapter(new MongooseAdapter());
1212
const config = require('../config');
1313
const { Users } = require('../app/models');
1414

15-
const mongod = new MongodbMemoryServer();
15+
let mongod;
1616

1717
//
1818
// setup utilities
1919
//
2020
exports.setupMongoose = async () => {
21-
const uri = await mongod.getConnectionString();
21+
mongod = await MongoMemoryServer.create();
22+
const uri = mongod.getUri();
2223
await mongoose.connect(uri);
2324
};
2425

0 commit comments

Comments
 (0)