|
|
|
@ -994,17 +994,22 @@ mod test_explorer {
|
|
|
|
|
// 0. Open the add file/folder prompt
|
|
|
|
|
explorer.handle_events("a").unwrap();
|
|
|
|
|
let prompt = &explorer.prompt.as_ref().unwrap().1;
|
|
|
|
|
fn sanitize(s: &str) -> String {
|
|
|
|
|
fn to_forward_slash(s: &str) -> String {
|
|
|
|
|
s.replace(std::path::MAIN_SEPARATOR, "/")
|
|
|
|
|
}
|
|
|
|
|
fn to_os_main_separator(s: &str) -> String {
|
|
|
|
|
s.replace('/', format!("{}", std::path::MAIN_SEPARATOR).as_str())
|
|
|
|
|
}
|
|
|
|
|
assert_eq!(
|
|
|
|
|
sanitize(&prompt.prompt()),
|
|
|
|
|
to_forward_slash(&prompt.prompt()),
|
|
|
|
|
" New file or folder (ends with '/'): "
|
|
|
|
|
);
|
|
|
|
|
assert_eq!(sanitize(prompt.line()), "test_explorer/new_folder/");
|
|
|
|
|
assert_eq!(to_forward_slash(prompt.line()), "test_explorer/new_folder/");
|
|
|
|
|
|
|
|
|
|
// 1. Add a new folder at the root
|
|
|
|
|
explorer.handle_events(&sanitize("yoyo/<ret>")).unwrap();
|
|
|
|
|
explorer
|
|
|
|
|
.handle_events(&to_os_main_separator("yoyo/<ret>"))
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
// 1a. Expect the new folder is added, and is focused
|
|
|
|
|
assert_eq!(
|
|
|
|
@ -1027,7 +1032,7 @@ mod test_explorer {
|
|
|
|
|
|
|
|
|
|
// 3. Add a new folder
|
|
|
|
|
explorer
|
|
|
|
|
.handle_events(&sanitize("asus.sass/<ret>"))
|
|
|
|
|
.handle_events(&to_os_main_separator("asus.sass/<ret>"))
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
// 3a. Expect the new folder is added under "styles", although "styles" is not opened
|
|
|
|
@ -1050,7 +1055,9 @@ mod test_explorer {
|
|
|
|
|
assert!(fs::read_dir(path.join("styles/sus.sass")).is_ok());
|
|
|
|
|
|
|
|
|
|
// 4. Add a new folder with non-existent parents
|
|
|
|
|
explorer.handle_events(&sanitize("aa/b/c/<ret>")).unwrap();
|
|
|
|
|
explorer
|
|
|
|
|
.handle_events(&to_os_main_separator("aa/b/c/<ret>"))
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
// 4a. Expect the non-existent parents are created,
|
|
|
|
|
// and the new folder is created,
|
|
|
|
@ -1078,7 +1085,9 @@ mod test_explorer {
|
|
|
|
|
explorer.handle_events("j").unwrap();
|
|
|
|
|
|
|
|
|
|
// 6. Add a new folder here
|
|
|
|
|
explorer.handle_events(&sanitize("afoobar/<ret>")).unwrap();
|
|
|
|
|
explorer
|
|
|
|
|
.handle_events(&to_os_main_separator("afoobar/<ret>"))
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
|
|
// 6a. Expect the folder is added under "styles",
|
|
|
|
|
// because the folder of the current item, "style.css" is "styles/"
|
|
|
|
|