From 68e3d5396daa29ad9d9161241ee9d6020b1b73f4 Mon Sep 17 00:00:00 2001 From: Chip Senkbeil Date: Mon, 22 Apr 2024 01:05:14 -0500 Subject: [PATCH] Bump wait for api node to be 300 millis --- spec/api_node_spec.lua | 20 ++++++++++---------- spec/utils.lua | 7 +++++++ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/spec/api_node_spec.lua b/spec/api_node_spec.lua index 2daa93a..31bad8c 100644 --- a/spec/api_node_spec.lua +++ b/spec/api_node_spec.lua @@ -51,13 +51,13 @@ describe("org-roam.api.node", function() roam.api.capture_node({}, function(_id) id = _id end) -- Wait a bit for the capture buffer to appear - vim.wait(100) + utils.wait() -- Save the capture buffer and exit it vim.cmd("wq") -- Wait a bit for the capture to be processed - vim.wait(100) + utils.wait() -- We should have an id for a valid capture assert.is_not_nil(id) @@ -97,7 +97,7 @@ describe("org-roam.api.node", function() end) -- Wait a bit for the capture to be processed - vim.wait(100) + utils.wait() -- We should have an id for a valid capture assert.is_not_nil(id) @@ -143,7 +143,7 @@ describe("org-roam.api.node", function() roam.api.insert_node({}, function(_id) id = _id end) -- Wait a bit for the capture to be processed - vim.wait(100) + utils.wait() -- We should have an id for a valid insertion assert.are.equal("1", id) @@ -186,13 +186,13 @@ describe("org-roam.api.node", function() roam.api.insert_node({}, function(_id) id = _id end) -- Wait a bit for the capture buffer to appear - vim.wait(100) + utils.wait() -- Save the capture buffer and exit it vim.cmd("wq") -- Wait a bit for the capture to be processed - vim.wait(100) + utils.wait() -- We should have an id for a valid insertion assert.is_not_nil(id) @@ -231,7 +231,7 @@ describe("org-roam.api.node", function() roam.api.insert_node({ immediate = true }, function(_id) id = _id end) -- Wait a bit for the capture to be processed - vim.wait(100) + utils.wait() -- We should have an id for a valid insertion assert.is_not_nil(id) @@ -269,7 +269,7 @@ describe("org-roam.api.node", function() roam.api.find_node({}, function(_id) id = _id end) -- Wait a bit for the capture to be processed - vim.wait(100) + utils.wait() -- We should have an id for a valid find assert.are.equal("2", id) @@ -309,13 +309,13 @@ describe("org-roam.api.node", function() roam.api.find_node({}, function(_id) id = _id end) -- Wait a bit for the capture buffer to appear - vim.wait(100) + utils.wait() -- Save the capture buffer and exit it vim.cmd("wq") -- Wait a bit for the capture to be processed - vim.wait(100) + utils.wait() -- We should have an id for a valid find assert.is_not_nil(id) diff --git a/spec/utils.lua b/spec/utils.lua index c55804a..fdb4f3c 100644 --- a/spec/utils.lua +++ b/spec/utils.lua @@ -26,6 +26,13 @@ function M.autogroup_name() return AUGROUP_NAME end +---Waits a standard amount of time for a test. +---This can be adjusted for CI usage. +---@param time? integer +function M.wait(time) + vim.wait(time or 300) +end + ---Takes string, splits into lines, and removes common indentation. ---@param s string ---@return string