From a7c3fc6204c4866344dd0ed7aba33ec59464495b Mon Sep 17 00:00:00 2001 From: robin Date: Sat, 20 Dec 2025 23:45:35 +0100 Subject: [PATCH] meta: add tests --- .busted | 13 +++++++++++++ tests/minimal_init.vim | 2 ++ tests/nvim-shim | 3 +++ tests/sorter_spec.lua | 19 +++++++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 .busted create mode 100644 tests/minimal_init.vim create mode 100755 tests/nvim-shim create mode 100644 tests/sorter_spec.lua diff --git a/.busted b/.busted new file mode 100644 index 0000000..98b97e5 --- /dev/null +++ b/.busted @@ -0,0 +1,13 @@ +return { + _all = { + coverage = false, + lpath = "lua/?.lua;lua/?/init.lua", + lua = "./tests/nvim-shim", + }, + default = { + verbose = true, + }, + tests = { + verbose = true, + }, +} diff --git a/tests/minimal_init.vim b/tests/minimal_init.vim new file mode 100644 index 0000000..36c8a86 --- /dev/null +++ b/tests/minimal_init.vim @@ -0,0 +1,2 @@ +set rtp+=. +runtime! plugin/plenary.vim diff --git a/tests/nvim-shim b/tests/nvim-shim new file mode 100755 index 0000000..8dd6de6 --- /dev/null +++ b/tests/nvim-shim @@ -0,0 +1,3 @@ +#!/usr/bin/env sh + +nvim -l "$@" diff --git a/tests/sorter_spec.lua b/tests/sorter_spec.lua new file mode 100644 index 0000000..5bcd4c0 --- /dev/null +++ b/tests/sorter_spec.lua @@ -0,0 +1,19 @@ +describe("sort", function() + local sorter = require("artio").sorter + local lst = vim + .iter(ipairs({ "a", "b", "c" })) + :map(function(i, v) + return { id = i, v = v, text = v } + end) + :totable() + + it("alphabet by a", function() + assert.equals(1, vim.tbl_get(sorter(lst, "a"), 1, 1)) + end) + it("alphabet by b", function() + assert.equals(2, vim.tbl_get(sorter(lst, "b"), 2, 1)) + end) + it("alphabet by c", function() + assert.equals(3, vim.tbl_get(sorter(lst, "c"), 3, 1)) + end) +end) -- 2.51.2