aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorAram Drevekenin <aram@poor.dev>2020-12-14 16:25:46 +0100
committerGitHub <noreply@github.com>2020-12-14 16:25:46 +0100
commitac9c0274f44a12bd329da4f528323f22d5b6f2df (patch)
treed20e490c23a2c23fd578e0489c291dcde52514ef /src/tests
parentfix(style): make match arms consistent (#96) (diff)
downloadsl0ppij-ac9c0274f44a12bd329da4f528323f22d5b6f2df.tar.gz
sl0ppij-ac9c0274f44a12bd329da4f528323f22d5b6f2df.tar.xz
sl0ppij-ac9c0274f44a12bd329da4f528323f22d5b6f2df.zip
fix(compatibility): fix vim overwrite message and buffer clearing on exit (#98)
* fix(compatibility): fix vim overwrite message and buffer clearing on exit * style(formatting): make rustfmt happy
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/fixtures/clear_scroll_regionbin0 -> 5240 bytes
-rw-r--r--src/tests/fixtures/vim_overwritebin0 -> 4154 bytes
-rw-r--r--src/tests/integration/compatibility.rs57
-rw-r--r--src/tests/integration/snapshots/mosaic__tests__integration__compatibility__clear_scroll_region-2.snap32
-rw-r--r--src/tests/integration/snapshots/mosaic__tests__integration__compatibility__clear_scroll_region.snap32
-rw-r--r--src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_overwrite-2.snap32
-rw-r--r--src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_overwrite.snap32
7 files changed, 185 insertions, 0 deletions
diff --git a/src/tests/fixtures/clear_scroll_region b/src/tests/fixtures/clear_scroll_region
new file mode 100644
index 00000000..d4741364
--- /dev/null
+++ b/src/tests/fixtures/clear_scroll_region
Binary files differ
diff --git a/src/tests/fixtures/vim_overwrite b/src/tests/fixtures/vim_overwrite
new file mode 100644
index 00000000..3a804d64
--- /dev/null
+++ b/src/tests/fixtures/vim_overwrite
Binary files differ
diff --git a/src/tests/integration/compatibility.rs b/src/tests/integration/compatibility.rs
index 114c10d2..1df46583 100644
--- a/src/tests/integration/compatibility.rs
+++ b/src/tests/integration/compatibility.rs
@@ -260,3 +260,60 @@ pub fn htop_right_scrolling() {
assert_snapshot!(snapshot);
}
}
+
+#[test]
+pub fn vim_overwrite() {
+ // this tests the vim overwrite message
+ // to recreate:
+ // * open a file in vim
+ // * open the same file in another window
+ // * change the file in the other window and save
+ // * change the file in the original vim window and save
+ // * confirm you would like to change the file by pressing 'y' and then ENTER
+ // * if everything looks fine, this test passed :)
+ let fake_win_size = PositionAndSize {
+ columns: 116,
+ rows: 28,
+ x: 0,
+ y: 0,
+ };
+ let fixture_name = "vim_overwrite";
+ let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
+ fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &COMMAND_TOGGLE, &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 clear_scroll_region() {
+ // this tests the scroll region used by eg. vim is cleared properly
+ // this means that when vim exits, we get back the previous scroll
+ // buffer
+ let fake_win_size = PositionAndSize {
+ columns: 116,
+ rows: 28,
+ x: 0,
+ y: 0,
+ };
+ let fixture_name = "clear_scroll_region";
+ let mut fake_input_output = get_fake_os_input(&fake_win_size, fixture_name);
+ fake_input_output.add_terminal_input(&[&COMMAND_TOGGLE, &COMMAND_TOGGLE, &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);
+ }
+}
diff --git a/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__clear_scroll_region-2.snap b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__clear_scroll_region-2.snap
new file mode 100644
index 00000000..8c309266
--- /dev/null
+++ b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__clear_scroll_region-2.snap
@@ -0,0 +1,32 @@
+---
+source: src/tests/integration/compatibility.rs
+expression: snapshot
+---
+⋊> ~/c/mosaic on main ⨯ vim some-file 15:07:22
+⋊> ~/c/mosaic on main ⨯ 15:07:29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Bye from Mosaic!█
diff --git a/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__clear_scroll_region.snap b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__clear_scroll_region.snap
new file mode 100644
index 00000000..3a7b2d5e
--- /dev/null
+++ b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__clear_scroll_region.snap
@@ -0,0 +1,32 @@
+---
+source: src/tests/integration/compatibility.rs
+expression: snapshot
+---
+Welcome to fish, the friendly interactive shell
+⋊> ~/c/mosaic on main ⨯ vim some-file 15:07:22
+⋊> ~/c/mosaic on main ⨯ █ 15:07:29
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_overwrite-2.snap b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_overwrite-2.snap
new file mode 100644
index 00000000..7edfc74d
--- /dev/null
+++ b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_overwrite-2.snap
@@ -0,0 +1,32 @@
+---
+source: src/tests/integration/compatibility.rs
+expression: snapshot
+---
+ 1 line 1
+ 2 line 2
+ 3 line 3
+ 4 line 4
+ 5 line 5
+ 6 line 6
+ 7 line 7
+ 8 line 8
+ 9 line 9
+ 10 line 10
+ 11 line 11
+ 12 line 12
+ 13 line 13
+ 14 line 14
+ 15 line 15
+ 16 line 16
+ 17 line 17
+ 18 line 18
+ 19 line 19
+ 20 line 20
+ 21 line 21
+ 22 line 22
+ 23 line 23
+ 24 line 24
+ 25 line 25
+ NORMAL some-file unix | utf-8 | no ft 1% 1:1
+
+Bye from Mosaic!█
diff --git a/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_overwrite.snap b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_overwrite.snap
new file mode 100644
index 00000000..406b5b31
--- /dev/null
+++ b/src/tests/integration/snapshots/mosaic__tests__integration__compatibility__vim_overwrite.snap
@@ -0,0 +1,32 @@
+---
+source: src/tests/integration/compatibility.rs
+expression: snapshot
+---
+1 █
+ 1 line 1
+ 2 line 2
+ 3 line 3
+ 4 line 4
+ 5 line 5
+ 6 line 6
+ 7 line 7
+ 8 line 8
+ 9 line 9
+ 10 line 10
+ 11 line 11
+ 12 line 12
+ 13 line 13
+ 14 line 14
+ 15 line 15
+ 16 line 16
+ 17 line 17
+ 18 line 18
+ 19 line 19
+ 20 line 20
+ 21 line 21
+ 22 line 22
+ 23 line 23
+ 24 line 24
+ 25 line 25
+ NORMAL some-file unix | utf-8 | no ft 1% 1:1
+