Skip to content

Commit

Permalink
Fixing db.getTags() and db.clearTags()
Browse files Browse the repository at this point in the history
  • Loading branch information
JasmineRocket authored Oct 11, 2024
1 parent 953aac8 commit 2ce77ed
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/webserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ const webserver = require('../src/webserver');
const topics = require('../src/topics/tags');
const db = require('../src/database');

//Automated test cases generated with the help of ChatGPT

Check failure on line 8 in test/webserver.js

View workflow job for this annotation

GitHub Actions / test

Expected exception block, space or tab after '//' in comment

describe('createNewTag', () => {
let originalCreateEmptyTag;

Expand All @@ -22,13 +24,13 @@ describe('createNewTag', () => {
// Simulate a scenario where the function tries to add tags to an invalid forum category

// Assuming there's an invalid category check in the createNewTag function, expect no tags to be added in this case
await db.clearTags(); // Clear tags first to ensure a clean test
await Topics.deleteTags(['Homework', 'Assignment']);

Check failure on line 27 in test/webserver.js

View workflow job for this annotation

GitHub Actions / test

'Topics' is not defined

// Act: Run createNewTag with invalid forum categories (this would need to be simulated in the webserver function)
await webserver.createNewTag({ forumCategory: 'InvalidCategory' });
await Topics.createNewTag({ forumCategory: 'InvalidCategory' });

Check failure on line 30 in test/webserver.js

View workflow job for this annotation

GitHub Actions / test

'Topics' is not defined

// Assert: Check that no tags have been added
const tags = await db.getTags();
const tags = await Topics.getTags(0, -1);

Check failure on line 33 in test/webserver.js

View workflow job for this annotation

GitHub Actions / test

'Topics' is not defined
assert.strictEqual(tags.length, 0, 'No tags should be added for invalid forum categories');
});
});

0 comments on commit 2ce77ed

Please sign in to comment.