-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from mainmatter/handle-service
include selected service in message
- Loading branch information
Showing
2 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ async fn it_works_for_the_happy_path() { | |
name: String::from("name"), | ||
email: String::from("[email protected]"), | ||
message: String::from("Hi!"), | ||
service: String::from("Digital Products & Design"), | ||
}; | ||
let result = send_message(payload, "api_key", &request_sendgrid).await; | ||
|
||
|
@@ -34,7 +35,7 @@ async fn it_sends_the_right_payload_to_sendgrid() { | |
"subject": "Mainmatter inquiry", | ||
"content": [{ | ||
"type": "text/plain", | ||
"value": "Hi!" | ||
"value": "Service: Digital Products & Design\n\nHi!" | ||
}] | ||
}); | ||
|
||
|
@@ -47,6 +48,7 @@ async fn it_sends_the_right_payload_to_sendgrid() { | |
name: String::from("name"), | ||
email: String::from("[email protected]"), | ||
message: String::from("Hi!"), | ||
service: String::from("Digital Products & Design"), | ||
}; | ||
let _result = send_message(payload, "api_key", &request_sendgrid).await; | ||
} | ||
|
@@ -65,7 +67,7 @@ async fn it_sends_an_empty_message_if_none_is_provided() { | |
"subject": "Mainmatter inquiry", | ||
"content": [{ | ||
"type": "text/plain", | ||
"value": "–" | ||
"value": "Service: Digital Products & Design\n\n–" | ||
}] | ||
}); | ||
|
||
|
@@ -78,6 +80,39 @@ async fn it_sends_an_empty_message_if_none_is_provided() { | |
name: String::from("name"), | ||
email: String::from("[email protected]"), | ||
message: String::from(""), | ||
service: String::from("Digital Products & Design"), | ||
}; | ||
let _result = send_message(payload, "api_key", &request_sendgrid).await; | ||
} | ||
|
||
#[wasm_bindgen_test] | ||
async fn it_sends_an_empty_service_if_none_is_provided() { | ||
async fn request_sendgrid(_api_key: &str, data: String) -> Result<u16, NetworkError> { | ||
let expected = json!({ | ||
"personalizations": [{ | ||
"to": [ | ||
{ "email": "[email protected]", "name": "Mainmatter" } | ||
]} | ||
], | ||
"from": { "email": "[email protected]", "name": "name via mainmatter.com" }, | ||
"reply_to": { "email": "[email protected]", "name": "name" }, | ||
"subject": "Mainmatter inquiry", | ||
"content": [{ | ||
"type": "text/plain", | ||
"value": "Service: –\n\nHi!" | ||
}] | ||
}); | ||
|
||
assert_eq!(data, expected.to_string()); | ||
|
||
Ok(200) | ||
} | ||
|
||
let payload = Payload { | ||
name: String::from("name"), | ||
email: String::from("[email protected]"), | ||
message: String::from("Hi!"), | ||
service: String::from(""), | ||
}; | ||
let _result = send_message(payload, "api_key", &request_sendgrid).await; | ||
} | ||
|
@@ -92,6 +127,7 @@ async fn it_responds_with_502_if_sendgrid_errors() { | |
name: String::from("name"), | ||
email: String::from("[email protected]"), | ||
message: String::from("Hi!"), | ||
service: String::from(""), | ||
}; | ||
let result = send_message(payload, "api_key", &request_sendgrid).await; | ||
|
||
|
@@ -108,6 +144,7 @@ async fn it_responds_with_500_if_calling_sendgrid_errors() { | |
name: String::from("name"), | ||
email: String::from("[email protected]"), | ||
message: String::from("Hi!"), | ||
service: String::from(""), | ||
}; | ||
let result = send_message(payload, "api_key", &request_sendgrid).await; | ||
|
||
|