UNPKG

@magic.batua/account

Version:

The Account modules powers the user account management features of the Magic Batua platform.

116 lines 5.55 kB
"use strict"; // // Account.spec.ts // Magic-Account // // Created on February 14, 2018 by Animesh Mishra <hello@animesh.ltd> // © 2018 Magic Batua. All Rights Reserved. // Object.defineProperty(exports, "__esModule", { value: true }); const Chai = require("chai"); const Account_1 = require("../Source/Account"); const Source_1 = require("../Source/Source"); const bson_1 = require("bson"); const expect = Chai.expect; describe("◊◊◊◊ Account: Init from client ◊◊◊◊", function () { let account = new Account_1.Account({ "name": "Test", "phone": "123456789", "email": "contact@example.com", "password": "password", "inviteCode": "abcdefgh" }, Source_1.Source.Client); it("Instantiation successful", function () { expect(account).to.not.be.null; expect(account).to.not.be.undefined; expect(account).to.be.an.instanceof(Account_1.Account); }); it("Contact information initialised.", function () { expect(account, "account.name").to.have.property("name").equal("Test"); expect(account, "account.email").to.have.property("email").equal("contact@example.com"); expect(account, "account.phone").to.have.property("phone").equal("123456789"); }); it("Password initialised.", function () { expect(account.CanAuthenticateUsing("password")).to.be.true; }); it("Object ID initialised.", function () { expect(account).to.have.property("_id").be.an.instanceof(bson_1.ObjectId); }); it("Referral code initialised.", function () { expect(account).to.have.property("referralCode").not.be.null; expect(account).to.have.property("referralCode").not.be.undefined; expect(account).to.have.property("referralCode").be.a("string"); }); it("Password reset successful.", function () { account.ResetPassword("nicoleta"); expect(account.CanAuthenticateUsing("nicoleta")).to.be.true; }); it("Export for client", function () { let clientExport = account.Export(); expect(clientExport).to.not.have.property("password"); expect(clientExport).to.not.have.property("salt"); expect(clientExport).to.not.have.property("isDeleted"); expect(clientExport).to.not.have.property("recoverBy"); }); }); describe("◊◊◊◊ Account: Init from database ◊◊◊◊", function () { let account = new Account_1.Account({ "_id": new bson_1.ObjectId("5aad5ef68f678e060c49ee4f"), "isDeleted": false, "name": "Test", "phone": "123456789", "email": "contact@example.com", "salt": "sBHKqlBtH5IG56G4a72hj/MdeNXt/GeXYO1bDh+o31+BRtcSSJgqsmK+upUSt8HU+gIEPVAbO8ctRVdAg3bYeIR1m28S++OYiylHq88DnZziRNtVsi4Aj76Yv2EiAiq+vBWVxfJ7RsDqJys0qrlOpuMzAr84GMsxSC9zDQrMCJE=", "password": "x5ul+22y3cqzBGSB74NHRanUA95l4Ix4TAYdz6Tr+JO9PjmEvkTjGgYOEviLZI6vp5SwImmIQWDn6KgU2PwB0SRGozcOfe9WQXZZxY+b9XjHr2tlMhRzt8NPxJDQ/wFEShdePSZPKW2OFBtQQY7f1H3b2J2GCgpSQs9bodZnVmGnp2fHZM2NH5EEDLh4zlVdDMKLdDkWuNMMbeOI3bZt/8k5dvOLAasJVeZHbrWYESIP82eaqbbf6LDTXGhCp5N1k0ulihnsR5Q+0UphlI6ab2+rQrCbJd5PHZMy0vtrfeQvl5aR6Xij8pEETT18OY0UvAKqOz1ZBHKGgNNqMhiL60vsjDMxmCH8P4BfouhFlgbwln9YCj5A495kVZhjkyI346hWEElAVIfrt8E94IVZj8rDPXZBmAjSnrpJgc34DB6Fkf8MkN+oFUHUpIl+69uL+KD8DDrh8eVJqFHXqkgNj/2W9ZaPVvikJo4oVZ0ZmkxsiILnQ8Az8gu0gSdQLhKMfbycF4t3oasBp0udWuB2dYVhUYyoHnRdmetkAmJ1MgyIVUrD28On19unFpECOwaBejs/nCX01bX0iwYwid9A5rV4U7qUBMIlmWGLfUVMASop8HJf+JmdLBpoCzWcBfWcbN7HfBZe8bJXIW0bTg6lj+EN+XhNkwsmHTN2bAUobWg=", "referralCode": "abcdefgh", "pointsLedger": { "available": 0, "signup": 600, "referral": 0, "redeemable": 0, "expired": 0, "redeemed": 0, "refunded": 0, "transactions": [ { "_id": "5aad5e56f7418c444d79f464", "points": 600, "type": "Issue", "date": { "$date": 1521311318734 }, "notes": "Signup", "expiryDate": { "$date": 1552868918734 } } ] } }); it("Instantiation successful", function () { expect(account).to.not.be.null; expect(account).to.not.be.undefined; expect(account).to.be.an.instanceof(Account_1.Account); }); it("Contact information initialised.", function () { expect(account, "account.name").to.have.property("name").equal("Test"); expect(account, "account.email").to.have.property("email").equal("contact@example.com"); expect(account, "account.phone").to.have.property("phone").equal("123456789"); }); it("Password initialised.", function () { expect(account.CanAuthenticateUsing("password")).to.be.true; }); it("Object ID initialised.", function () { expect(account).to.have.property("_id").be.an.instanceof(bson_1.ObjectId); }); it("Referral code initialised.", function () { expect(account).to.have.property("referralCode").not.be.null; expect(account).to.have.property("referralCode").not.be.undefined; expect(account).to.have.property("referralCode").be.a("string"); }); it("Password reset successful.", function () { account.ResetPassword("password"); expect(account.CanAuthenticateUsing("password")).to.be.true; }); }); //# sourceMappingURL=Account.spec.js.map