Test updates.
This commit is contained in:
@@ -42,6 +42,25 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serializes_account_response() {
|
||||
let id = Uuid::nil();
|
||||
let account = request().into_domain(id).unwrap();
|
||||
let response = serde_json::to_value(AccountResponse::from(account)).unwrap();
|
||||
|
||||
assert_eq!(response["id"], id.to_string());
|
||||
assert_eq!(response["name"], "Savings");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deserializes_account_response_as_request() {
|
||||
let account = request().into_domain(Uuid::nil()).unwrap();
|
||||
let response = serde_json::to_value(AccountResponse::from(account)).unwrap();
|
||||
let request: AccountRequest = serde_json::from_value(response).unwrap();
|
||||
|
||||
assert_eq!(request.name, "Savings");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn converts_between_dto_and_domain() {
|
||||
let id = Uuid::new_v4();
|
||||
@@ -53,19 +72,4 @@ mod tests {
|
||||
assert_eq!(response.id, id);
|
||||
assert_eq!(response.name, "Savings");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn keeps_account_json_flat() {
|
||||
let response = AccountResponse {
|
||||
id: Uuid::nil(),
|
||||
name: "Savings".to_owned(),
|
||||
};
|
||||
|
||||
let response = serde_json::to_value(response).unwrap();
|
||||
assert_eq!(response["id"], Uuid::nil().to_string());
|
||||
assert_eq!(response["name"], "Savings");
|
||||
|
||||
let request: AccountRequest = serde_json::from_value(response).unwrap();
|
||||
assert_eq!(request.name, "Savings");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user