From 1e0d1fb97afd71f0c3c57571233ff9b177e2bc9d Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Tue, 3 May 2022 10:16:57 +0900 Subject: [PATCH] Add test for CustomGroup --- plume-common/src/activity_pub/mod.rs | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/plume-common/src/activity_pub/mod.rs b/plume-common/src/activity_pub/mod.rs index a939ae35..e79751c3 100644 --- a/plume-common/src/activity_pub/mod.rs +++ b/plume-common/src/activity_pub/mod.rs @@ -564,6 +564,40 @@ mod tests { assert_eq!(to_value(person).unwrap(), expected); } + #[test] + fn de_custom_group() { + let group = CustomGroup::new( + ApActor::new("https://example.com/inbox".parse().unwrap(), Group::new()), + ApSignature { + public_key: PublicKey { + id: "https://example.com/pubkey".parse().unwrap(), + owner: "https://example.com/owner".parse().unwrap(), + public_key_pem: "pubKeyPem".into(), + }, + }, + SourceProperty { + source: Source { + content: String::from("This is a *custom* group."), + media_type: String::from("text/markdown"), + }, + }, + ); + let expected = json!({ + "inbox": "https://example.com/inbox", + "type": "Group", + "publicKey": { + "id": "https://example.com/pubkey", + "owner": "https://example.com/owner", + "publicKeyPem": "pubKeyPem" + }, + "source": { + "content": "This is a *custom* group.", + "mediaType": "text/markdown" + } + }); + assert_eq!(to_value(group).unwrap(), expected); + } + #[test] fn se_licensed_article() { let object = ApObject::new(Article::new());