32 lines
822 B
Plaintext
32 lines
822 B
Plaintext
![]() |
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.
|
||
|
|
||
|
This rule raises an issue when a Chai assertion is given twice the same argument.
|
||
|
|
||
|
== Noncompliant Code Example
|
||
|
|
||
|
----
|
||
|
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
|
||
|
|
||
|
----
|
||
|
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);
|
||
|
});
|
||
|
});
|
||
|
----
|