add usermanager tests
This commit is contained in:
@@ -251,24 +251,24 @@ function update(userId, user, callback) {
|
||||
assert.strictEqual(typeof user, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
assert(!('username' in user) || (user.username === null || typeof user.username === 'string'));
|
||||
assert(!('email' in user) || (typeof user.email === 'string'));
|
||||
assert(!('fallbackEmail' in user) || (typeof user.fallbackEmail === 'string'));
|
||||
assert(!('twoFactorAuthenticationEnabled' in user) || (typeof user.twoFactorAuthenticationEnabled === 'boolean'));
|
||||
assert(!('admin' in user) || (typeof user.admin === 'boolean'));
|
||||
assert(!('active' in user) || (typeof user.active === 'boolean'));
|
||||
|
||||
var args = [ ];
|
||||
var fields = [ ];
|
||||
for (var k in user) {
|
||||
fields.push(k + ' = ?');
|
||||
|
||||
if (k === 'username') {
|
||||
assert(user.username === null || typeof user.username === 'string');
|
||||
args.push(user.username);
|
||||
} else if (k === 'email' || k === 'fallbackEmail') {
|
||||
assert.strictEqual(typeof user[k], 'string');
|
||||
args.push(user[k]);
|
||||
} else if (k === 'twoFactorAuthenticationEnabled' || k === 'admin' || k === 'active') {
|
||||
assert.strictEqual(typeof user[k], 'boolean');
|
||||
if (k === 'twoFactorAuthenticationEnabled' || k === 'admin' || k === 'active') {
|
||||
fields.push(k + ' = ?');
|
||||
args.push(user[k] ? 1 : 0);
|
||||
} else if (k === 'permissions') {
|
||||
fields.push(`${k}Json = ?`);
|
||||
args.push(JSON.stringify(user[k]));
|
||||
} else {
|
||||
fields.push(k + ' = ?');
|
||||
args.push(user[k]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user