From 2486fbda61d1a97fd7237bae84a7ff629a5d45d4 Mon Sep 17 00:00:00 2001 From: Ze-Zheng Wu Date: Sun, 31 Mar 2024 19:44:49 +0800 Subject: [PATCH] chore: update spec_tests code This is to keep them consistent with the existing code. --- crates/biome_css_analyze/tests/spec_tests.rs | 7 ++++--- crates/biome_js_analyze/tests/spec_tests.rs | 7 ++++--- crates/biome_js_transform/tests/spec_tests.rs | 7 ++++--- crates/biome_json_analyze/tests/spec_tests.rs | 7 ++++--- crates/biome_migrate/tests/spec_tests.rs | 7 ++++--- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/crates/biome_css_analyze/tests/spec_tests.rs b/crates/biome_css_analyze/tests/spec_tests.rs index 2ecfd65b38b7..420a62a54562 100644 --- a/crates/biome_css_analyze/tests/spec_tests.rs +++ b/crates/biome_css_analyze/tests/spec_tests.rs @@ -186,12 +186,13 @@ fn check_code_action( action: &AnalyzerAction, options: CssParserOptions, ) { - let (new_tree, Some((_, text_edit))) = action + let (new_tree, text_edit) = match action .mutation .clone() .commit_with_text_range_and_edit(true) - else { - todo!(); + { + (new_tree, Some((_, text_edit))) => (new_tree, text_edit), + (new_tree, None) => (new_tree, Default::default()), }; let output = text_edit.new_string(source); diff --git a/crates/biome_js_analyze/tests/spec_tests.rs b/crates/biome_js_analyze/tests/spec_tests.rs index bcfc0c97eefd..61f0e7be6ba8 100644 --- a/crates/biome_js_analyze/tests/spec_tests.rs +++ b/crates/biome_js_analyze/tests/spec_tests.rs @@ -188,12 +188,13 @@ fn check_code_action( action: &AnalyzerAction, options: JsParserOptions, ) { - let (new_tree, Some((_, text_edit))) = action + let (new_tree, text_edit) = match action .mutation .clone() .commit_with_text_range_and_edit(true) - else { - panic!("text edit doesn't exist"); + { + (new_tree, Some((_, text_edit))) => (new_tree, text_edit), + (new_tree, None) => (new_tree, Default::default()), }; let output = text_edit.new_string(source); diff --git a/crates/biome_js_transform/tests/spec_tests.rs b/crates/biome_js_transform/tests/spec_tests.rs index 8734617c3200..95c0d0d5f75e 100644 --- a/crates/biome_js_transform/tests/spec_tests.rs +++ b/crates/biome_js_transform/tests/spec_tests.rs @@ -142,12 +142,13 @@ fn check_transformation( transformation: &AnalyzerTransformation, options: JsParserOptions, ) { - let (new_tree, Some((_, text_edit))) = transformation + let (new_tree, text_edit) = match transformation .mutation .clone() .commit_with_text_range_and_edit(true) - else { - panic!("text edit doesn't exist"); + { + (new_tree, Some((_, text_edit))) => (new_tree, text_edit), + (new_tree, None) => (new_tree, Default::default()), }; let output = text_edit.new_string(source); diff --git a/crates/biome_json_analyze/tests/spec_tests.rs b/crates/biome_json_analyze/tests/spec_tests.rs index 61867a4fec5d..776ce4b08bf6 100644 --- a/crates/biome_json_analyze/tests/spec_tests.rs +++ b/crates/biome_json_analyze/tests/spec_tests.rs @@ -113,12 +113,13 @@ pub(crate) fn analyze_and_snap( } fn check_code_action(path: &Path, source: &str, action: &AnalyzerAction) { - let (new_tree, Some((_, text_edit))) = action + let (new_tree, text_edit) = match action .mutation .clone() .commit_with_text_range_and_edit(true) - else { - panic!("text edit doesn't exist"); + { + (new_tree, Some((_, text_edit))) => (new_tree, text_edit), + (new_tree, None) => (new_tree, Default::default()), }; let output = text_edit.new_string(source); diff --git a/crates/biome_migrate/tests/spec_tests.rs b/crates/biome_migrate/tests/spec_tests.rs index e55a2b60a167..4bc3582b18e2 100644 --- a/crates/biome_migrate/tests/spec_tests.rs +++ b/crates/biome_migrate/tests/spec_tests.rs @@ -100,12 +100,13 @@ pub(crate) fn analyze_and_snap( } fn check_code_action(path: &Path, source: &str, action: &AnalyzerAction) { - let (new_tree, Some((_, text_edit))) = action + let (new_tree, text_edit) = match action .mutation .clone() .commit_with_text_range_and_edit(true) - else { - panic!("text edit doesn't exist"); + { + (new_tree, Some((_, text_edit))) => (new_tree, text_edit), + (new_tree, None) => (new_tree, Default::default()), }; let output = text_edit.new_string(source);