Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
chore: add additional test
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Sep 8, 2022
1 parent ce66ebd commit 26cb57b
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
48 changes: 48 additions & 0 deletions crates/rome_cli/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,54 @@ mod format {
assert_cli_snapshot(module_path!(), "applies_custom_configuration", fs, console);
}

#[test]
fn applies_custom_configuration_over_config_file() {
let mut fs = MemoryFileSystem::default();
let mut console = BufferConsole::default();

let file_path = Path::new("rome.json");
fs.insert(file_path.into(), CONFIG_FORMAT.as_bytes());

let file_path = Path::new("file.js");
fs.insert(file_path.into(), CUSTOM_CONFIGURATION_BEFORE.as_bytes());

let result = run_cli(
DynRef::Borrowed(&mut fs),
DynRef::Borrowed(&mut console),
Arguments::from_vec(vec![
OsString::from("format"),
OsString::from("--line-width"),
OsString::from("10"),
OsString::from("--indent-style"),
OsString::from("space"),
OsString::from("--indent-size"),
OsString::from("8"),
OsString::from("--write"),
file_path.as_os_str().into(),
]),
);

assert!(result.is_ok(), "run_cli returned {result:?}");

let mut file = fs
.open(file_path)
.expect("formatting target file was removed by the CLI");

let mut content = String::new();
file.read_to_string(&mut content)
.expect("failed to read file from memory FS");

assert_eq!(content, CUSTOM_CONFIGURATION_AFTER);

drop(file);
assert_cli_snapshot(
module_path!(),
"applies_custom_configuration_over_config_file",
fs,
console,
);
}

#[test]
fn applies_custom_quote_style() {
let mut fs = MemoryFileSystem::default();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
source: crates/rome_cli/tests/snap_test.rs
expression: content
---
## `rome.json`

```json
{
"formatter": {
"enabled": true,
"lineWidth": 160,
"indentStyle": "space",
"indentSize": 6
}
}

```

## `file.js`

```js
function f() {
return {
a,
b,
};
}

```

# Emitted Messages


0 comments on commit 26cb57b

Please sign in to comment.