Skip to content

Commit

Permalink
update to account for #51
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyMichaelTDM committed May 12, 2024
1 parent 07031fe commit d542365
Showing 1 changed file with 35 additions and 14 deletions.
49 changes: 35 additions & 14 deletions tests/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,34 @@ fn test_const() {
register_goldenfile(&mut mint, &base_path, "typescript.ts");

// Generate the typescript definitions
tsync::generate_typescript_defs(vec![input.clone()], output1, false);
tsync::generate_typescript_defs(vec![input], output2, false);
tsync::generate_typescript_defs(vec![input.clone()], output1, false, false);
tsync::generate_typescript_defs(vec![input], output2, false, false);

// Compare the generated files to the checked-in golden files
teardown_mint(mint);
}

#[test]
fn test_const_enum_numeric() {
let base_path = PathBuf::from("test/const_enum_numeric");
let input = base_path.join("rust.rs");
let output1 = base_path.join("typescript.d.ts");
let output2 = base_path.join("typescript.ts");

// Create a new goldenfile mint
let mut mint = Mint::new(&base_path);
// Register the goldenfiles
register_goldenfile(&mut mint, &base_path, "typescript.d.ts");
register_goldenfile(&mut mint, &base_path, "typescript.ts");

// Generate the typescript definitions
tsync::generate_typescript_defs(vec![input.clone()], output1, false, true);
tsync::generate_typescript_defs(vec![input], output2, false, true);

// Compare the generated files to the checked-in golden files and reset the goldenfiles
teardown_mint(mint);
}

#[test]
fn test_directory_input() {
let base_path = PathBuf::from("test/directory_input");
Expand All @@ -71,7 +92,7 @@ fn test_directory_input() {
register_goldenfile(&mut mint, &base_path, "typescript.d.ts");

// Generate the typescript definitions
tsync::generate_typescript_defs(vec![input], output, false);
tsync::generate_typescript_defs(vec![input], output, false, false);

// Compare the generated files to the checked-in golden files and reset the goldenfiles
teardown_mint(mint);
Expand All @@ -91,8 +112,8 @@ fn test_doc_comments() {
register_goldenfile(&mut mint, &base_path, "typescript.ts");

// Generate the typescript definitions
tsync::generate_typescript_defs(vec![input.clone()], output1, false);
tsync::generate_typescript_defs(vec![input], output2, false);
tsync::generate_typescript_defs(vec![input.clone()], output1, false, false);
tsync::generate_typescript_defs(vec![input], output2, false, false);

// Compare the generated files to the checked-in golden files and reset the goldenfiles
teardown_mint(mint);
Expand All @@ -112,8 +133,8 @@ fn test_enum() {
register_goldenfile(&mut mint, &base_path, "typescript.ts");

// Generate the typescript definitions
tsync::generate_typescript_defs(vec![input.clone()], output1, false);
tsync::generate_typescript_defs(vec![input], output2, false);
tsync::generate_typescript_defs(vec![input.clone()], output1, false, false);
tsync::generate_typescript_defs(vec![input], output2, false, false);

// Compare the generated files to the checked-in golden files and reset the goldenfiles
teardown_mint(mint);
Expand All @@ -133,8 +154,8 @@ fn test_enum_numeric() {
register_goldenfile(&mut mint, &base_path, "typescript.ts");

// Generate the typescript definitions
tsync::generate_typescript_defs(vec![input.clone()], output1, false);
tsync::generate_typescript_defs(vec![input], output2, false);
tsync::generate_typescript_defs(vec![input.clone()], output1, false, false);
tsync::generate_typescript_defs(vec![input], output2, false, false);

// Compare the generated files to the checked-in golden files and reset the goldenfiles
teardown_mint(mint);
Expand All @@ -154,8 +175,8 @@ fn test_generic() {
register_goldenfile(&mut mint, &base_path, "typescript.ts");

// Generate the typescript definitions
tsync::generate_typescript_defs(vec![input.clone()], output1, false);
tsync::generate_typescript_defs(vec![input], output2, false);
tsync::generate_typescript_defs(vec![input.clone()], output1, false, false);
tsync::generate_typescript_defs(vec![input], output2, false, false);

// Compare the generated files to the checked-in golden files and reset the goldenfiles
teardown_mint(mint);
Expand All @@ -175,8 +196,8 @@ fn test_struct() {
register_goldenfile(&mut mint, &base_path, "typescript.ts");

// Generate the typescript definitions
tsync::generate_typescript_defs(vec![input.clone()], output1, false);
tsync::generate_typescript_defs(vec![input], output2, false);
tsync::generate_typescript_defs(vec![input.clone()], output1, false, false);
tsync::generate_typescript_defs(vec![input], output2, false, false);

// Compare the generated files to the checked-in golden files and reset the goldenfiles
teardown_mint(mint);
Expand All @@ -194,7 +215,7 @@ fn test_type() {
register_goldenfile(&mut mint, &base_path, "typescript.d.ts");

// Generate the typescript definitions
tsync::generate_typescript_defs(vec![input], output, false);
tsync::generate_typescript_defs(vec![input], output, false, false);

// Compare the generated files to the checked-in golden files and reset the goldenfiles
teardown_mint(mint);
Expand Down

0 comments on commit d542365

Please sign in to comment.