From 4c1297040234702b3262540e94c156ef00cca8dd Mon Sep 17 00:00:00 2001 From: Christian Angermann <28717+cange@users.noreply.github.com> Date: Tue, 30 Jul 2024 21:54:07 +0200 Subject: [PATCH] feat: introduce '.todo' as toggle for JavaScript ecosystem - jest: https://jestjs.io/docs/api#testtodoname - vitest: https://vitest.dev/api/#test-todo --- README.md | 16 +++++++++------- lua/specto/config.lua | 12 +++++++++--- lua/specto/toggle.lua | 3 +++ lua/specto/types.lua | 2 +- 4 files changed, 22 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index a77c330..c1efc66 100644 --- a/README.md +++ b/README.md @@ -68,8 +68,9 @@ The provided commands can either be called directly via `:Specto toggle *` withi a test block or used via keybinding. ```lua -vim.keymap.set("n", "to", "Specto toggle only" ) -vim.keymap.set("n", "ts", "Specto toggle skip" ) +vim.keymap.set("n", "to", "Specto toggle only", { desc = "Toggle test only" }) +vim.keymap.set("n", "ts", "Specto toggle skip", { desc = "Toggle test skip" }) +vim.keymap.set("n", "tt", "Specto toggle todo", { desc = "Toggle test todo" }) ``` ### Scope @@ -138,9 +139,10 @@ Each language can be define an individual set for `only` and `skip` features. ### Supported Languages -List of supported languages and their dedicated DSLs (eg. `it`, `describe`, `test`). +List of supported languages and their dedicated framework DSLs (eg. `it`, +`describe`, `test`). -| Language | DSL | Features | Examples | -| ------------------------- | :---: | ---------- | ------------------- | -| `javascript`/`typescript` | jest | only, skip | `it.only`,`it.skip` | -| `ruby` | rspec | skip | `xit` | +| Language | DSL | skip | only | todo | +| ------------------------- | :---------: | :--: | :--: | :--: | +| `javascript`/`typescript` | jest/vitest | ✓ | ✓ | ✓ | +| `ruby` | rspec | ✓ | ⛌ | ⛌ | diff --git a/lua/specto/config.lua b/lua/specto/config.lua index 52f048e..5d5e6d1 100644 --- a/lua/specto/config.lua +++ b/lua/specto/config.lua @@ -18,15 +18,21 @@ local defaults = { filetypes = { "javascript", "typescript" }, file_patterns = { "__tests__/", "%.?test%.", "%.?spec%." }, features = { + only = { + flag = "only", + keywords = { "it", "describe", "test" }, + prefix = false, + separator = ".", + }, skip = { flag = "skip", keywords = { "it", "describe", "test" }, prefix = false, separator = ".", }, - only = { - flag = "only", - keywords = { "it", "describe", "test" }, + todo = { + flag = "todo", + keywords = { "it", "describe", "test", "bench" }, prefix = false, separator = ".", }, diff --git a/lua/specto/toggle.lua b/lua/specto/toggle.lua index b4d3afb..2f8ad61 100644 --- a/lua/specto/toggle.lua +++ b/lua/specto/toggle.lua @@ -101,4 +101,7 @@ function M.only() toggle:setup("only") end ---@example it.skip() => it() => it.skip() function M.skip() toggle:setup("skip") end +---@example it.todo() => it() => it.todo() +function M.todo() toggle:setup("todo") end + return M diff --git a/lua/specto/types.lua b/lua/specto/types.lua index 50bc8d7..a7ede01 100644 --- a/lua/specto/types.lua +++ b/lua/specto/types.lua @@ -19,7 +19,7 @@ ---@field prefix boolean ---@alias specto.ConfigFeatureKeywords string[] ----@alias specto.ToggleType '"only"'|'"skip"' +---@alias specto.ToggleType '"only"'|'"skip"'|'"todo"' ---@class specto.Tree ---@field type specto.ToggleType