From f65a6541fd0c6bd89c72a87041f2f07f64daa08a Mon Sep 17 00:00:00 2001 From: Nadiia Padalka Date: Tue, 10 Mar 2026 21:00:11 +0200 Subject: [PATCH] fix hasBeenCalled function --- resources/assert_lib.brs | 5 +++- test/e2e/assert/assert.test.js | 24 +++++++++++++++++++ .../tests/01-hasBeenCalledWith.test.brs | 20 ++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/resources/assert_lib.brs b/resources/assert_lib.brs index 5a17dbb..d1722ad 100644 --- a/resources/assert_lib.brs +++ b/resources/assert_lib.brs @@ -161,9 +161,12 @@ function __roca_deepEquals(lhs as object, rhs as object) as boolean index = 0 for each updatedLeft in lhs updatedRight = rhs[index] - isEqual = __roca_deepEquals(updatedLeft, updatedRight) + if type(updatedRight) <> "roAssociativeArray" and type(updatedRight) <> "roArray" then + isEqual = (updatedLeft = updatedRight) + end if + if not isEqual then return false index++ diff --git a/test/e2e/assert/assert.test.js b/test/e2e/assert/assert.test.js index 4ec6abf..cec9fc0 100644 --- a/test/e2e/assert/assert.test.js +++ b/test/e2e/assert/assert.test.js @@ -14,6 +14,8 @@ describe("assert", () => { { fullTitle: "hasBeenCalledWith success complex arg" }, { fullTitle: "hasBeenCalledWith success multiple args" }, { fullTitle: "hasBeenCalledWith success multiple calls" }, + { fullTitle: "hasBeenCalledWith success boolean true value" }, + { fullTitle: "hasBeenCalledWith success boolean false value" }, ]); expect(results.failures).toMatchObject([ @@ -108,6 +110,28 @@ describe("assert", () => { name: "m.assert.hasBeenCalledWith", }, }, + { + fullTitle: + "hasBeenCalledWith failure boolean values, which do not match(true/false)", + err: { + actual: "(true)", + expected: "(false)", + message: + "Expected mock function 'fakeFunc' to have been called with args (false)", + name: "m.assert.hasBeenCalledWith", + }, + }, + { + fullTitle: + "hasBeenCalledWith failure boolean values, which do not match(false/true)", + err: { + actual: "(false)", + expected: "(true)", + message: + "Expected mock function 'fakeFunc' to have been called with args (true)", + name: "m.assert.hasBeenCalledWith", + }, + }, ]); }); }); diff --git a/test/e2e/assert/mock-function-calls/tests/01-hasBeenCalledWith.test.brs b/test/e2e/assert/mock-function-calls/tests/01-hasBeenCalledWith.test.brs index cec7bce..e97a9fa 100644 --- a/test/e2e/assert/mock-function-calls/tests/01-hasBeenCalledWith.test.brs +++ b/test/e2e/assert/mock-function-calls/tests/01-hasBeenCalledWith.test.brs @@ -33,6 +33,16 @@ function main(args as object) as object m.assert.hasBeenCalledWith(m.spy, ["bar"]) m.assert.hasBeenCalledWith(m.spy, ["baz"]) end sub) + + m.it("boolean true value", sub() + fakeFunc(true) + m.assert.hasBeenCalledWith(m.spy, [true]) + end sub) + + m.it("boolean false value", sub() + fakeFunc(false) + m.assert.hasBeenCalledWith(m.spy, [false]) + end sub) end sub) m.describe("failure", sub() @@ -60,6 +70,16 @@ function main(args as object) as object fakeFunc([], 456) m.assert.hasBeenCalledWith(m.spy, [["baz"], 456]) end sub) + + m.it("boolean values, which do not match(true/false)", sub() + fakeFunc(true) + m.assert.hasBeenCalledWith(m.spy, [false]) + end sub) + + m.it("boolean values, which do not match(false/true)", sub() + fakeFunc(false) + m.assert.hasBeenCalledWith(m.spy, [true]) + end sub) end sub) end sub) end function