about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-06-29 17:52:40 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-06-29 17:52:40 -0700
commitbfbe73e0efd2f80d5a2402ced3a93d6748319fbd (patch)
treed46e9cc92f9b2e9edd981b157ac8e1bc5a24b8c7
parent9410cccb083151d322fdad5ba6273e05c3165c32 (diff)
downloadview.love-bfbe73e0efd2f80d5a2402ced3a93d6748319fbd.tar.gz
new test: dragging and dropping a file on lines.love
-rw-r--r--main_tests.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/main_tests.lua b/main_tests.lua
index 2096464..495630f 100644
--- a/main_tests.lua
+++ b/main_tests.lua
@@ -10,6 +10,33 @@ function test_resize_window()
   -- TODO: how to make assertions about when App.update got past the early exit?
 end
 
+function test_drop_file()
+  io.write('\ntest_drop_file')
+  App.screen.init{width=Margin_left+300, height=300}
+  App.filesystem['foo'] = 'abc\ndef\nghi\n'
+  local fake_dropped_file = {
+    opened = false,
+    getFilename = function(self)
+                    return 'foo'
+                  end,
+    open = function(self)
+             self.opened = true
+           end,
+    lines = function(self)
+              assert(self.opened)
+              return App.filesystem['foo']:gmatch('[^\n]+')
+            end,
+    close = function(self)
+              self.opened = false
+            end,
+  }
+  App.filedropped(fake_dropped_file)
+  check_eq(#Lines, 3, 'F - test_drop_file/#lines')
+  check_eq(Lines[1].data, 'abc', 'F - test_drop_file/lines:1')
+  check_eq(Lines[2].data, 'def', 'F - test_drop_file/lines:2')
+  check_eq(Lines[3].data, 'ghi', 'F - test_drop_file/lines:3')
+end
+
 function test_adjust_line_width()
   io.write('\ntest_adjust_line_width')
   Filename = 'foo'