Skip to content

Commit

Permalink
Add test for charge having nullable refunds
Browse files Browse the repository at this point in the history
  • Loading branch information
mzeitlin11 committed Dec 23, 2023
1 parent d8a2dec commit feb13c4
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/tests/it/deser.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use serde_json::json;
use stripe_core::Customer;
use stripe_core::charge::ChargeStatus;
use stripe_core::{Charge, Customer};
use stripe_types::Currency;

#[test]
fn deserialize_customer_with_card() {
Expand Down Expand Up @@ -198,3 +200,29 @@ fn deserialize_checkout_event() {
let result = serde_json::from_value::<Event>(example);
assert!(result.is_ok(), "expected ok; was {:?}", result);
}

#[test]
// https://github.com/arlyon/async-stripe/issues/456
// NB: deserialization test because `stripe_mock` always includes `refunds`
fn deserialize_charge_with_no_refunds() {
let example = json!({
"amount": 0,
"billing_details": {},
"amount_captured": 0,
"amount_refunded": 0,
"captured": true,
"currency": "cad",
"created": 1703349829,
"disputed": false,
"id": "ch_123",
"livemode": false,
"metadata": {},
"paid": false,
"status": "pending",
"refunded": false,
});
let charge: Charge = serde_json::from_value(example).unwrap();
assert_eq!(charge.id.as_str(), "ch_123");
assert_eq!(charge.currency, Currency::CAD);
assert_eq!(charge.status, ChargeStatus::Pending);
}

0 comments on commit feb13c4

Please sign in to comment.