summaryrefslogtreecommitdiff
path: root/lua/99/test
diff options
context:
space:
mode:
authorcodegirl007 <s.raide@gmail.com>2026-02-08 18:04:32 -0800
committerGitHub <noreply@github.com>2026-02-08 18:04:32 -0800
commite4050fe6164765202814b353db43da75c1947af6 (patch)
tree8e9fe8b195edcde1d3b37134be672655d169f5e1 /lua/99/test
parent17be2bff90a22d8bafc102e3ca1730bb05026841 (diff)
parent76acc1d15d8a2161d43b60ee8c5d49c1a5885c60 (diff)
downloada4-e4050fe6164765202814b353db43da75c1947af6.tar.xz
a4-e4050fe6164765202814b353db43da75c1947af6.zip
Merge branch 'master' into back-that-hash-up
Diffstat (limited to 'lua/99/test')
-rw-r--r--lua/99/test/providers_spec.lua13
-rw-r--r--lua/99/test/throbber_spec.lua91
2 files changed, 100 insertions, 4 deletions
diff --git a/lua/99/test/providers_spec.lua b/lua/99/test/providers_spec.lua
index 2c75030..809080b 100644
--- a/lua/99/test/providers_spec.lua
+++ b/lua/99/test/providers_spec.lua
@@ -8,10 +8,15 @@ describe("providers", function()
local request = { context = { model = "anthropic/claude-sonnet-4-5" } }
local cmd =
Providers.OpenCodeProvider._build_command(nil, "test query", request)
- eq(
- { "opencode", "run", "-m", "anthropic/claude-sonnet-4-5", "test query" },
- cmd
- )
+ eq({
+ "opencode",
+ "run",
+ "--agent",
+ "build",
+ "-m",
+ "anthropic/claude-sonnet-4-5",
+ "test query",
+ }, cmd)
end)
it("has correct default model", function()
diff --git a/lua/99/test/throbber_spec.lua b/lua/99/test/throbber_spec.lua
new file mode 100644
index 0000000..39425a5
--- /dev/null
+++ b/lua/99/test/throbber_spec.lua
@@ -0,0 +1,91 @@
+---- PURELY AI GENERATED FILE -----
+---- This could be crap test, i did about ~15 second code review,
+---- looks mostly correct, a little weird, but close enough ----
+local Throbber = require("99.ops.throbber")
+local eq = assert.are.same
+
+describe("Throbber", function()
+ it(
+ "cycles through throb, cooldown, and restart phases, then stops",
+ function()
+ local test_icons = { "a", "b", "c", "d", "e" }
+ local original_icons = Throbber._icons
+ Throbber._icons = { test_icons }
+
+ local received = {}
+ local states = {}
+ --- @type _99.Throbber
+ local throbber
+ throbber = Throbber.new(function(icon)
+ table.insert(received, icon)
+ table.insert(states, throbber.state)
+ end)
+ throbber.throb_fn = function(percent)
+ local index = math.floor(percent * #test_icons) + 1
+ return test_icons[math.min(index, #test_icons)]
+ end
+
+ -- Start throbbing
+ throbber:start()
+ vim.wait(800)
+
+ -- Verify we cycled through multiple icons (throb phase)
+ local seen_icons = {}
+ for _, icon in ipairs(received) do
+ seen_icons[icon] = true
+ end
+ assert.is_true(
+ seen_icons["a"] and seen_icons["b"] and seen_icons["c"],
+ "Expected to cycle through multiple icons during throb phase"
+ )
+
+ -- Wait for cooldown (should stay on first icon)
+ local icon_count_before_cooldown = #received
+ vim.wait(600)
+
+ -- Verify cooldown: stays on first icon
+ local cooldown_icons = {}
+ for i = icon_count_before_cooldown + 1, #received do
+ table.insert(cooldown_icons, received[i])
+ end
+ for _, icon in ipairs(cooldown_icons) do
+ eq("e", icon, "Expected cooldown to stay on last icon")
+ end
+
+ -- Wait for second throb cycle to start
+ vim.wait(600)
+
+ -- Verify we transitioned back to throbbing state
+ local seen_throbbing = false
+ local seen_cooldown = false
+ local seen_second_throb = false
+ for _, state in ipairs(states) do
+ if state == "throbbing" then
+ if not seen_throbbing then
+ seen_throbbing = true
+ elseif seen_cooldown then
+ seen_second_throb = true
+ end
+ elseif state == "cooldown" then
+ seen_cooldown = true
+ end
+ end
+ assert.is_true(seen_throbbing, "Expected to see throbbing state")
+ assert.is_true(seen_cooldown, "Expected to see cooldown state")
+ assert.is_true(
+ seen_second_throb,
+ "Expected to see second throbbing cycle"
+ )
+
+ -- Stop the throbber
+ throbber:stop()
+ local count_after_stop = #received
+
+ -- Verify no more updates after stop
+ vim.wait(300)
+ eq(count_after_stop, #received, "Expected no more updates after stop")
+
+ Throbber._icons = original_icons
+ end
+ )
+end)