* wip: tabs, just outlining stuff, for now it is a mess * wip: tabs, just outlining stuff, for now it is a mess * wip: formatting * wip: some moving around * wip: not sure why those things are not imported * wip: cleaning up a bit * wip: doesn't render when new tab is created? * wip: doesnt re-render when a new tab is spawned for now * wip: tabs now are a BTreeMap and we can switch between them in both directions * wip: I think that should also be here * wip: cleanup * Spawn a new terminal simultaneously with a new tab * Ensure proper Opening and Closing of tabs * cleanup * more cleanup * tests(snapshots): add 'loading' snapshot to each scenario * fix(tests): update snapshots * Add tests for tabs implementation * wip: added tests, moved tab related stuff to a separate file * wip: var name change, removed unused imports * chore: fromatting * wip: tests are you ok? * Remove next_tab_index field * clean close_tab() logic in screen.render() * wip: more tests added, review changes covered * chore: a programmer and a formatter walk into a bar.... * style(screen): update description comment * docs(tab): add comment description Co-authored-by: denis <denis@airheadventures.com> Co-authored-by: Kunal Mohan <kunalmohan99@gmail.com> Co-authored-by: Aram Drevekenin <aram@poor.dev> Co-authored-by: Kunal Mohan <44079328+kunalmohan@users.noreply.github.com>
76 lines
2 KiB
Rust
76 lines
2 KiB
Rust
use ::insta::assert_snapshot;
|
|
|
|
use crate::terminal_pane::PositionAndSize;
|
|
use crate::tests::fakes::FakeInputOutput;
|
|
use crate::tests::utils::get_output_frame_snapshots;
|
|
use crate::{start, Opt};
|
|
|
|
use crate::tests::utils::commands::{
|
|
COMMAND_TOGGLE, MOVE_FOCUS_DOWN, MOVE_FOCUS_UP, QUIT, SPLIT_HORIZONTALLY, SPLIT_VERTICALLY,
|
|
};
|
|
|
|
fn get_fake_os_input(fake_win_size: &PositionAndSize) -> FakeInputOutput {
|
|
FakeInputOutput::new(*fake_win_size)
|
|
}
|
|
|
|
#[test]
|
|
pub fn move_focus_down() {
|
|
let fake_win_size = PositionAndSize {
|
|
columns: 121,
|
|
rows: 20,
|
|
x: 0,
|
|
y: 0,
|
|
};
|
|
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
|
fake_input_output.add_terminal_input(&[
|
|
&COMMAND_TOGGLE,
|
|
&COMMAND_TOGGLE,
|
|
&SPLIT_HORIZONTALLY,
|
|
&MOVE_FOCUS_UP,
|
|
&MOVE_FOCUS_DOWN,
|
|
&QUIT,
|
|
]);
|
|
start(Box::new(fake_input_output.clone()), Opt::default());
|
|
|
|
let output_frames = fake_input_output
|
|
.stdout_writer
|
|
.output_frames
|
|
.lock()
|
|
.unwrap();
|
|
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
|
|
for snapshot in snapshots {
|
|
assert_snapshot!(snapshot);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
pub fn move_focus_down_to_the_largest_overlap() {
|
|
let fake_win_size = PositionAndSize {
|
|
columns: 121,
|
|
rows: 20,
|
|
x: 0,
|
|
y: 0,
|
|
};
|
|
let mut fake_input_output = get_fake_os_input(&fake_win_size);
|
|
fake_input_output.add_terminal_input(&[
|
|
&COMMAND_TOGGLE,
|
|
&COMMAND_TOGGLE,
|
|
&SPLIT_HORIZONTALLY,
|
|
&SPLIT_VERTICALLY,
|
|
&SPLIT_VERTICALLY,
|
|
&MOVE_FOCUS_UP,
|
|
&MOVE_FOCUS_DOWN,
|
|
&QUIT,
|
|
]);
|
|
start(Box::new(fake_input_output.clone()), Opt::default());
|
|
|
|
let output_frames = fake_input_output
|
|
.stdout_writer
|
|
.output_frames
|
|
.lock()
|
|
.unwrap();
|
|
let snapshots = get_output_frame_snapshots(&output_frames, &fake_win_size);
|
|
for snapshot in snapshots {
|
|
assert_snapshot!(snapshot);
|
|
}
|
|
}
|