import {toNullable} from 'fp-ts/lib/Option'; import {Account, SimpleBank} from './bank'; import { Gen, Property, choose, elements, forall, keyValueOf, mapOf, mapOf1, property, } from './property'; const sampleAccounts: Account[] = [ 'FR12345678901234', 'DE2345678901234', 'IT34567890123412', ]; const genAccount: Gen = elements(sampleAccounts); const genBalance: Gen = choose(0, 1000000); const genAccounts: Gen> = mapOf1(genAccount, genBalance); describe('Bank Simulator', () => { test('can retrieve balance given account exists', () => { const prop = forall(genAccounts, accounts => { const api = new SimpleBank(accounts); return property(keyValueOf(accounts), ([accountNr, bal]) => { const retrieved = toNullable(api.balance(accountNr)); return retrieved == bal; }); }); const result = Property.run(prop); console.log(result); expect(result.result).toBe('OK'); }); });