@magic.batua/points
Version:
The Points module powers the loyalty points features of the Magic Batua platform.
94 lines • 2.86 kB
JavaScript
;
//
// index.spec.ts
// Magic Point
//
// Created on February 18, 2018 by Animesh Mishra <hello@animesh.ltd>
// © 2018 Magic Batua. All Rights Reserved.
//
Object.defineProperty(exports, "__esModule", { value: true });
const Chai = require("chai");
const index_1 = require("../index");
const expect = Chai.expect;
let ledger;
before(function () {
let transactions = [
{
points: 600,
type: "Issue",
notes: "Signup"
},
{
points: 400,
type: "Issue",
notes: "Referral"
},
{
_id: '5aad35c684ec63317d13d7f0',
points: 400,
type: 'Issue',
date: "2014-03-17T15:35:34.648Z",
notes: 'Referral',
expiryDate: "2015-03-17T21:35:34.648Z"
}
];
ledger = new index_1.Ledger(transactions);
});
describe("◊◊◊ Points ◊◊◊", function () {
this.timeout(10000);
it("Should initialise ledger correctly", function () {
try {
expect(ledger).to.have.property("signup").equal(600);
expect(ledger).to.have.property("referral").equal(400);
expect(ledger).to.have.property("expired").equal(400);
}
catch (exception) {
console.log(exception);
Chai.assert(false);
}
});
it("Should issue a Point correctly", function () {
try {
let issue = ledger.Issue(20, "Tuition Fee");
expect(ledger).to.have.property("redeemable").equal(20);
}
catch (exception) {
console.log(exception);
Chai.assert(false);
}
});
it("Should redeem points correctly", function () {
try {
let redeem = ledger.Redeem(8, "Recharge");
expect(ledger).to.have.property("redeemed").equal(8);
expect(ledger).to.have.property("available").equal(12);
}
catch (exception) {
console.log(exception);
Chai.assert(false);
}
});
it("Should make signup redeemable.", function () {
try {
ledger.MakeSignupRedeemable();
expect(ledger).to.have.property("available").equal(612);
expect(ledger).to.have.property("signup").equal(0);
}
catch (exception) {
console.log(exception);
Chai.assert(false);
}
});
it("Should make referrals redeemable.", function () {
try {
ledger.MakeReferralsRedeemable();
expect(ledger).to.have.property("available").equal(1012);
expect(ledger).to.have.property("referral").equal(0);
}
catch (exception) {
console.log(exception);
Chai.assert(false);
}
});
});
//# sourceMappingURL=index.spec.js.map