Skip to content

Commit

Permalink
Create gamification.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Dec 4, 2024
1 parent 0611485 commit 540d3f6
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/gamification.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// gamification.test.js

const Gamification = require('./gamification'); // Assuming you have a Gamification module

describe('Gamification Features', () => {
let gamification;

beforeEach(() => {
gamification = new Gamification();
});

test('should award points for completing a task', () => {
gamification.completeTask('user1', 'task1');
const points = gamification.getUser Points('user1');
expect(points).toBeGreaterThan(0);
});

test('should unlock a badge after earning enough points', () => {
gamification.completeTask('user1', 'task1');
gamification.completeTask('user1', 'task2');
const badges = gamification.getUser Badges('user1');
expect(badges).toContain('Task Master');
});

test('should not award points for duplicate task completion', () => {
gamification.completeTask('user1', 'task1');
gamification.completeTask('user1', 'task1'); // Duplicate
const points = gamification.getUser Points('user1');
expect(points).toBe(10); // Assuming task1 is worth 10 points
});
});

0 comments on commit 540d3f6

Please sign in to comment.