52 lines
1.1 KiB
Plaintext
Raw Normal View History

Many assertions compare two objects or properties of these objects. Passing twice the same argument is likely to be a bug due to developer's carelessness.
2021-02-02 15:02:10 +01:00
This rule raises an issue when a Chai assertion is given twice the same argument.
== Noncompliant Code Example
2022-02-04 17:28:24 +01:00
[source,javascript]
----
const assert = require('chai').assert;
describe("test the same object", function() {
it("uses chai 'assert'", function() {
const expected = '1'
const actual = (1).toString()
assert.equal(actual, actual); // Noncompliant
});
});
----
== Compliant Solution
2022-02-04 17:28:24 +01:00
[source,javascript]
----
const assert = require('chai').assert;
describe("test the same object", function() {
it("uses chai 'assert'", function() {
const expected = '1'
const actual = (1).toString()
assert.equal(actual, expected);
});
});
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
include::highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]