From 8d2c8f9bcccac7e1ab76f0025671cc5cd543f2fe Mon Sep 17 00:00:00 2001 From: Sunli Date: Tue, 27 Oct 2020 20:47:24 +0800 Subject: [PATCH] Add test for `SchemaBuilder::override_description`. #327 --- tests/use_type_description.rs | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/tests/use_type_description.rs b/tests/use_type_description.rs index 88339787..cb06b6da 100644 --- a/tests/use_type_description.rs +++ b/tests/use_type_description.rs @@ -1,5 +1,6 @@ use async_graphql::*; use async_std::stream::Stream; +use chrono::{DateTime, Utc}; #[async_std::test] pub async fn test_object() { @@ -98,3 +99,45 @@ pub async fn test_subscription() { }) ); } + +#[async_std::test] +pub async fn test_override_description() { + /// Haha + #[derive(SimpleObject)] + struct Query { + value: i32, + value2: DateTime, + } + + let schema = Schema::build( + Query { + value: 100, + value2: Utc::now(), + }, + EmptyMutation, + EmptySubscription, + ) + .override_description::("Hehe") + .override_description::>("DT") + .finish(); + + assert_eq!( + schema + .execute(r#"{ __type(name: "Query") { description } }"#) + .await + .data, + value!({ + "__type": { "description": "Hehe" } + }) + ); + + assert_eq!( + schema + .execute(r#"{ __type(name: "DateTime") { description } }"#) + .await + .data, + value!({ + "__type": { "description": "DT" } + }) + ); +}