Open AntoineGautier opened 2 months ago
const rawJson = { encapsulated: undefined, class_prefixes: 'partial', class_specifier: 'test class_specifier' } const referenceJsonOutput = { class_specifier: 'test class_specifier', encapsulated: true } equalObjects(rawJson, referenceJsonOutput) // returns false --> should return true
@anandkp92 Can you look into that?
This ticket covers two issues.
First, there seems to be a bug in the function
equalObjects
defined intest/test_jsonquery.js
and used in all unit tests.Whereas
Why
assert.deepStrictEqual()
is not used instead ofequalObjects
?Second, within the module
lib/jsonquery.js
, all local functions are invoked using the keywordthis
, i.e., assimilating the module as an object to resolve local references. This appears to be only required by the fact that the tests intest/test_jsonquery.js
rely onsinon
stubs which indeed do not support local function calls. But there is a workaround (usingrewire
) that can be implemented in the test script and avoids modifying the tested module.With the above code, the call to
classSpecifier
withinclassDefinition
can be made directly, withoutthis.classSpecifier
. Similarly, modifying each unit test with the above pattern enables getting rid ofthis
in all function calls withinlib/jsonquery.js
.