vendredi 3 juillet 2015

Testing Maps/Sets with QUnit (or other Unit Testing Tool)

How do we assert for equality of ES6 Maps and Sets?

For example:

// ES6 Map
var m1 = new Map();
m1.set('one', 1);
var m2 = new Map();
m2.set('two', 2);
assert.deepEqual(m1,m2);     // outputs: passed.

// ES6 Set
var s1 = new Set();
s1.add(1);
var s2 = new Set();
s2.add(2);
assert.deepEqual(s1,s2);     // outputs: passed.

The intention is to assert that the elements of the Sets/Maps are equal. Both the both assertions should fail.

Is there an equivalent of deepEqual for Sets/Maps? In other words, short of manually iterating the elements, how do we test for Set/Map equality deeply?

If there is no way in QUnit, is there a unit testing tool that works for ES6 Sets and Maps?

Aucun commentaire:

Enregistrer un commentaire