aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-06-10 22:27:01 -0700
committerZeyla Hellyer <[email protected]>2017-06-10 22:27:01 -0700
commite92b667058138ffd01587e28e9d8551cd59df160 (patch)
tree756f3db02851474c342adc0464707a1ca9bc01e4 /tests
parentFix negative nonces failing to deserialize (diff)
downloadserenity-e92b667058138ffd01587e28e9d8551cd59df160.tar.xz
serenity-e92b667058138ffd01587e28e9d8551cd59df160.zip
Deserialize embed footers
Diffstat (limited to 'tests')
-rw-r--r--tests/resources/message_footer_1.json70
-rw-r--r--tests/test_create_embed.rs1
-rw-r--r--tests/test_message.rs24
3 files changed, 95 insertions, 0 deletions
diff --git a/tests/resources/message_footer_1.json b/tests/resources/message_footer_1.json
new file mode 100644
index 0000000..8c0fb21
--- /dev/null
+++ b/tests/resources/message_footer_1.json
@@ -0,0 +1,70 @@
+{
+ "attachments": [],
+ "tts": false,
+ "embeds": [
+ {
+ "description": "Kyon is your ordinary high school freshman who has long given up on his childhood dreams of encountering the fantastic and supernatural…or so he thought. From the very first day of school, his classmate–the beautiful but eccentric Haruhi Suzumiya–makes it very clear that her only desire is to meet aliens, time travelers, and psychics! A chance conversation between the two inspires Haruhi to form the SOS Brigade, a school club created for the sole purpose of getting these supernatural beings together. The initial members consist of the mute bookworm Yuki Nagato, the timid but voluptuous Mikuru Asahina, and the polite and ever-smiling Itsuki Koizumi. By the end of this first volume, Kyon quickly finds out that these seemingly “helpless victims” of Haruhi’s are actually members of secret organizations–both futuristic and alien–keeping watch over Haruhi as she is the pinnacle of some major calamity on the horizon… \n(Source: Yen Press)",
+ "author": {
+ "url": "https://kitsu.io/manga/suzumiya-haruhi-no-yuuutsu-1d17ddde-b0df-4389-9d4a-f06faa4d6427",
+ "name": "Suzumiya Haruhi no Yuuutsu"
+ },
+ "color": 16738048,
+ "fields": [
+ {
+ "inline": true,
+ "name": "Type",
+ "value": "Manga"
+ },
+ {
+ "inline": true,
+ "name": "Volume(s)",
+ "value": "20"
+ },
+ {
+ "inline": true,
+ "name": "Rating",
+ "value": "75.5/100"
+ },
+ {
+ "inline": true,
+ "name": "Chapters",
+ "value": "105"
+ },
+ {
+ "inline": true,
+ "name": "Rank",
+ "value": "758"
+ }
+ ],
+ "footer": {
+ "text": "2005-09-26 - 2013-09-26",
+ "proxy_icon_url": "https://images-ext-1.discordapp.net/external/pfZ4lvyhr9-sWzjU_u1DcTYZ7QutEFR4e1CZoXq2CS8/http/i.imgur.com/taRJXqB.png",
+ "icon_url": "http://i.imgur.com/taRJXqB.png"
+ },
+ "type": "rich",
+ "thumbnail": {
+ "url": "https://media.kitsu.io/manga/poster_images/2899/original.jpg?1434255521",
+ "width": 225,
+ "proxy_url": "https://images-ext-2.discordapp.net/external/PPXC92RHs7u8dxa4EGK3IBBuCLibURqP7-LOzWG_zxo/%3F1434255521/https/media.kitsu.io/manga/poster_images/2899/original.jpg",
+ "height": 315
+ }
+ }
+ ],
+ "timestamp": "2017-06-10T21:09:39.366000+00:00",
+ "mention_everyone": false,
+ "id": "323207107669393420",
+ "pinned": false,
+ "edited_timestamp": null,
+ "author": {
+ "username": "Yuki α",
+ "discriminator": "0097",
+ "bot": true,
+ "id": "134755682170699776",
+ "avatar": "cf3f033038c87cb89aa9eadc37ef9c09"
+ },
+ "mention_roles": [],
+ "content": "",
+ "channel_id": "244567637332328449",
+ "mentions": [],
+ "type": 0
+}
diff --git a/tests/test_create_embed.rs b/tests/test_create_embed.rs
index 13596cf..8e9537d 100644
--- a/tests/test_create_embed.rs
+++ b/tests/test_create_embed.rs
@@ -24,6 +24,7 @@ fn test_from_embed() {
value: "z".to_owned(),
},
],
+ footer: None,
image: Some(EmbedImage {
height: 213,
proxy_url: "a".to_owned(),
diff --git a/tests/test_message.rs b/tests/test_message.rs
new file mode 100644
index 0000000..7a8f083
--- /dev/null
+++ b/tests/test_message.rs
@@ -0,0 +1,24 @@
+extern crate serde;
+extern crate serde_json;
+extern crate serenity;
+
+use serde::de::Deserialize;
+use serde_json::Value;
+use serenity::model::Message;
+use std::fs::File;
+
+macro_rules! p {
+ ($s:ident, $filename:expr) => ({
+ let f = File::open(concat!("./tests/resources/", $filename, ".json")).unwrap();
+ let v = serde_json::from_reader::<File, Value>(f).unwrap();
+
+ $s::deserialize(v).unwrap()
+ })
+}
+
+#[test]
+fn test_footer_deser() {
+ let mut message = p!(Message, "message_footer_1");
+
+ assert_eq!(message.embeds.remove(0).footer.unwrap().text, "2005-09-26 - 2013-09-26");
+}