diff --git a/crates/cli_bin/tests/format.rs b/crates/cli_bin/tests/format.rs index 4bef9aa33..0a5109272 100644 --- a/crates/cli_bin/tests/format.rs +++ b/crates/cli_bin/tests/format.rs @@ -5,25 +5,6 @@ use insta::assert_yaml_snapshot; mod common; -#[test] -fn format_patterns() -> Result<()> { - let (_temp_dir, grit_dir) = get_fixture("unformatted_patterns", true)?; - - let mut cmd = get_test_cmd()?; - cmd.arg("format").current_dir(grit_dir.clone()); - let output = cmd.output()?; - - println!("stderr: {}", String::from_utf8(output.stderr.clone())?); - println!("stdout: {}", String::from_utf8(output.stdout.clone())?); - - assert!( - output.status.success(), - "Command didn't finish successfully" - ); - assert_yaml_snapshot!(String::from_utf8(output.stdout)?); - Ok(()) -} - #[test] fn format_patterns_with_rewrite() -> Result<()> { let (_temp_dir, grit_dir) = get_fixture("unformatted_patterns", true)?; diff --git a/crates/cli_bin/tests/snapshots/format__format_patterns.snap b/crates/cli_bin/tests/snapshots/format__format_patterns.snap deleted file mode 100644 index 24a4cbab1..000000000 --- a/crates/cli_bin/tests/snapshots/format__format_patterns.snap +++ /dev/null @@ -1,6 +0,0 @@ ---- -source: crates/cli_bin/tests/format.rs -expression: "String::from_utf8(output.stdout)?" -snapshot_kind: text ---- -".grit/./others/test_move_import.md:\n tags: [private]\n ---\n ```grit\n -language js\n -\n +language js;\n `sanitizeFilePath` as $s where {\n - move_import(`sanitizeFilePath`, `'@getgrit/universal'`)\n +\tmove_import(`sanitizeFilePath`, `'@getgrit/universal'`)\n }\n ```\n \n\n.grit/grit.yaml:\n version: 0.0.1\n patterns:\n - - name: aspect_ratio_yaml\n - description: Yaml version of aspect_ratio.md\n - body: |\n - language css\n -\n - `a { $props }` where {\n - $props <: contains `aspect-ratio: $x`\n - }\n +- name: aspect_ratio_yaml\n + description: Yaml version of aspect_ratio.md\n + body: |+\n + language css;\n + `a { $props }` where { $props <: contains `aspect-ratio: $x` }\n \n - - file: ./others/test_move_import.md\n +- file: ./others/test_move_import.md\n \n\n.grit/patterns/aspect_ratio.md:\n ---\n \n ```grit\n -language css\n -\n -`a { $props }` where {\n - $props <: contains `aspect-ratio: $x`\n -}\n +language css;\n +`a { $props }` where { $props <: contains `aspect-ratio: $x` }\n ```\n \n ## Matches the right selector and declaration block\n \n\n.grit/patterns/dependency.grit:\n -language json\n -\n +language json;\n pattern upgrade_dependency($target_dep, $target_version, $dependency_key) {\n - or {\n - `$key: $value` where {\n - $key <: `\"$target_dep\"`,\n - $value => `\"$target_version\"`\n - },\n - pair($key, $value) where {\n - $key <: `\"$dependency_key\"`,\n - $value <: object($properties) where {\n - $properties <: not contains pair(key=$dep_key) where {\n - $dep_key <: contains `$target_dep`\n - },\n - $properties => `\"$target_dep\": \"$target_version\",\\n$properties`\n - }\n - }\n - }\n -}\n +\tor {\n +\t\t`$key: $value` where {\n +\t\t\t$key <: `\"$target_dep\"`,\n +\t\t\t$value => `\"$target_version\"`\n +\t\t},\n +\t\tpair($key, $value) where {\n +\t\t\t$key <: `\"$dependency_key\"`,\n +\t\t\t$value <: object($properties) where {\n +\t\t\t\t$properties <: notcontains pair(key = $dep_key) where {\n +\t\t\t\t\t$dep_key <: contains `$target_dep`\n +\t\t\t\t},\n +\t\t\t\t$properties => `\"$target_dep\": \"$target_version\",\\n$properties`\n +\t\t\t}\n +\t\t}\n +\t}}\n \n pattern console_method_to_info($method) {\n - `console.$method($message)` => `console.info($message)`\n -}\n +\t`console.$method($message)` => `console.info($message)`}\n \n\n"