diff --git a/lua/promise/test/helper.lua b/lua/promise/test/helper.lua index 7e426a6..d0b5069 100644 --- a/lua/promise/test/helper.lua +++ b/lua/promise/test/helper.lua @@ -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 diff --git a/spec/lua/promise/all_settled_spec.lua b/spec/lua/promise/all_settled_spec.lua index 5666a9b..092cd47 100644 --- a/spec/lua/promise/all_settled_spec.lua +++ b/spec/lua/promise/all_settled_spec.lua @@ -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) @@ -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 }, @@ -37,6 +38,6 @@ describe("Promise.all_settled()", function() on_finished() end) on_finished:wait() - assert.is_same({}, got) + assert.same({}, got) end) end) diff --git a/spec/lua/promise/all_spec.lua b/spec/lua/promise/all_spec.lua index 91ba69a..17d3087 100644 --- a/spec/lua/promise/all_spec.lua +++ b/spec/lua/promise/all_spec.lua @@ -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) @@ -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() @@ -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() diff --git a/spec/lua/promise/any_spec.lua b/spec/lua/promise/any_spec.lua index ce86278..6ad2468 100644 --- a/spec/lua/promise/any_spec.lua +++ b/spec/lua/promise/any_spec.lua @@ -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) @@ -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() @@ -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() @@ -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) diff --git a/spec/lua/promise/catch_spec.lua b/spec/lua/promise/catch_spec.lua index 7014e0d..141f789 100644 --- a/spec/lua/promise/catch_spec.lua +++ b/spec/lua/promise/catch_spec.lua @@ -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) @@ -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) diff --git a/spec/lua/promise/finally_spec.lua b/spec/lua/promise/finally_spec.lua index 54c6a83..9c95bfb 100644 --- a/spec/lua/promise/finally_spec.lua +++ b/spec/lua/promise/finally_spec.lua @@ -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) @@ -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() @@ -84,6 +85,6 @@ describe("promise:finally()", function() end) on_finished:wait() - assert.is_same(want, got) + assert.same(want, got) end) end) diff --git a/spec/lua/promise/new_spec.lua b/spec/lua/promise/new_spec.lua index c20dbb7..b3fbecb 100644 --- a/spec/lua/promise/new_spec.lua +++ b/spec/lua/promise/new_spec.lua @@ -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) diff --git a/spec/lua/promise/next_spec.lua b/spec/lua/promise/next_spec.lua index 31b578f..9534571 100644 --- a/spec/lua/promise/next_spec.lua +++ b/spec/lua/promise/next_spec.lua @@ -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) @@ -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() @@ -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) diff --git a/spec/lua/promise/race_spec.lua b/spec/lua/promise/race_spec.lua index b709a15..f9c7fa7 100644 --- a/spec/lua/promise/race_spec.lua +++ b/spec/lua/promise/race_spec.lua @@ -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) @@ -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() diff --git a/spec/lua/promise/reject_spec.lua b/spec/lua/promise/reject_spec.lua index e17f09c..62c9f01 100644 --- a/spec/lua/promise/reject_spec.lua +++ b/spec/lua/promise/reject_spec.lua @@ -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) @@ -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() diff --git a/spec/lua/promise/resolve_spec.lua b/spec/lua/promise/resolve_spec.lua index 518ef6d..de9e04e 100644 --- a/spec/lua/promise/resolve_spec.lua +++ b/spec/lua/promise/resolve_spec.lua @@ -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) @@ -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() diff --git a/spec/lua/promise/with_resolvers_spec.lua b/spec/lua/promise/with_resolvers_spec.lua index 4a1d548..43bd872 100644 --- a/spec/lua/promise/with_resolvers_spec.lua +++ b/spec/lua/promise/with_resolvers_spec.lua @@ -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) @@ -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() @@ -36,6 +37,6 @@ describe("Promise.with_resolvers()", function() end) on_finished:wait() - assert.is_same("error", got) + assert.same("error", got) end) end)