refactor: closes #12629, allow passing arrays to meta.userOrGroupExists

This commit is contained in:
Barış Soner Uşaklı
2024-06-10 16:59:55 -04:00
parent be86d8efc7
commit bad1564301
3 changed files with 32 additions and 28 deletions

View File

@@ -1492,28 +1492,18 @@ describe('User', () => {
});
});
it('should return true if user/group exists', (done) => {
meta.userOrGroupExists('registered-users', (err, exists) => {
assert.ifError(err);
assert(exists);
done();
});
});
it('should return true/false if user/group exists or not', async () => {
assert.strictEqual(await meta.userOrGroupExists('registered-users'), true);
assert.strictEqual(await meta.userOrGroupExists('John Smith'), true);
assert.strictEqual(await meta.userOrGroupExists('doesnot exist'), false);
assert.deepStrictEqual(await meta.userOrGroupExists(['doesnot exist', 'nope not here']), [false, false]);
assert.deepStrictEqual(await meta.userOrGroupExists(['doesnot exist', 'John Smith']), [false, true]);
assert.deepStrictEqual(await meta.userOrGroupExists(['administrators', 'John Smith']), [true, true]);
it('should return true if user/group exists', (done) => {
meta.userOrGroupExists('John Smith', (err, exists) => {
assert.ifError(err);
assert(exists);
done();
});
});
it('should return false if user/group does not exists', (done) => {
meta.userOrGroupExists('doesnot exist', (err, exists) => {
assert.ifError(err);
assert(!exists);
done();
});
await assert.rejects(
meta.userOrGroupExists(['', undefined]),
{ message: '[[error:invalid-data]]' },
);
});
it('should delete user', async () => {