From 47a48708d7aab840d5dfb5ac50219289c0bd7b60 Mon Sep 17 00:00:00 2001 From: Pablo P Varela Date: Tue, 23 Jan 2024 18:00:37 +0100 Subject: [PATCH] add more tests --- lua/unclutter/tabline_spec.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lua/unclutter/tabline_spec.lua b/lua/unclutter/tabline_spec.lua index eda58ca..09028a9 100644 --- a/lua/unclutter/tabline_spec.lua +++ b/lua/unclutter/tabline_spec.lua @@ -1,22 +1,24 @@ local M = require "unclutter.tabline" describe("Tabpage section", function() - it("creates tabpage section for multiple tabpages", function() + before_each(function() -- Mock vim.fn.tabpagenr ---@diagnostic disable-next-line: duplicate-set-field vim.fn.tabpagenr = function(arg) if arg == "$" then - return 3 - end -- total tabpages - return 2 -- current tabpage + return 3 -- total tabpages for the first test, 1 for the second + end + return 2 -- current tabpage for the first test, 1 for the second end + end) + it("creates tabpage section for multiple tabpages", function() M.make_tabpage_section() assert.are.equal(" Tab 2/3 ", M.tabpage_section) end) it("creates no tabpage section for a single tabpage", function() - -- Mock vim.fn.tabpagenr + -- Change the mock for a single tabpage scenario ---@diagnostic disable-next-line: duplicate-set-field vim.fn.tabpagenr = function(arg) if arg == "$" then