Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlam committed Jul 9, 2021
1 parent 415416d commit 0960a81
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion test/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ describe('Controllers', () => {
assert.deepStrictEqual(parsedResponse.response, {});
assert.deepStrictEqual(parsedResponse.status, {
code: 'not-found',
message: '[[error:no-user]]',
message: 'User does not exist',
});
done();
});
Expand Down
4 changes: 2 additions & 2 deletions test/topicThumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ describe('Topic thumbs', () => {
assert.ifError(err);
assert.strictEqual(res.statusCode, 503);
assert(body && body.status);
assert.strictEqual(body.status.message, '[[error:topic-thumbnails-are-disabled]]');
assert.strictEqual(body.status.message, 'Topic thumbnails are disabled.');
done();
});
});
Expand All @@ -362,7 +362,7 @@ describe('Topic thumbs', () => {
assert.ifError(err);
assert.strictEqual(res.statusCode, 500);
assert(body && body.status);
assert.strictEqual(body.status.message, '[[error:invalid-file]]');
assert.strictEqual(body.status.message, 'Invalid File');
done();
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('Topic\'s', () => {
},
json: true,
});
assert.strictEqual(result.body.status.message, '[[error:no-privileges]]');
assert.strictEqual(result.body.status.message, 'You do not have enough privileges for this action.');
});

it('should post a topic as guest if guest group has privileges', async () => {
Expand Down
18 changes: 9 additions & 9 deletions test/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -2123,14 +2123,14 @@ describe('User', () => {
it('should error if user does not have invite privilege', async () => {
const { res } = await helpers.invite({ emails: 'invite1@test.com', groupsToJoin: [] }, notAnInviterUid, jar, csrf_token);
assert.strictEqual(res.statusCode, 403);
assert.strictEqual(res.body.status.message, '[[error:no-privileges]]');
assert.strictEqual(res.body.status.message, 'You do not have enough privileges for this action.');
});

it('should error out if user tries to use an inviter\'s uid via the API', async () => {
const { res } = await helpers.invite({ emails: 'invite1@test.com', groupsToJoin: [] }, inviterUid, jar, csrf_token);
const numInvites = await User.getInvitesNumber(inviterUid);
assert.strictEqual(res.statusCode, 403);
assert.strictEqual(res.body.status.message, '[[error:no-privileges]]');
assert.strictEqual(res.body.status.message, 'You do not have enough privileges for this action.');
assert.strictEqual(numInvites, 0);
});
});
Expand Down Expand Up @@ -2159,14 +2159,14 @@ describe('User', () => {
it('should error with invalid data', async () => {
const { res } = await helpers.invite({}, inviterUid, jar, csrf_token);
assert.strictEqual(res.statusCode, 400);
assert.strictEqual(res.body.status.message, '[[error:invalid-data]]');
assert.strictEqual(res.body.status.message, 'Invalid Data');
});

it('should error if user is not admin and type is admin-invite-only', async () => {
meta.config.registrationType = 'admin-invite-only';
const { res } = await helpers.invite({ emails: 'invite1@test.com', groupsToJoin: [] }, inviterUid, jar, csrf_token);
assert.strictEqual(res.statusCode, 403);
assert.strictEqual(res.body.status.message, '[[error:no-privileges]]');
assert.strictEqual(res.body.status.message, 'You do not have enough privileges for this action.');
});

it('should send invitation email (without groups to be joined)', async () => {
Expand All @@ -2183,13 +2183,13 @@ describe('User', () => {
it('should error if the user has not permission to invite to the group', async () => {
const { res } = await helpers.invite({ emails: 'invite4@test.com', groupsToJoin: [PRIVATE_GROUP] }, inviterUid, jar, csrf_token);
assert.strictEqual(res.statusCode, 403);
assert.strictEqual(res.body.status.message, '[[error:no-privileges]]');
assert.strictEqual(res.body.status.message, 'You do not have enough privileges for this action.');
});

it('should error if a non-admin tries to invite to the administrators group', async () => {
const { res } = await helpers.invite({ emails: 'invite4@test.com', groupsToJoin: ['administrators'] }, inviterUid, jar, csrf_token);
assert.strictEqual(res.statusCode, 403);
assert.strictEqual(res.body.status.message, '[[error:no-privileges]]');
assert.strictEqual(res.body.status.message, 'You do not have enough privileges for this action.');
});

it('should to invite to own private group', async () => {
Expand All @@ -2211,7 +2211,7 @@ describe('User', () => {
meta.config.maximumInvites = 1;
const { res } = await helpers.invite({ emails: 'invite6@test.com', groupsToJoin: [] }, inviterUid, jar, csrf_token);
assert.strictEqual(res.statusCode, 403);
assert.strictEqual(res.body.status.message, `[[error:invite-maximum-met, ${5}, ${1}]]`);
assert.strictEqual(res.body.status.message, `You have invited the maximum amount of people (${5} out of ${1}).`);
meta.config.maximumInvites = 10;
});

Expand All @@ -2224,14 +2224,14 @@ describe('User', () => {
const { res } = await helpers.invite({ emails: 'inviter@nodebb.org', groupsToJoin: [] }, adminUid, jar, csrf_token);
const numInvites = await User.getInvitesNumber(adminUid);
assert.strictEqual(res.statusCode, 403);
assert.strictEqual(res.body.status.message, '[[error:no-privileges]]');
assert.strictEqual(res.body.status.message, 'You do not have enough privileges for this action.');
assert.strictEqual(numInvites, 0);
});

it('should error if email exists', async () => {
const { res } = await helpers.invite({ emails: 'inviter@nodebb.org', groupsToJoin: [] }, inviterUid, jar, csrf_token);
assert.strictEqual(res.statusCode, 400);
assert.strictEqual(res.body.status.message, '[[error:email-taken]]');
assert.strictEqual(res.body.status.message, 'Email taken');
});
});

Expand Down

0 comments on commit 0960a81

Please sign in to comment.