Skip to content

Commit

Permalink
Added insertion order Map tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Oct 2, 2014
1 parent 31ee4d5 commit c498619
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,17 @@ describe('Collections', function () {
);
});
});

it('should preserve insertion order', function() {
var convertToPairs = function (item) { return [item, true]; };
var arr1 = ['d', 'a', 'b'];
var arr2 = [3, 2, 'z', 'a', 1];
var arr3 = [3, 2, 'z', {}, 'a', 1];

expect(Array.from(new Map(arr1.map(convertToPairs)).keys())).to.eql(arr1);
expect(Array.from(new Map(arr2.map(convertToPairs)).keys())).to.eql(arr2);
expect(Array.from(new Map(arr3.map(convertToPairs)).keys())).to.eql(arr3);
});
});

it('map iteration', function () {
Expand Down

0 comments on commit c498619

Please sign in to comment.