mirror of
https://github.com/xazukx/ts-rs.git
synced 2026-11-18 22:30:26 +00:00
adjust tests
This commit is contained in:
@@ -11,7 +11,7 @@ pub(crate) fn unit(name: &str, rename_all: &Option<Inflection>) -> Result<Derive
|
||||
|
||||
Ok(DerivedTS {
|
||||
inline: quote!("null".to_owned()),
|
||||
decl: quote!(format!("export type {} = null;", #name)),
|
||||
decl: quote!(format!("type {} = null;", #name)),
|
||||
inline_flattened: None,
|
||||
name: name.to_owned(),
|
||||
dependencies: quote!(vec![]),
|
||||
|
||||
@@ -20,7 +20,7 @@ fn test_newtype() {
|
||||
#[derive(TS)]
|
||||
struct NewType(String);
|
||||
|
||||
assert_eq!("export type NewType = string;", NewType::decl());
|
||||
assert_eq!("type NewType = string;", NewType::decl());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -28,7 +28,7 @@ fn test_tuple_newtype() {
|
||||
#[derive(TS)]
|
||||
struct TupleNewType(String, i32, (i32, i32));
|
||||
assert_eq!(
|
||||
"export type TupleNewType = [string, number, [number, number]];",
|
||||
"type TupleNewType = [string, number, [number, number]];",
|
||||
TupleNewType::decl()
|
||||
)
|
||||
}
|
||||
|
||||
@@ -14,6 +14,6 @@ enum SimpleEnum {
|
||||
fn test_simple_enum() {
|
||||
assert_eq!(
|
||||
SimpleEnum::decl(),
|
||||
r#"export type SimpleEnum = "asdf" | "B" | "C";"#
|
||||
r#"type SimpleEnum = "asdf" | "B" | "C";"#
|
||||
)
|
||||
}
|
||||
|
||||
@@ -16,6 +16,6 @@ enum RenamedEnum {
|
||||
fn test_simple_enum() {
|
||||
assert_eq!(
|
||||
RenamedEnum::decl(),
|
||||
r#"export type SimpleEnum = "ASDF" | "b" | "c";"#
|
||||
r#"type SimpleEnum = "ASDF" | "b" | "c";"#
|
||||
)
|
||||
}
|
||||
|
||||
@@ -31,11 +31,11 @@ enum Untagged {
|
||||
fn test_serde_enum() {
|
||||
assert_eq!(
|
||||
SimpleEnum::decl(),
|
||||
r#"export type SimpleEnum = {kind: "A", d: null} | {kind: "B", d: null};"#
|
||||
r#"type SimpleEnum = {kind: "A", d: null} | {kind: "B", d: null};"#
|
||||
);
|
||||
assert_eq!(
|
||||
ComplexEnum::decl(),
|
||||
r#"export type ComplexEnum = {kind: "A", data: null} | {kind: "B", data: {
|
||||
r#"type ComplexEnum = {kind: "A", data: null} | {kind: "B", data: {
|
||||
foo: string,
|
||||
bar: number,
|
||||
}} | {kind: "W", data: SimpleEnum} | {kind: "F", data: {
|
||||
@@ -45,6 +45,6 @@ fn test_serde_enum() {
|
||||
|
||||
assert_eq!(
|
||||
Untagged::decl(),
|
||||
r#"export type Untagged = string | number | null;"#
|
||||
r#"type Untagged = string | number | null;"#
|
||||
)
|
||||
}
|
||||
|
||||
@@ -26,13 +26,13 @@ enum SimpleEnum {
|
||||
fn test_stateful_enum() {
|
||||
assert_eq!(
|
||||
Foo::decl(),
|
||||
r#"export interface Foo {
|
||||
r#"interface Foo {
|
||||
bar: Bar,
|
||||
}"#
|
||||
);
|
||||
assert_eq!(
|
||||
SimpleEnum::decl(),
|
||||
r#"export type SimpleEnum = string | number | "C" | [string, number] | Foo | {
|
||||
r#"type SimpleEnum = string | number | "C" | [string, number] | Foo | {
|
||||
a: number,
|
||||
b: string,
|
||||
};"#
|
||||
|
||||
+1
-1
@@ -5,5 +5,5 @@ struct Unit;
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
assert_eq!("export type Unit = null;", Unit::decl())
|
||||
assert_eq!("type Unit = null;", Unit::decl())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user