Skip to content

Commit

Permalink
test(actions): add test cases for 'actions' (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
linrongbin16 authored Mar 12, 2024
1 parent 1801ed9 commit 0ff97f4
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 11 deletions.
10 changes: 4 additions & 6 deletions lua/gitlinker/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ end
-- see: https://github.com/axieax/urlview.nvim/blob/b183133fd25caa6dd98b415e0f62e51e061cd522/lua/urlview/actions.lua#L38
--- @param url string
local function system(url)
local job
if vim.fn.has("mac") > 0 then
job = vim.fn.jobstart({ "open", url })
vim.fn.jobstart({ "open", url })
elseif vim.fn.has("win32") > 0 or vim.fn.has("win64") > 0 then
job = vim.fn.jobstart({ "cmd", "/C", "start", url })
vim.fn.jobstart({ "cmd", "/C", "start", url })
elseif vim.fn.executable("wslview") > 0 then
job = vim.fn.jobstart({ "wslview", url })
vim.fn.jobstart({ "wslview", url })
else
job = vim.fn.jobstart({ "xdg-open", url })
vim.fn.jobstart({ "xdg-open", url })
end
-- vim.fn.jobwait({ job })
end

local M = {
Expand Down
25 changes: 25 additions & 0 deletions spec/gitlinker/actions_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
local cwd = vim.fn.getcwd()

describe("gitlinker.actions", function()
local assert_eq = assert.is_equal
local assert_true = assert.is_true
local assert_false = assert.is_false

before_each(function()
vim.api.nvim_command("cd " .. cwd)
end)

local actions = require("gitlinker.actions")
require("gitlinker").setup()

describe("[actions]", function()
local URL =
"https://github.com/linrongbin16/gitlinker.nvim/blob/1801ed9513fd4a1f0bff3440dcca7b0ea656a508/spec/gitlinker_spec.lua?plain=1#L3"
it("clipboard", function()
actions.clipboard(URL)
end)
it("system", function()
actions.system(URL)
end)
end)
end)
2 changes: 1 addition & 1 deletion spec/gitlinker/configs_spec.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local cwd = vim.fn.getcwd()

describe("gitlinker", function()
describe("gitlinker.gitlinker", function()
local assert_eq = assert.is_equal
local assert_true = assert.is_true
local assert_false = assert.is_false
Expand Down
2 changes: 1 addition & 1 deletion spec/gitlinker/git_spec.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local cwd = vim.fn.getcwd()

describe("git", function()
describe("gitlinker.git", function()
local assert_eq = assert.is_equal
local assert_true = assert.is_true
local assert_false = assert.is_false
Expand Down
2 changes: 1 addition & 1 deletion spec/gitlinker/highlight_spec.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local cwd = vim.fn.getcwd()

describe("highlight", function()
describe("gitlinker.highlight", function()
local assert_eq = assert.is_equal
local assert_true = assert.is_true
local assert_false = assert.is_false
Expand Down
2 changes: 1 addition & 1 deletion spec/gitlinker/linker_spec.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local cwd = vim.fn.getcwd()

describe("linker", function()
describe("gitlinker.linker", function()
local assert_eq = assert.is_equal
local assert_true = assert.is_true
local assert_false = assert.is_false
Expand Down
2 changes: 1 addition & 1 deletion spec/gitlinker/range_spec.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local cwd = vim.fn.getcwd()

describe("range", function()
describe("gitlinker.range", function()
local assert_eq = assert.is_equal
local assert_true = assert.is_true
local assert_false = assert.is_false
Expand Down

0 comments on commit 0ff97f4

Please sign in to comment.