diff --git a/test/fixtures/init.lua b/test/fixtures/init.lua new file mode 100644 index 0000000..b9866b6 --- /dev/null +++ b/test/fixtures/init.lua @@ -0,0 +1,5 @@ +-- This is a nvimpager init file for the test suite. + +if vim.fn.has("nvim-0.10") == 1 then + vim.cmd.colorscheme("vim") +end diff --git a/test/nvimpager_spec.lua b/test/nvimpager_spec.lua index 4a71760..aad9408 100644 --- a/test/nvimpager_spec.lua +++ b/test/nvimpager_spec.lua @@ -74,16 +74,16 @@ describe("cat mode", function() end) end) - it("displays a small file with syntax highlighting to stdout", function() - local output = run("./nvimpager -c test/fixtures/makefile") + it("displays a small file with syntax highlighting to stdout #colorscheme", function() + local output = run("./nvimpager -c test/fixtures/makefile -u test/fixtures/init.lua") local expected = read("test/fixtures/makefile.ansi") assert.equal(expected, output) end) - it("reads stdin with syntax highlighting", function() + it("reads stdin with syntax highlighting #colorscheme", function() local output = run("./nvimpager -c -- " .. - "-c 'set filetype=make' " .. - "< test/fixtures/makefile") + "-c 'set filetype=make' -u test/fixtures/init.lua " .. + " < test/fixtures/makefile") local expected = read("test/fixtures/makefile.ansi") assert.equal(expected, output) end) @@ -94,24 +94,24 @@ describe("cat mode", function() assert.equal(expected, output) end) - it("handles color schemes with a non trivial Normal group", function() + it("handles color schemes with a non trivial Normal group #colorscheme", function() local output = run("./nvimpager -c test/fixtures/conceal.tex " .. - "--cmd 'hi Normal ctermfg=Red'") + " -u test/fixtures/init.lua --cmd 'hi Normal ctermfg=Red'") local expected = read("test/fixtures/conceal.tex.red") assert.equal(expected, output) end) - it("highlights all files", function() + it("highlights all files #colorscheme", function() local output = run("./nvimpager -c test/fixtures/makefile " .. - "test/fixtures/help.txt ") + "test/fixtures/help.txt -u test/fixtures/init.lua") local expected = read("test/fixtures/makefile.ansi") .. read("test/fixtures/help.txt.ansi") assert.equal(expected, output) end) - it("concatenates the same file twice", function() + it("concatenates the same file twice #colorscheme", function() local output = run("./nvimpager -c test/fixtures/makefile " .. - "test/fixtures/makefile ") + "test/fixtures/makefile -u test/fixtures/init.lua") local expected = read("test/fixtures/makefile.ansi") expected = expected .. expected assert.equal(expected, output) @@ -130,22 +130,22 @@ describe("cat mode", function() assert.equal('', output) end) - it("explicit - as file argument means stdin", function() - local shell_command = "echo foo | ./nvimpager -c - test/fixtures/makefile" + it("explicit - as file argument means stdin #colorscheme", function() + local shell_command = "echo foo | ./nvimpager -c - test/fixtures/makefile -u test/fixtures/init.lua" local output = run("sh -c '" .. shell_command .. "'") local expected = "\27[0mfoo\27[0m\n" .. read("test/fixtures/makefile.ansi") assert.equal(expected, output) end) - it("prefers file arguments over stdin", function() - local shell_command = "echo foo | ./nvimpager -c test/fixtures/makefile" + it("prefers file arguments over stdin #colorscheme", function() + local shell_command = "echo foo | ./nvimpager -c test/fixtures/makefile -u test/fixtures/init.lua" local output = run("sh -c '" .. shell_command .. "'") assert.equal(read("test/fixtures/makefile.ansi"), output) end) - it("can show stdin as the second file", function() - local output = run("echo foo | ./nvimpager -c test/fixtures/makefile -") + it("can show stdin as the second file #colorscheme", function() + local output = run("echo foo | ./nvimpager -c test/fixtures/makefile - -u test/fixtures/init.lua") local expected = read("test/fixtures/makefile.ansi") .. "\27[0mfoo\27[0m\n" assert.equal(expected, output) end)