Skip to content

Commit

Permalink
test: qutebrowser spec
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvmanila committed Sep 3, 2022
1 parent e86bf33 commit e063078
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
3 changes: 3 additions & 0 deletions spec/fixtures/.qutebrowser/bookmarks/urls
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
https://news.ycombinator.com
https://qutebrowser.org qutebrowser
https://github.com/dhruvmanila/telescope-bookmarks.nvim dhruvmanila/telescope-bookmarks.nvim: A Neovim Telescope extension to open your browser bookmarks right from the editor!
64 changes: 64 additions & 0 deletions spec/unit/qutebrowser_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
local qutebrowser = require "telescope._extensions.bookmarks.qutebrowser"
local utils = require "telescope._extensions.bookmarks.utils"

describe("qutebrowser", function()
describe("collect_bookmarks", function()
local match = require "luassert.match"

before_each(function()
stub(utils, "warn")
end)

after_each(function()
utils.warn:revert()
end)

it("should warn if OS not supported", function()
local bookmarks = qutebrowser.collect_bookmarks { os_name = "random" }

assert.is_nil(bookmarks)
assert.stub(utils.warn).was_called()
assert
.stub(utils.warn)
.was_called_with(match.matches "Unsupported OS for qutebrowser")
end)

it("should warn if file is absent", function()
local bookmarks = qutebrowser.collect_bookmarks {
os_name = "Darwin",
os_homedir = ".",
}

assert.is_nil(bookmarks)
assert.stub(utils.warn).was_called()
assert
.stub(utils.warn)
.was_called_with(match.matches "No qutebrowser bookmarks file found at")
end)

it("should parse bookmarks file", function()
local bookmarks = qutebrowser.collect_bookmarks {
os_name = "Darwin",
os_homedir = "spec/fixtures",
}

assert.are.same(bookmarks, {
{
name = "",
path = "",
url = "https://news.ycombinator.com",
},
{
name = "qutebrowser",
path = "qutebrowser",
url = "https://qutebrowser.org",
},
{
name = "dhruvmanila/telescope-bookmarks.nvim: A Neovim Telescope extension to open your browser bookmarks right from the editor!",
path = "dhruvmanila/telescope-bookmarks.nvim: A Neovim Telescope extension to open your browser bookmarks right from the editor!",
url = "https://github.com/dhruvmanila/telescope-bookmarks.nvim",
},
})
end)
end)
end)

0 comments on commit e063078

Please sign in to comment.