Skip to content

Commit

Permalink
test(integration): support reading config
Browse files Browse the repository at this point in the history
  • Loading branch information
g-plane committed Aug 29, 2024
1 parent f753b70 commit 49712dd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dprint_plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ dprint-plugin-typescript = { version = "0.91", features = ["wasm"] }
insta = { version = "1.38", features = ["glob"] }
malva = { version = "0.10", features = ["config_serde"] }
similar-asserts = "1.5"
toml = "0.8"
14 changes: 11 additions & 3 deletions dprint_plugin/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
use anyhow::Error;
use insta::{assert_snapshot, glob, Settings};
use markup_fmt::{detect_language, format_text, FormatError};
use std::{borrow::Cow, fs, path::Path};
use std::{borrow::Cow, fs, io, path::Path};

#[test]
fn integration_with_dprint_ts_snapshot() {
fn format_with_dprint_ts(input: &str, path: &Path) -> Result<String, FormatError<Error>> {
let options = Default::default();
let options = match fs::read_to_string(path.with_extension("toml")) {
Ok(file) => toml::from_str(&file).unwrap(),
Err(e) if e.kind() == io::ErrorKind::NotFound => Default::default(),
Err(e) => panic!("{e}"),
};
format_text(
input,
detect_language(path).unwrap(),
Expand Down Expand Up @@ -104,7 +108,11 @@ fn integration_with_dprint_ts_snapshot() {
#[test]
fn integration_with_biome_snapshot() {
fn format_with_biome(input: &str, path: &Path) -> Result<String, FormatError<Error>> {
let options = Default::default();
let options = match fs::read_to_string(path.with_extension("toml")) {
Ok(file) => toml::from_str(&file).unwrap(),
Err(e) if e.kind() == io::ErrorKind::NotFound => Default::default(),
Err(e) => panic!("{e}"),
};
format_text(
&input,
detect_language(path).unwrap(),
Expand Down

0 comments on commit 49712dd

Please sign in to comment.