Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Run Lua Tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
lua-version: ['5.3']
steps:
- uses: actions/checkout@v2
- name: Setup Lua
uses: leafo/gh-actions-lua@v8
with:
lua-version: ${{ matrix.lua-version }}
- name: Install Luarocks
uses: leafo/gh-actions-luarocks@v2
- name: Install dependencies
run: luarocks install busted
- name: Run tests
run: busted ./tests/
5 changes: 4 additions & 1 deletion .luarc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"diagnostics.globals": ["vim"]
"diagnostics.globals": ["vim"],
"linter": "luacheck",
"test_framework": "busted",
"test_runner": "busted"
}
15 changes: 15 additions & 0 deletions development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Development Practices for Themery.nvim

This document outlines the development practices, including testing, for the Themery.nvim project.

## Running Unit Tests

To ensure the quality and functionality of Themery.nvim, unit tests have been implemented. These tests are located in the `tests/` directory of the repository.

To run the unit tests, you will need to have a Lua testing framework installed, such as Busted or Luassert. Once you have a testing framework installed, you can run the tests by executing the following command from the root of the repository:

```bash
busted ./tests/
```

This command will run all the tests found in the `tests/` directory and output the results. It's recommended to run the tests before pushing changes to ensure that your contributions do not introduce regressions or break existing functionality.
50 changes: 50 additions & 0 deletions tests/init_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
local themery = require("themery")
local mock = require("luassert.mock")
local stub = require("luassert.stub")

describe("Themery module", function()
before_each(function()
-- Mocking necessary Neovim API calls and other module dependencies
mock(vim.api, true)
stub(themery, "setup")
stub(themery, "closeAndRevert")
stub(themery, "closeAndSave")
stub(themery, "updateView")
end)

after_each(function()
mock.revert(vim.api)
themery.setup:revert()
themery.closeAndRevert:revert()
themery.closeAndSave:revert()
themery.updateView:revert()
end)

describe("setup function", function()
it("should configure themery with default settings", function()
themery.setup()
assert.stub(themery.setup).was_called_with()
end)
end)

describe("closeAndRevert function", function()
it("should revert to the previous theme", function()
themery.closeAndRevert()
assert.stub(themery.closeAndRevert).was_called()
end)
end)

describe("closeAndSave function", function()
it("should save the current theme and close the themery window", function()
themery.closeAndSave()
assert.stub(themery.closeAndSave).was_called()
end)
end)

describe("updateView function", function()
it("should update the themery window view based on user interaction", function()
themery.updateView(1)
assert.stub(themery.updateView).was_called_with(1)
end)
end)
end)