-
Notifications
You must be signed in to change notification settings - Fork 0
/
ContaBancaria.test.ts
49 lines (39 loc) · 1.37 KB
/
ContaBancaria.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { beforeEach, describe, expect, test } from "bun:test";
import ContaBancaria from "./ContaBancaria.ts";
describe("Teste da classe ContaBancaria", () => {
let conta: ContaBancaria
let contaDois: ContaBancaria
beforeEach(() => {
conta = new ContaBancaria()
contaDois = new ContaBancaria()
})
test("Método Depositar", () => {
expect(conta.depositar(200)).toBe(200)
})
test("Método Depositar - Depósito Inválido", () => {
expect(() => conta.depositar(-100)).toThrow("Valor inválido")
})
test("Método Sacar", () => {
conta.depositar(300)
expect(conta.sacar(200)).toBe(100)
})
test("Método Sacar - Saque Inválido", () => {
expect(() => conta.sacar(-80)).toThrow("Valor inválido ou saldo insuficiente")
})
test("Método transferir", () => {
conta.depositar(500)
expect(conta.transferir(200, contaDois)).toBe(300)
})
test("Método transferir - Valor Inválido", () => {
expect(() => conta.transferir(200, contaDois)).toThrow("Valor inválido ou saldo insuficiente")
})
test("Consultar Saldo", () => {
conta.depositar(500)
expect(conta.consultarSaldo()).toBe(`Seu saldo atual é de R$ 500`)
})
test("Exibir Extrato", () => {
conta.depositar(200)
conta.sacar(100)
expect(conta.exibirExtrato()).toBe("1. Depósito de R$ 200.00 - 19/9/2024\n2. Saque de R$ 100.00 - 19/9/2024")
})
})