feat: browse channel playlists
This commit is contained in:
+46
-1
@@ -120,6 +120,47 @@ fn provider_choice_is_configurable_and_normal_only() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn channel_playlists_are_configurable_and_normal_only() {
|
||||
let defaults = Bindings::default();
|
||||
let overrides = configured("[keys.channel]\nplaylists = 'alt+l'\n").unwrap();
|
||||
for &context in ALL {
|
||||
let expected = (context == Context::Normal).then_some(Action::ChannelPlaylists);
|
||||
for (code, modifiers) in [
|
||||
(KeyCode::Char('L'), KeyModifiers::NONE),
|
||||
(KeyCode::Char('L'), KeyModifiers::SHIFT),
|
||||
(KeyCode::Char('l'), KeyModifiers::SHIFT),
|
||||
] {
|
||||
assert_eq!(press(&defaults, context, code, modifiers), expected);
|
||||
assert_ne!(
|
||||
press(&overrides, context, code, modifiers),
|
||||
Some(Action::ChannelPlaylists),
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
press(&defaults, context, KeyCode::Char('l'), KeyModifiers::NONE),
|
||||
None,
|
||||
);
|
||||
assert_eq!(
|
||||
press(&overrides, context, KeyCode::Char('l'), KeyModifiers::ALT),
|
||||
expected,
|
||||
);
|
||||
}
|
||||
assert!(default_config().contains("channel.playlists = [\"L\"]"));
|
||||
assert!(defaults.help_text().to_string().lines().any(|line| {
|
||||
line.trim_start().starts_with("L ")
|
||||
&& line.contains("Browse the current channel's playlists")
|
||||
}));
|
||||
assert!(overrides.help_text().to_string().lines().any(|line| {
|
||||
line.trim_start().starts_with("Alt+l ")
|
||||
&& line.contains("Browse the current channel's playlists")
|
||||
}));
|
||||
let collision = configured("[keys.channel]\nplaylists = 'u'\n")
|
||||
.unwrap_err()
|
||||
.to_string();
|
||||
assert!(collision.contains("channel.playlists") && collision.contains("channel.browse"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn only_section_headers_are_bold_in_the_grouped_overview() {
|
||||
use ratatui::{
|
||||
@@ -426,6 +467,9 @@ fn collection_removal_defaults_are_scoped_and_inherit_view_actions() {
|
||||
(Context::Description, Context::CollectionDescription),
|
||||
] {
|
||||
for &(key, action) in &bindings.contexts[ordinary as usize] {
|
||||
if action == Action::ChannelPlaylists {
|
||||
continue;
|
||||
}
|
||||
assert_eq!(
|
||||
bindings.resolve(collection, KeyEvent::new(key.code, key.modifiers)),
|
||||
Some(action),
|
||||
@@ -434,7 +478,8 @@ fn collection_removal_defaults_are_scoped_and_inherit_view_actions() {
|
||||
}
|
||||
assert_eq!(
|
||||
bindings.contexts[collection as usize].len(),
|
||||
bindings.contexts[ordinary as usize].len() + 2,
|
||||
bindings.contexts[ordinary as usize].len() + 2
|
||||
- usize::from(ordinary == Context::Normal),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user