From 4a96ee3da26e1695fdff2e0dd68c91b583a4698d Mon Sep 17 00:00:00 2001 From: "Afshin T. Darian" Date: Sat, 20 Aug 2022 02:23:02 +0100 Subject: [PATCH] Update docstrings and tests --- packages/algorithm/src/iter.ts | 4 ++-- packages/algorithm/tests/src/iter.spec.ts | 5 +++-- packages/algorithm/tests/src/retro.spec.ts | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/algorithm/src/iter.ts b/packages/algorithm/src/iter.ts index 6fd6cdd80..d93f1c0a1 100644 --- a/packages/algorithm/src/iter.ts +++ b/packages/algorithm/src/iter.ts @@ -13,7 +13,7 @@ * * @deprecated * - * @param object - The iterable or array-like object of interest. + * @param object - The iterable object of interest. * * @returns A new array of values from the given object. * @@ -33,7 +33,7 @@ export function toArray(object: Iterable): T[] { /** * Create an object from an iterable of key/value pairs. * - * @param object - The iterable or array-like object of interest. + * @param object - The iterable object of interest. * * @returns A new object mapping keys to values. * diff --git a/packages/algorithm/tests/src/iter.spec.ts b/packages/algorithm/tests/src/iter.spec.ts index 807435ad1..ab4556072 100644 --- a/packages/algorithm/tests/src/iter.spec.ts +++ b/packages/algorithm/tests/src/iter.spec.ts @@ -18,9 +18,10 @@ import { each, every, some, toArray, toObject, zip } from '@lumino/algorithm'; * expected results of that iterator. */ export function testIterator( - factory: () => [IterableIterator, T[]] + factory: () => [IterableIterator, T[]], + name = '' ): void { - describe('yield', () => { + describe(`yield ${name}`, () => { it('should return the same values in the iterator', () => { let [it, results] = factory(); expect(Array.from(it)).to.deep.equal(results); diff --git a/packages/algorithm/tests/src/retro.spec.ts b/packages/algorithm/tests/src/retro.spec.ts index 8c98455bc..285e13496 100644 --- a/packages/algorithm/tests/src/retro.spec.ts +++ b/packages/algorithm/tests/src/retro.spec.ts @@ -20,9 +20,9 @@ describe('@lumino/algorithm', () => { }); it('should call `retro` on a retroable', () => { - let iterator = [1, 2, 3, 4][Symbol.iterator](); - let retroable = { retro: () => iterator }; - expect(retro(retroable)).to.equal(iterator); + let data = [1, 2, 3, 4]; + let retroable = { retro: () => retro(data) }; + testIterator(() => [retro(retroable), data.slice().reverse()], 'retro'); }); it('should reverse an array', () => {