Skip to content

Instantly share code, notes, and snippets.

@jasongorman
Created March 22, 2019 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasongorman/a701406aa4d8635c2fedf7265c1d3685 to your computer and use it in GitHub Desktop.
Save jasongorman/a701406aa4d8635c2fedf7265c1d3685 to your computer and use it in GitHub Desktop.
const BankAccount = require("../../src/liskov_substitution/bank_account");
describe('bank account', () => {
it('credit account', () => {
const account = new BankAccount();
account.credit(account, 50);
expect(account.balance).toBe(50);
})
it('debit account with sufficient funds', () => {
const account = new BankAccount();
account.credit(account, 50);
account.debit(account, 50);
expect(account.balance).toBe(0);
})
it('debit account with insufficient funds', () => {
const account = new BankAccount();
account.credit(account, 50);
expect(() => account.debit(account, 51)).toThrow('Insufficient funds error');
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment