Use chai directly instead of internal `eq` function in test asserts
See original GitHub issueAppropriate assert functions from chai should be used to be more explicit.
Code like this:
describe('ensureArray', function() {
context('given argument is not an array', function() {
specify('should wrap value into singleton array', function() {
const arrayPrototype = Array.prototype;
eq(RA.ensureArray(void 0), [void 0]);
eq(RA.ensureArray({}), [{}]);
eq(RA.ensureArray(null), [null]);
eq(RA.ensureArray(undefined), [undefined]);
eq(RA.ensureArray(42), [42]);
eq(RA.ensureArray('Array'), ['Array']);
eq(RA.ensureArray(true), [true]);
eq(RA.ensureArray(false), [false]);
eq(RA.ensureArray({ __proto__: arrayPrototype }), [
{ __proto__: arrayPrototype },
]);
});
});
});
has to become like this:
import { assert } from 'chai';
describe('ensureArray', function() {
context('given argument is not an array', function() {
specify('should wrap value into singleton array', function() {
const arrayPrototype = Array.prototype;
assert.sameOrderedMembers(RA.ensureArray(void 0), [void 0]);
assert.sameDeepOrderedMembers(RA.ensureArray({}), [{}]);
assert.sameOrderedMembers(RA.ensureArray(null), [null]);
assert.sameOrderedMembers(RA.ensureArray(undefined), [undefined]);
assert.sameOrderedMembers(RA.ensureArray(42), [42]);
assert.sameOrderedMembers(RA.ensureArray('Array'), ['Array']);
assert.sameOrderedMembers(RA.ensureArray(true), [true]);
assert.sameOrderedMembers(RA.ensureArray(false), [false]);
assert.sameDeepOrderedMembers(
RA.ensureArray({ __proto__: arrayPrototype }),
[{ __proto__: arrayPrototype }]
);
});
});
Issue Analytics
- State:
- Created 4 years ago
- Comments:34 (7 by maintainers)
Top Results From Across the Web
JavaScript — Unit Testing using Mocha and Chai - codeburst
This article will cover testing of basic function, testing of async callback functions and testing of promises with Mocha and Chai.
Read more >The Ultimate Unit Testing Cheat-sheet For Mocha, Chai, Sinon ...
Asserts that the target has a property name, optionally asserting that the value of that property is strictly equal to value. If the...
Read more >Core Plugin Concepts - Chai Assertion Library
This tutorial will show you how to access Chai's plugin API, use flags to transfer data through the language chain, and write your...
Read more >Unit testing Node.js applications using Mocha, Chai, and Sinon
In this article, we will look at how to use Mocha for testing, Chai for assertions and Sinon for mocks, spies, and stubs....
Read more >How do I test if a function calls a specific method/function?
I am using Mocha with Chai, but am open to any other assertion libraries. Ok, so testing whether a methid is being called...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@char0n, here is Batch 20 PR
@char0n, here is Batch 19 PR