Add pinned tab controls
This commit is contained in:
@@ -18,6 +18,21 @@ fn favorite_command_toggles_active_tab() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pin_command_toggles_active_tab() -> Result<(), Box<dyn Error>> {
|
||||
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||
|
||||
core.set_command_query(">pin");
|
||||
let intent = core.submit_command()?;
|
||||
let snapshot = core.snapshot()?;
|
||||
|
||||
assert_eq!(intent, Some(CommandIntent::Command("pin".to_string())));
|
||||
assert_eq!(snapshot.pinned_tabs.len(), 1);
|
||||
assert_eq!(snapshot.pinned_tabs[0].id(), &snapshot.active_tab_id);
|
||||
assert_eq!(snapshot.command_query, "");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_tab_command_opens_new_tab() -> Result<(), Box<dyn Error>> {
|
||||
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||
|
||||
@@ -155,6 +155,38 @@ fn toggles_active_tab_favorite() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn toggles_active_tab_pinned() -> Result<(), Box<dyn Error>> {
|
||||
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||
|
||||
let pinned = core.toggle_active_tab_pinned()?;
|
||||
let snapshot = core.snapshot()?;
|
||||
|
||||
assert!(pinned);
|
||||
assert_eq!(snapshot.pinned_tabs.len(), 1);
|
||||
assert_eq!(snapshot.pinned_tabs[0].id(), &snapshot.active_tab_id);
|
||||
|
||||
let pinned = core.toggle_active_tab_pinned()?;
|
||||
let snapshot = core.snapshot()?;
|
||||
|
||||
assert!(!pinned);
|
||||
assert!(snapshot.pinned_tabs.is_empty());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn favorite_tabs_are_omitted_from_pinned_section() -> Result<(), Box<dyn Error>> {
|
||||
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||
|
||||
core.toggle_active_tab_pinned()?;
|
||||
core.toggle_active_tab_favorite()?;
|
||||
|
||||
let snapshot = core.snapshot()?;
|
||||
assert_eq!(snapshot.favorites.len(), 1);
|
||||
assert!(snapshot.pinned_tabs.is_empty());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn enforces_default_favorite_limit() -> Result<(), Box<dyn Error>> {
|
||||
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||
|
||||
Reference in New Issue
Block a user