diff --git a/packages/collection/__tests__/collection.test.ts b/packages/collection/__tests__/collection.test.ts index 26843dce1..f3c80c31d 100644 --- a/packages/collection/__tests__/collection.test.ts +++ b/packages/collection/__tests__/collection.test.ts @@ -828,9 +828,14 @@ describe('tap() tests', () => { }); describe('toJSON() tests', () => { - test('it returns the values as an array', () => { + test('it returns the entries of the collection', () => { const c = createTestCollection(); - expect(c.toJSON()).toStrictEqual([1, 2, 3]); + + expect(c.toJSON()).toStrictEqual([ + ['a', 1], + ['b', 2], + ['c', 3], + ]); }); }); diff --git a/packages/collection/src/collection.ts b/packages/collection/src/collection.ts index 93bfc950a..fcee69f7f 100644 --- a/packages/collection/src/collection.ts +++ b/packages/collection/src/collection.ts @@ -933,7 +933,7 @@ export class Collection extends Map { public toJSON() { // toJSON is called recursively by JSON.stringify. - return [...this.values()]; + return [...this.entries()]; } private static defaultSort(firstValue: V, secondValue: V): number {