use crate::ids::UserId; use crate::models::properties::{DateOrDateTime, DateValue}; use crate::models::text::{ Annotations, Link, MentionObject, RichText, RichTextCommon, Text, TextColor, }; use crate::models::users::{Person, User, UserCommon}; use crate::models::{ListResponse, Object, Page}; use chrono::{DateTime, NaiveDate}; use std::str::FromStr; #[test] fn deserialize_page() { let _page: Page = serde_json::from_str(include_str!("tests/page.json")).unwrap(); } #[test] fn deserialize_query_result() { let _page: ListResponse = serde_json::from_str(include_str!("tests/query_result.json")).unwrap(); } #[test] fn deserialize_number_format() { let _search_results: ListResponse = serde_json::from_str(include_str!("tests/issue_15.json")).unwrap(); } #[test] fn rich_text() { let rich_text_text: RichText = serde_json::from_str(include_str!("tests/rich_text_text.json")).unwrap(); assert_eq!( rich_text_text, RichText::Text { rich_text: RichTextCommon { plain_text: "Rich".to_string(), href: Some("https://github.com/jakeswenson/notion".to_string()), annotations: Some(Annotations { bold: Some(true), code: Some(true), color: Some(TextColor::Default), italic: Some(true), strikethrough: Some(true), underline: Some(true), }), }, text: Text { content: "Rich".to_string(), link: Some(Link { url: "https://github.com/jakeswenson/notion".to_string() }), }, } ) } #[test] fn rich_text_mention_user_person() { let rich_text_mention_user_person: RichText = serde_json::from_str(include_str!("tests/rich_text_mention_user_person.json")).unwrap(); assert_eq!( rich_text_mention_user_person, RichText::Mention { rich_text: RichTextCommon { plain_text: "@John Doe".to_string(), href: None, annotations: Some(Annotations { bold: Some(false), code: Some(false), color: Some(TextColor::Default), italic: Some(false), strikethrough: Some(false), underline: Some(false), }), }, mention: MentionObject::User { user: User::Person { common: UserCommon { id: UserId::from_str("1118608e-35e8-4fa3-aef7-a4ced85ce8e0").unwrap(), name: Some("John Doe".to_string()), avatar_url: Some( "https://secure.notion-static.com/e6a352a8-8381-44d0-a1dc-9ed80e62b53d.jpg" .to_string() ), }, person: Person { email: "john.doe@gmail.com".to_string() }, } }, } ) } #[test] fn rich_text_mention_date() { let rich_text_mention_date: RichText = serde_json::from_str(include_str!("tests/rich_text_mention_date.json")).unwrap(); assert_eq!( rich_text_mention_date, RichText::Mention { rich_text: RichTextCommon { plain_text: "2022-04-16 → ".to_string(), href: None, annotations: Some(Annotations { bold: Some(false), code: Some(false), color: Some(TextColor::Default), italic: Some(false), strikethrough: Some(false), underline: Some(false), }), }, mention: MentionObject::Date { date: DateValue { start: DateOrDateTime::Date(NaiveDate::from_str("2022-04-16").unwrap()), end: None, time_zone: None, } }, } ) } #[test] fn rich_text_mention_date_with_time() { let rich_text_mention_date_with_time: RichText = serde_json::from_str(include_str!("tests/rich_text_mention_date_with_time.json")).unwrap(); assert_eq!( rich_text_mention_date_with_time, RichText::Mention { rich_text: RichTextCommon { plain_text: "2022-05-14T09:00:00.000-04:00 → ".to_string(), href: None, annotations: Some(Annotations { bold: Some(false), code: Some(false), color: Some(TextColor::Default), italic: Some(false), strikethrough: Some(false), underline: Some(false), }), }, mention: MentionObject::Date { date: DateValue { start: DateOrDateTime::DateTime( DateTime::from_str("2022-05-14T09:00:00.000-04:00").unwrap() ), end: None, time_zone: None, } }, } ) } #[test] fn rich_text_mention_date_with_end() { let rich_text_mention_date_with_end: RichText = serde_json::from_str(include_str!("tests/rich_text_mention_date_with_end.json")).unwrap(); assert_eq!( rich_text_mention_date_with_end, RichText::Mention { rich_text: RichTextCommon { plain_text: "2022-05-12 → 2022-05-13".to_string(), href: None, annotations: Some(Annotations { bold: Some(false), code: Some(false), color: Some(TextColor::Default), italic: Some(false), strikethrough: Some(false), underline: Some(false), }), }, mention: MentionObject::Date { date: DateValue { start: DateOrDateTime::Date(NaiveDate::from_str("2022-05-12").unwrap()), end: Some(DateOrDateTime::Date( NaiveDate::from_str("2022-05-13").unwrap() )), time_zone: None, } }, } ) } #[test] fn rich_text_mention_date_with_end_and_time() { let rich_text_mention_date_with_end_and_time: RichText = serde_json::from_str(include_str!( "tests/rich_text_mention_date_with_end_and_time.json" )) .unwrap(); assert_eq!( rich_text_mention_date_with_end_and_time, RichText::Mention { rich_text: RichTextCommon { plain_text: "2022-04-16T12:00:00.000-04:00 → 2022-04-16T12:00:00.000-04:00" .to_string(), href: None, annotations: Some(Annotations { bold: Some(false), code: Some(false), color: Some(TextColor::Default), italic: Some(false), strikethrough: Some(false), underline: Some(false), }), }, mention: MentionObject::Date { date: DateValue { start: DateOrDateTime::DateTime( DateTime::from_str("2022-04-16T12:00:00.000-04:00").unwrap() ), end: Some(DateOrDateTime::DateTime( DateTime::from_str("2022-04-16T12:00:00.000-04:00").unwrap() )), time_zone: None, } }, } ) } low-components Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
'Gravatar' /> Drew Powers
AgeCommit message (Expand)AuthorFilesLines
2021-11-19[ci] yarn formatGravatar matthewp 1-3/+3
2021-11-19Add Debug tests (#1882)Gravatar Matthew Phillips 4-0/+62
2021-11-19[ci] collect statsGravatar FredKSchott 1-0/+1
2021-11-19Version Packages (next) (#1881)astro@0.21.0-next.8@astrojs/renderer-vue@0.2.0-next.2Gravatar github-actions[bot] 25-23/+42
2021-11-18Improve HMR (#1896)Gravatar Drew Powers 2-10/+18
2021-11-18update depsGravatar Fred K. Schott 5-352/+65
2021-11-18fix #1778Gravatar Fred K. Schott 2-1/+8
2021-11-18Update compiler (#1869)Gravatar Nate Moore 3-11/+6
2021-11-18remove unused remark dependency (#1894)Gravatar Fred K. Schott 2-245/+13
2021-11-18Improve error messages (#1875)Gravatar Drew Powers 39-61/+448
2021-11-18pin astro compiler to older versionGravatar Fred K. Schott 2-5/+5
2021-11-18Update yarn.lock to reflect the state of the package.json files (#1892)Gravatar Jonathan Neal 5-1300/+1000
2021-11-19[ci] yarn formatGravatar FredKSchott 1-5/+3
39-61/+448
2021-11-18pin astro compiler to older versionGravatar Fred K. Schott 2-5/+5
2021-11-18Update yarn.lock to reflect the state of the package.json files (#1892)Gravatar Jonathan Neal 5-1300/+1000
2021-11-19[ci] yarn formatGravatar FredKSchott 1-5/+3