forked from sorentwo/braintree-elixir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomer_test.exs
52 lines (42 loc) · 1.31 KB
/
customer_test.exs
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
50
51
52
defmodule Braintree.CustomerTest do
use ExUnit.Case, async: true
alias Braintree.Customer
test "all customer attributes are included" do
customer = %Customer{
company: "Soren",
email: "parker@example.com",
first_name: "Parker",
last_name: "Selbert"
}
assert customer.id == nil
assert customer.company == "Soren"
assert customer.email == "parker@example.com"
assert customer.first_name == "Parker"
assert customer.last_name == "Selbert"
assert customer.addresses == []
assert customer.credit_cards == []
assert customer.paypal_accounts == []
end
test "new/1 converts nested payment methods to a list of known structs" do
customer = Customer.new(%{
"company" => "Soren",
"email" => "parker@example.com",
"credit_cards" => [%{
"bin" => "12345",
"card_type" => "Visa"
}],
"paypal_accounts" => [%{
"email" => "parker@example.com",
"token" => "t0k3n"
}]
})
assert Enum.any?(customer.credit_cards)
assert Enum.any?(customer.paypal_accounts)
[card] = customer.credit_cards
assert card.bin == "12345"
assert card.card_type == "Visa"
[paypal] = customer.paypal_accounts
assert paypal.email == "parker@example.com"
assert paypal.token == "t0k3n"
end
end