-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}); | ||
}); |