Skip to content

Commit

Permalink
Create loyalty.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Dec 3, 2024
1 parent f753821 commit 549a935
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/loyalty.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// tests/loyalty.test.js
const Loyalty = require('../loyalty'); // Assuming you have a loyalty module

describe('Loyalty Module', () => {
let loyalty;

beforeEach(() => {
loyalty = new Loyalty();
});

test('should add points correctly', () => {
loyalty.addPoints(100);
expect(loyalty.getPoints()).toBe(100);
});

test('should redeem points correctly', () => {
loyalty.addPoints(100);
loyalty.redeemPoints(50);
expect(loyalty.getPoints()).toBe(50);
});

test('should not allow redeeming more points than available', () => {
expect(() => loyalty.redeemPoints(50)).toThrow('Insufficient points');
});
});

0 comments on commit 549a935

Please sign in to comment.