refactor: 可読性のため一部でArray.prototype.at
を使うように (#11274)
* refactor: `Array.prototype.at`を使うように * fixup! refactor: `Array.prototype.at`を使うように
This commit is contained in:
parent
c0dbc3b53f
commit
2b6dbd4fcb
19 changed files with 46 additions and 44 deletions
|
@ -447,12 +447,12 @@ export async function testPaginationConsistency<Entity extends { id: string, cre
|
|||
for (const limit of [1, 5, 10, 100, undefined]) {
|
||||
// 1. sinceId/DateとuntilId/Dateで両端を指定して取得した結果が期待通りになっていること
|
||||
if (ordering === 'desc') {
|
||||
const end = expected[expected.length - 1];
|
||||
const end = expected.at(-1)!;
|
||||
let last = await fetchEntities(rangeToParam({ limit, since: end }));
|
||||
const actual: Entity[] = [];
|
||||
while (last.length !== 0) {
|
||||
actual.push(...last);
|
||||
last = await fetchEntities(rangeToParam({ limit, until: last[last.length - 1], since: end }));
|
||||
last = await fetchEntities(rangeToParam({ limit, until: last.at(-1), since: end }));
|
||||
}
|
||||
actual.push(end);
|
||||
assert.deepStrictEqual(
|
||||
|
@ -467,7 +467,7 @@ export async function testPaginationConsistency<Entity extends { id: string, cre
|
|||
const actual: Entity[] = [];
|
||||
while (last.length !== 0) {
|
||||
actual.push(...last);
|
||||
last = await fetchEntities(rangeToParam({ limit, since: last[last.length - 1] }));
|
||||
last = await fetchEntities(rangeToParam({ limit, since: last.at(-1) }));
|
||||
}
|
||||
assert.deepStrictEqual(
|
||||
actual.map(({ id, createdAt }) => id + ':' + createdAt),
|
||||
|
@ -480,7 +480,7 @@ export async function testPaginationConsistency<Entity extends { id: string, cre
|
|||
const actual: Entity[] = [];
|
||||
while (last.length !== 0) {
|
||||
actual.push(...last);
|
||||
last = await fetchEntities(rangeToParam({ limit, until: last[last.length - 1] }));
|
||||
last = await fetchEntities(rangeToParam({ limit, until: last.at(-1) }));
|
||||
}
|
||||
assert.deepStrictEqual(
|
||||
actual.map(({ id, createdAt }) => id + ':' + createdAt),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue