From 9c50907ab1ca4b7fb219206b05c7409af11b8799 Mon Sep 17 00:00:00 2001 From: Laurent Vauthrin Date: Tue, 21 Mar 2023 12:55:43 -0400 Subject: [PATCH] Added tests for opening a range --- tests/openingh_spec.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/openingh_spec.lua b/tests/openingh_spec.lua index e6d09f8..5bee778 100644 --- a/tests/openingh_spec.lua +++ b/tests/openingh_spec.lua @@ -34,9 +34,20 @@ describe("openingh should open", function() it("file on :OpenInGHFile", function() vim.cmd("e ./README.md") + vim.api.nvim_win_set_cursor(0, { 3, 0 }) vim.cmd("OpenInGHFile") - local status = vim.g.OPENINGH_RESULT - assert.truthy(status) + local expected = "/blob/main/README.md#L3" + assert.equal(expected, status:sub(-#expected)) + end) + + it("file range on :'<,'>OpenInGHFile", function() + vim.cmd("e ./README.md") + vim.api.nvim_buf_set_mark(0, "<", 5, 0, {}) + vim.api.nvim_buf_set_mark(0, ">", 10, 0, {}) + vim.cmd("'<,'>OpenInGHFile") + local status = vim.g.OPENINGH_RESULT + local expected = "/blob/main/README.md#L5-L10" + assert.equal(expected, status:sub(-#expected)) end) end)