From 8ef7d8f5aca4f5d4bc394a79a1ad44ca45625ec7 Mon Sep 17 00:00:00 2001 From: gustavo-shigueo Date: Mon, 25 Nov 2024 13:22:20 -0300 Subject: [PATCH] Also test tagging behavior in struct_tag test file --- ts-rs/tests/integration/struct_tag.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ts-rs/tests/integration/struct_tag.rs b/ts-rs/tests/integration/struct_tag.rs index e80475e4..bcb49960 100644 --- a/ts-rs/tests/integration/struct_tag.rs +++ b/ts-rs/tests/integration/struct_tag.rs @@ -13,10 +13,21 @@ struct TaggedType { b: i32, } +#[derive(TS)] +#[cfg_attr(feature = "serde-compat", derive(Serialize))] +#[cfg_attr(feature = "serde-compat", serde(tag = "type"))] +#[cfg_attr(not(feature = "serde-compat"), ts(tag = "type"))] +struct EmptyTaggedType {} + #[test] fn test() { assert_eq!( TaggedType::inline(), "{ \"type\": \"TaggedType\", a: number, b: number, }" - ) + ); + + assert_eq!( + EmptyTaggedType::inline(), + r#"{ "type": "EmptyTaggedType", }"# + ); }