diff --git a/Cargo.lock b/Cargo.lock index a1af168..7b3a102 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1610,6 +1610,9 @@ dependencies = [ name = "specta-tests" version = "0.0.0" dependencies = [ + "chrono", + "either", + "glam 0.30.9", "insta", "serde", "serde_json", @@ -1620,6 +1623,7 @@ dependencies = [ "specta-util", "toml 0.8.23", "trybuild", + "ulid", "wasm-bindgen", ] diff --git a/specta-typescript/src/types.rs b/specta-typescript/src/types.rs index fa62b08..b0ffe0d 100644 --- a/specta-typescript/src/types.rs +++ b/specta-typescript/src/types.rs @@ -30,10 +30,12 @@ use specta::{ /// use specta::Type; /// use specta_typescript::Any; /// +/// # #[cfg(feature = "serde")] { /// #[derive(Serialize, Type)] /// pub struct Demo { /// pub field: Any, /// } +/// # } /// ``` pub struct Any(T); @@ -102,10 +104,12 @@ impl serde::Serialize for Any { /// use specta::Type; /// use specta_typescript::Unknown; /// +/// # #[cfg(feature = "serde")] { /// #[derive(Serialize, Type)] /// pub struct Demo { /// pub field: Unknown, /// } +/// # } /// ``` pub struct Unknown(T); @@ -174,10 +178,12 @@ impl serde::Serialize for Unknown { /// use specta::Type; /// use specta_typescript::Never; /// +/// # #[cfg(feature = "serde")] { /// #[derive(Serialize, Type)] /// pub struct Demo { /// pub field: Never, /// } +/// # } /// ``` pub struct Never(T); diff --git a/tests/Cargo.toml b/tests/Cargo.toml index ad5056b..f2a1e0c 100644 --- a/tests/Cargo.toml +++ b/tests/Cargo.toml @@ -11,7 +11,7 @@ path = "tests/lib.rs" harness = true [dependencies] -specta = { path = "../specta", features = ["derive", "serde_json", "serde_yaml", "unstable_json_macro", "toml"] } +specta = { path = "../specta", features = ["derive", "serde_json", "serde_yaml", "unstable_json_macro", "toml", "chrono", "either", "ulid", "glam"] } specta-serde = { path = "../specta-serde" } specta-typescript = { path = "../specta-typescript" } specta-util = { path = "../specta-util", features = ["serde"] } # TODO: Remove `serde` feature @@ -23,3 +23,7 @@ serde_json = "1.0.140" serde_yaml = "0.9.34" toml = "0.8.20" insta = "1.42.2" +chrono = { version = "0.4", default-features = false, features = ["clock"] } +either = { version = "1.15", default-features = false } +ulid = { version = "1.2", default-features = false, features = [] } +glam = { version = "0.30", default-features = false, features = ["std"] } diff --git a/tests/json.rs b/tests/json.rs deleted file mode 100644 index e2c7441..0000000 --- a/tests/json.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::ts::assert_ts; - -#[test] -#[cfg(feature = "serde")] -fn test_json() { - use specta::{json, True}; - - // assert_ts!(() => json!(null), "null"); - // assert_ts!(() => json!(true), "true"); - // assert_ts!(() => json!(false), "false"); - - // assert_ts!(() => json!({}), "Record"); - // assert_ts!(() => json!({ "hello": "world" }), "{ hello: string }"); - // assert_ts!(() => json!({ - // "hello": "world", - // }), "{ hello: string }"); - - // assert_ts!(() => json!([]), "[]"); - // assert_ts!(() => json!(["a", "b", "c"]), "string[]"); -} diff --git a/tests/tests/export.rs b/tests/tests/export.rs index 59fedc9..5e0342a 100644 --- a/tests/tests/export.rs +++ b/tests/tests/export.rs @@ -28,6 +28,7 @@ pub struct ReferingToUnexportedType { // TODO: Enable this test on Windows again. It's ordering of types is different for seemingly no reason. #[cfg(all(not(target_os = "windows"), all(feature = "export", feature = "ts")))] +// TODO: This feature guard is bogus because this test package doesn't define any features. #[test] fn test_export_feature() { use specta::{ diff --git a/tests/tests/json.rs b/tests/tests/json.rs index bc903a2..9a79584 100644 --- a/tests/tests/json.rs +++ b/tests/tests/json.rs @@ -21,9 +21,13 @@ fn test_json_macro() { // TODO: Fix these // assert_ts!(() => json!({ "a": "b" }), r#"{ "a": "b" }"#); + // assert_ts!(() => json!({ "hello": "world" }), "{ hello: string }"); + // assert_ts!(() => json!({ + // "hello": "world", + // }), "{ hello: string }"); // assert_ts!(() => json!({ "a": 5, "c": true, "d": false, "e": 42u8, "f": 2.7 }), r#""#); // assert_ts!(() => json!([]), "[]"); - // assert_ts!(() => json!(["a", "b", "c"]), ""); + // assert_ts!(() => json!(["a", "b", "c"]), "string[]"); // assert_ts!(() => json!([{}, {}, {}]), ""); // assert_ts!(() => json!([{ "n": "0" }, { "n": "1" }, { "n": "2" }]), ""); } diff --git a/tests/tests/lib.rs b/tests/tests/lib.rs index 5fcb2e1..e55247e 100644 --- a/tests/tests/lib.rs +++ b/tests/tests/lib.rs @@ -30,9 +30,7 @@ mod ty_override; mod type_collection; mod type_map; mod typescript; -// TODO: Bring this back -// #[cfg(all(feature = "ulid", feature = "typescript"))] -// mod ulid; +mod ulid; #[test] fn test_compile_errors() { diff --git a/tests/tests/remote_impls.rs b/tests/tests/remote_impls.rs index 5966eb6..0efffc0 100644 --- a/tests/tests/remote_impls.rs +++ b/tests/tests/remote_impls.rs @@ -1,5 +1,4 @@ #[test] -#[cfg(feature = "glam")] fn typescript_types_glam() { use crate::ts::assert_ts; @@ -34,6 +33,7 @@ fn typescript_types_glam() { #[test] #[cfg(feature = "bevy_ecs")] +// TODO: This feature guard is bogus because this test package doesn't define any features. fn typescript_types_bevy_ecs() { use specta_typescript::{self, BigIntExportBehavior, ExportConfig, ExportPath}; diff --git a/tests/tests/ts.rs b/tests/tests/ts.rs index ca6aee8..dfab0c1 100644 --- a/tests/tests/ts.rs +++ b/tests/tests/ts.rs @@ -324,11 +324,8 @@ fn typescript_types() { assert_ts!(PhantomData, r#"null"#); assert_ts!(Infallible, r#"never"#); - #[cfg(feature = "either")] - { - assert_ts!(either::Either, r#"string | number"#); - assert_ts!(either::Either, r#"number"#); - } + assert_ts!(either::Either, r#"string | number"#); + assert_ts!(either::Either, r#"number"#); assert_ts!(Any, r#"any"#); diff --git a/tests/tests/ts_rs/generics.rs b/tests/tests/ts_rs/generics.rs index 4a5bc07..29710e3 100644 --- a/tests/tests/ts_rs/generics.rs +++ b/tests/tests/ts_rs/generics.rs @@ -33,8 +33,8 @@ struct GenericAutoBound2 { #[specta(export = false)] struct Container1 { foo: Generic1, - bar: Box>>, - baz: Box>>>, + bar: HashSet>, + baz: BTreeMap>>, } #[test] diff --git a/tests/tests/ts_rs/indexmap.rs b/tests/tests/ts_rs/indexmap.rs index 4cd3a14..b7881e5 100644 --- a/tests/tests/ts_rs/indexmap.rs +++ b/tests/tests/ts_rs/indexmap.rs @@ -1,4 +1,5 @@ #![cfg(feature = "indexmap")] +// TODO: This feature guard is bogus because this test package doesn't define any features. use indexmap::{IndexMap, IndexSet}; use specta::Type; diff --git a/tests/tests/ts_rs/mod.rs b/tests/tests/ts_rs/mod.rs index d7e1f81..65ac941 100644 --- a/tests/tests/ts_rs/mod.rs +++ b/tests/tests/ts_rs/mod.rs @@ -1,5 +1,4 @@ mod arrays; -#[cfg(feature = "chrono")] mod chrono; mod field_rename; mod flatten; diff --git a/tests/tests/ts_rs/union_serde.rs b/tests/tests/ts_rs/union_serde.rs index 20fa0cb..7534de5 100644 --- a/tests/tests/ts_rs/union_serde.rs +++ b/tests/tests/ts_rs/union_serde.rs @@ -30,7 +30,6 @@ enum Untagged { None, } -#[cfg(feature = "serde")] #[test] fn test_serde_enum() { assert_ts!(SimpleEnumA, r#"{ kind: "A" } | { kind: "B" }"#); diff --git a/tests/tests/ts_rs/union_with_internal_tag.rs b/tests/tests/ts_rs/union_with_internal_tag.rs index dfec900..c4ce1cb 100644 --- a/tests/tests/ts_rs/union_with_internal_tag.rs +++ b/tests/tests/ts_rs/union_with_internal_tag.rs @@ -31,7 +31,6 @@ enum EnumWithInternalTag2 { } #[test] -#[cfg(feature = "serde")] fn test_enums_with_internal_tags() { assert_ts!( EnumWithInternalTag, diff --git a/tests/tests/type_collection.rs b/tests/tests/type_collection.rs index e5d72d1..bee661b 100644 --- a/tests/tests/type_collection.rs +++ b/tests/tests/type_collection.rs @@ -31,7 +31,6 @@ fn type_collection_duplicate_register_ty() { // TODO: Bring this back // #[test] -// #[cfg(feature = "typescript")] // fn type_collection_ts() { // let result = TypeCollection::default() // .register::()