Skip to content

Commit

Permalink
Also test tagging behavior in struct_tag test file
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavo-shigueo committed Nov 25, 2024
1 parent 212108a commit 8ef7d8f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ts-rs/tests/integration/struct_tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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", }"#
);
}

0 comments on commit 8ef7d8f

Please sign in to comment.