Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.