Skip to content

Instantly share code, notes, and snippets.

@Rukeeo1
Created May 6, 2019 12:00
Show Gist options
  • Save Rukeeo1/77c8884dc84c2cefc3750e76c4075386 to your computer and use it in GitHub Desktop.
Save Rukeeo1/77c8884dc84c2cefc3750e76c4075386 to your computer and use it in GitHub Desktop.
test cases for user.test.js
/* import the User constructor*/
const User = require("./user_constructor").User;
//..create dummy users for test purposes
let userOne = new User("John Doe");
let userTwo = new User("Jane Doe");
let userThree = new User("Bill Clinton");
describe("testing that the constructor function returns an object", function() {
it("should return 'object'", function() {
expect(typeof userOne).toBe("object");
});
it("should return the UserTwo object", function() {
expect(userTwo).toEqual({ accountBalance: 0, id: 1, name: "Jane Doe" });
});
});
describe("the User should should be able to make deposits", function() {
it("should update the user's account balance", function() {
userTwo.makeDeposit(45);
expect(userTwo).toEqual({ accountBalance: 45, id: 1, name: "Jane Doe" });
});
it("should only all integers", function() {
expect(userTwo.makeDeposit("a string")).toBe("please enter a valid number");
});
});
describe("the User should be able to make withdrawals", function() {
//to enable the user make withdrawals ....let's firs make a deposit to user three.
userThree.makeDeposit(400);
//{"accountBalance": 400, "id": 2, "name": "Bill Clinton"}
userThree.withdrawal(150);
it("should deduct from the account balance ", function() {
expect(userThree).toEqual({
accountBalance: 250,
id: 2,
name: "Bill Clinton"
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment