Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
morukele committed Nov 29, 2023
1 parent 1f3c0a5 commit 6946485
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions examples/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ async fn main() {
.email("[email protected]".to_string())
.currency(Some(Currency::NGN))
.channels(Some(vec![
Channel::Card,
Channel::ApplePay,
Channel::Bank,
Channel::BankTransfer,
Expand Down
11 changes: 7 additions & 4 deletions tests/api/charge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ use crate::helpers::get_paystack_client;
use paystack::{Channel, ChargeBodyBuilder, Currency};
use rand::Rng;

/// Values are hardcoded in this test because of the nature of the test.
/// The values reflect the values in my integration.
/// If you can come up with a way to improve this test, take a stab at it.
#[tokio::test]
async fn charge_authorization_succeeds() {
// Arrange
Expand All @@ -12,9 +15,9 @@ async fn charge_authorization_succeeds() {
// In this test, an already created customer in the integration is used
let amount = rng.gen_range(100..=100000).to_string();
let charge = ChargeBodyBuilder::default()
.email("melyssa@example.net".to_string())
.email("susanna@example.net".to_string())
.amount(amount)
.authorization_code("AUTH_9v3686msvt".to_string())
.authorization_code("AUTH_ik4t69fo2y".to_string())
.currency(Some(Currency::NGN))
.channel(Some(vec![Channel::Card]))
.transaction_charge(Some(100))
Expand All @@ -31,7 +34,7 @@ async fn charge_authorization_succeeds() {
assert!(charge_response.status);
assert_eq!(
charge_response.data.customer.unwrap().email.unwrap(),
"melyssa@example.net"
"susanna@example.net"
);
assert_eq!(
charge_response
Expand All @@ -50,6 +53,6 @@ async fn charge_authorization_succeeds() {
.unwrap()
.authorization_code
.unwrap(),
"AUTH_9v3686msvt"
"AUTH_ik4t69fo2y"
);
}
3 changes: 2 additions & 1 deletion tests/api/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ async fn initialize_transaction_valid() {
.email(email)
.currency(Some(Currency::NGN))
.channels(Some(vec![
Channel::Card,
Channel::ApplePay,
Channel::BankTransfer,
Channel::Bank,
Expand All @@ -35,7 +36,7 @@ async fn initialize_transaction_valid() {
.await
.expect("Unable to initialize transaction");

// println!("{:#?}", res);
println!("{:#?}", res);

// Assert
assert!(res.status);
Expand Down

0 comments on commit 6946485

Please sign in to comment.