api request Auth serializing test added
-use crate::types::api::APIRequest;
+use crate::types::api::{APIRequest, AuthRequest, GDPRConsentWithTime};
+use crate::types::profile::GDPRConsent;
+use chrono::prelude::TimeZone;
+use chrono::Utc;
+
+#[test]
+fn serialize_api_request_auth() {
+ let auth = vec![
+ APIRequest::Auth(AuthRequest::Login {
+ email: "email".to_owned(),
+ password: "password".to_owned(),
+ }),
+ APIRequest::Auth(AuthRequest::Register {
+ email: "email".to_owned(),
+ password: "password".to_owned(),
+ gdpr_consent: GDPRConsentWithTime {
+ gdpr_consent: GDPRConsent {
+ tos: true,
+ privacy: true,
+ marketing: true,
+ from: "from".to_owned(),
+ },
+ time: Utc.ymd(2020, 1, 1).and_hms_milli(0, 0, 0, 0),
+ },
+ }),
+ ];
+ let auth_json = r#"[{"type":"Auth","type":"Login","email":"email","password":"password"},{"type":"Auth","type":"Register","email":"email","password":"password","gdpr_consent":{"tos":true,"privacy":true,"marketing":true,"from":"from","time":"2020-01-01T00:00:00Z"}}]"#;
+ let auth_serialize = serde_json::to_string(&auth).unwrap();
+ assert_eq!(auth_json, auth_serialize, "Auth serialized successfully");
+}
#[test]
fn serialize_api_request_logout() {
