Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const {credit, debit} = require("../../src/liskov_substitution/bank_account");
- const bankAccountTest = (account, credit, debit) => {
- it('credit account', () => {
- const credited = credit({...account, balance: 0}, 50);
- expect(credited.balance).toBe(50);
- })
- it('debit account with sufficient funds', () => {
- const debited = debit({...account, balance: 50}, 50);
- expect(debited.balance).toBe(0);
- })
- it('debit account with insufficient funds', () => {
- expect(() => debit({...account, balance: 50}, 51)).toThrow('Insufficient funds error');
- })
- }
- describe("bank account", () => {
- const {credit, debit} = require("../../src/liskov_substitution/bank_account");
- const account = {id: 1, balance: 0};
- bankAccountTest(account, credit, debit);
- })
- describe("bank account with overdraft facility", () => {
- const overdraft_debit = require("../../src/liskov_substitution/overdraft_account");
- const overdraft_account = {id: 1, balance: 0, limit: 1000};
- bankAccountTest(overdraft_account, credit, overdraft_debit);
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement