Skip to content

Commit

Permalink
feat: introduce '.todo' as toggle for JavaScript ecosystem
Browse files Browse the repository at this point in the history
  • Loading branch information
cange committed Jul 31, 2024
1 parent 4e14227 commit 4c12970
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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", "<leader>to", "<cmd>Specto toggle only<CR>" )
vim.keymap.set("n", "<leader>ts", "<cmd>Specto toggle skip<CR>" )
vim.keymap.set("n", "<leader>to", "<cmd>Specto toggle only<CR>", { desc = "Toggle test only" })
vim.keymap.set("n", "<leader>ts", "<cmd>Specto toggle skip<CR>", { desc = "Toggle test skip" })
vim.keymap.set("n", "<leader>tt", "<cmd>Specto toggle todo<CR>", { desc = "Toggle test todo" })
```

### Scope
Expand Down Expand Up @@ -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 | | | |
12 changes: 9 additions & 3 deletions lua/specto/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ".",
},
Expand Down
3 changes: 3 additions & 0 deletions lua/specto/toggle.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lua/specto/types.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4c12970

Please sign in to comment.