Created
March 15, 2019 09:22
-
-
Save jasongorman/1d3022688c9eb3af158009550fb82c8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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