Skip to content

Commit

Permalink
Fix test warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
notomo committed Sep 9, 2024
1 parent 69f5b21 commit bfee746
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 17 deletions.
2 changes: 2 additions & 0 deletions lua/promise/test/helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ local helper = require("vusted.helper")
local plugin_name = helper.get_module_root(...)

helper.root = helper.find_plugin_root(plugin_name)
vim.opt.packpath:prepend(vim.fs.joinpath(helper.root, "spec/.shared/packages"))
require("assertlib").register(require("vusted.assert").register)

function helper.before_each() end

Expand Down
5 changes: 3 additions & 2 deletions spec/lua/promise/all_settled_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("promise.test.helper")
local Promise = helper.require("promise")
local assert = require("assertlib").typed(assert)

describe("Promise.all_settled()", function()
before_each(helper.before_each)
Expand All @@ -22,7 +23,7 @@ describe("Promise.all_settled()", function()
end)
on_finished:wait()

assert.is_same({
assert.same({
{ status = "fulfilled", value = 1 },
{ status = "rejected", reason = 2 },
{ status = "fulfilled", value = 3 },
Expand All @@ -37,6 +38,6 @@ describe("Promise.all_settled()", function()
on_finished()
end)
on_finished:wait()
assert.is_same({}, got)
assert.same({}, got)
end)
end)
5 changes: 3 additions & 2 deletions spec/lua/promise/all_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("promise.test.helper")
local Promise = helper.require("promise")
local assert = require("assertlib").typed(assert)

describe("Promise.all()", function()
before_each(helper.before_each)
Expand All @@ -22,7 +23,7 @@ describe("Promise.all()", function()
end)
on_finished:wait()

assert.is_same({ 1, 2, 3 }, got)
assert.same({ 1, 2, 3 }, got)
end)

it("resolves even if empty", function()
Expand All @@ -33,7 +34,7 @@ describe("Promise.all()", function()
on_finished()
end)
on_finished:wait()
assert.is_same({}, got)
assert.same({}, got)
end)

it("rejects if any promise is rejected", function()
Expand Down
7 changes: 4 additions & 3 deletions spec/lua/promise/any_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("promise.test.helper")
local Promise = helper.require("promise")
local assert = require("assertlib").typed(assert)

describe("Promise.any()", function()
before_each(helper.before_each)
Expand All @@ -22,7 +23,7 @@ describe("Promise.any()", function()
end)
on_finished:wait()

assert.is_same(1, got)
assert.same(1, got)
end)

it("rejects if empty", function()
Expand All @@ -33,7 +34,7 @@ describe("Promise.any()", function()
on_finished()
end)
on_finished:wait()
assert.is_same({}, got)
assert.same({}, got)
end)

it("rejects if all promise is rejected", function()
Expand All @@ -53,6 +54,6 @@ describe("Promise.any()", function()
end)
on_finished:wait()

assert.is_same({ 1, 2, 3 }, got)
assert.same({ 1, 2, 3 }, got)
end)
end)
3 changes: 2 additions & 1 deletion spec/lua/promise/catch_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("promise.test.helper")
local Promise = helper.require("promise")
local assert = require("assertlib").typed(assert)

describe("promise:catch()", function()
before_each(helper.before_each)
Expand Down Expand Up @@ -146,6 +147,6 @@ describe("promise:catch()", function()
end)
on_finished:wait()

assert.is_same({ 1, 2, 3 }, got)
assert.same({ 1, 2, 3 }, got)
end)
end)
5 changes: 3 additions & 2 deletions spec/lua/promise/finally_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("promise.test.helper")
local Promise = helper.require("promise")
local assert = require("assertlib").typed(assert)

describe("promise:finally()", function()
before_each(helper.before_each)
Expand Down Expand Up @@ -42,7 +43,7 @@ describe("promise:finally()", function()
end)
on_finished:wait()

assert.is_same(want, got)
assert.same(want, got)
end)

it("continues from catch()", function()
Expand Down Expand Up @@ -84,6 +85,6 @@ describe("promise:finally()", function()
end)
on_finished:wait()

assert.is_same(want, got)
assert.same(want, got)
end)
end)
1 change: 1 addition & 0 deletions spec/lua/promise/new_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("promise.test.helper")
local Promise = helper.require("promise")
local assert = require("assertlib").typed(assert)

describe("Promise.new()", function()
before_each(helper.before_each)
Expand Down
5 changes: 3 additions & 2 deletions spec/lua/promise/next_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("promise.test.helper")
local Promise = helper.require("promise")
local assert = require("assertlib").typed(assert)

describe("promise:next()", function()
before_each(helper.before_each)
Expand Down Expand Up @@ -51,7 +52,7 @@ describe("promise:next()", function()
on_finished1:wait()
on_finished2:wait()

assert.is_same({ 1, 2, 3, 4 }, got)
assert.same({ 1, 2, 3, 4 }, got)
end)

it("skips catch()", function()
Expand Down Expand Up @@ -167,6 +168,6 @@ describe("promise:next()", function()
end)
on_finished:wait()

assert.is_same({ 1, 2, 3 }, got)
assert.same({ 1, 2, 3 }, got)
end)
end)
3 changes: 2 additions & 1 deletion spec/lua/promise/race_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("promise.test.helper")
local Promise = helper.require("promise")
local assert = require("assertlib").typed(assert)

describe("Promise.race()", function()
before_each(helper.before_each)
Expand Down Expand Up @@ -30,7 +31,7 @@ describe("Promise.race()", function()
end)
on_finished:wait()

assert.is_same(2, got)
assert.same(2, got)
end)

it("rejects if any promise is rejected", function()
Expand Down
3 changes: 2 additions & 1 deletion spec/lua/promise/reject_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("promise.test.helper")
local Promise = helper.require("promise")
local assert = require("assertlib").typed(assert)

describe("Promise.reject()", function()
before_each(helper.before_each)
Expand All @@ -24,7 +25,7 @@ describe("Promise.reject()", function()
end)

helper.wait(p)
assert.is_same({ want1, want2 }, got)
assert.same({ want1, want2 }, got)
end)

it("if the argument is a promise, returns the promise", function()
Expand Down
3 changes: 2 additions & 1 deletion spec/lua/promise/resolve_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("promise.test.helper")
local Promise = helper.require("promise")
local assert = require("assertlib").typed(assert)

describe("Promise.resolve()", function()
before_each(helper.before_each)
Expand All @@ -24,7 +25,7 @@ describe("Promise.resolve()", function()
end)

helper.wait(p)
assert.is_same({ want1, want2 }, got)
assert.same({ want1, want2 }, got)
end)

it("if the argument is a promise, returns the promise", function()
Expand Down
5 changes: 3 additions & 2 deletions spec/lua/promise/with_resolvers_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local helper = require("promise.test.helper")
local Promise = helper.require("promise")
local assert = require("assertlib").typed(assert)

describe("Promise.with_resolvers()", function()
before_each(helper.before_each)
Expand All @@ -19,7 +20,7 @@ describe("Promise.with_resolvers()", function()
end)
on_finished:wait()

assert.is_same("ok", got)
assert.same("ok", got)
end)

it("returns promise with reject", function()
Expand All @@ -36,6 +37,6 @@ describe("Promise.with_resolvers()", function()
end)
on_finished:wait()

assert.is_same("error", got)
assert.same("error", got)
end)
end)

0 comments on commit bfee746

Please sign in to comment.