Skip to content

Instantly share code, notes, and snippets.

@jasongorman
Created March 15, 2019 09:22
Show Gist options
  • Save jasongorman/1d3022688c9eb3af158009550fb82c8e to your computer and use it in GitHub Desktop.
Save jasongorman/1d3022688c9eb3af158009550fb82c8e to your computer and use it in GitHub Desktop.
const {credit, debit} = require("../../src/liskov_substitution/bank_account");
describe('bank account', () => {
it('credit account', () => {
const account = {id: 1, balance: 0};
const credited = credit(account, 50);
expect(credited.balance).toBe(50);
})
it('debit account with sufficient funds', () => {
const account = {id: 1, balance: 50};
const debited = debit(account, 50);
expect(debited.balance).toBe(0);
})
it('debit account with insufficient funds', () => {
const account = {id: 1, balance: 50};
expect(() => 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