Skip to content

Commit

Permalink
Merge pull request #46 from CMU-313/us2/tests
Browse files Browse the repository at this point in the history
US2 - Automated tests
  • Loading branch information
guanjiecheng authored Oct 3, 2024
2 parents 9ad2369 + 27b0b1f commit 051634b
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/topics.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,35 @@ describe('Topic\'s', () => {
});
});

it('should set isAnonymous by default to false when creating a new topic', (done) => {
topics.post({
uid: topic.userId,
title: topic.title,
content: topic.content,
cid: topic.categoryId,
}, (err, result) => {
assert.ifError(err);
assert(result);
assert.strictEqual(result.topicData.isAnonymous, 'false', 'isAnonymous should be false by default');
done();
});
});

it('should set isAnonymous by default to true when creating a new topic', (done) => {
topics.post({
uid: topic.userId,
title: topic.title,
content: topic.content,
cid: topic.categoryId,
postAnonymous: true,
}, (err, result) => {
assert.ifError(err);
assert(result);
assert.strictEqual(result.topicData.isAnonymous, 'true', 'isAnonymous should be true by default');
done();
});
});

it('should get post count', async () => {
const count = await socketTopics.postcount({ uid: adminUid }, topic.tid);
assert.strictEqual(count, 1);
Expand Down

0 comments on commit 051634b

Please sign in to comment.