From 2b26fc3634dcb0855bd7929dee49cf3cb53ecbae Mon Sep 17 00:00:00 2001 From: Siddharth VP Date: Wed, 18 Oct 2023 01:53:10 +0530 Subject: [PATCH] add test for bot.read() with empty array, add some TODOs --- src/bot.ts | 2 ++ src/file.ts | 2 +- tests/bot.test.js | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bot.ts b/src/bot.ts index f03cc41..11d041a 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -986,6 +986,7 @@ export class Mwn { ): Promise { editConfig = editConfig || this.options.editConfig; + // TODO: use baserevid instead of basetimestamp for conflict handling let basetimestamp: string, curtimestamp: string; return this.request({ @@ -1334,6 +1335,7 @@ export class Mwn { prop: 'imageinfo', iiprop: 'url', }).then((data) => { + // TODO: handle errors const url = data.query.pages[0].imageinfo[0].url; const name = new this.Title(data.query.pages[0].title).getMainText(); return this.downloadFromUrl(url, localname || name); diff --git a/src/file.ts b/src/file.ts index c5f1686..57667dd 100644 --- a/src/file.ts +++ b/src/file.ts @@ -4,7 +4,7 @@ import { ApiQueryBacklinkspropParams } from './api_params'; export interface MwnFileStatic { /** * @constructor - * @param {string} name - name of the file + * @param {string|MwnTitle} name - name of the file */ new (title: MwnTitle | string): MwnFile; } diff --git a/tests/bot.test.js b/tests/bot.test.js index 234ed87..3215664 100644 --- a/tests/bot.test.js +++ b/tests/bot.test.js @@ -114,6 +114,12 @@ describe('mwn', async function () { }); }); + it('returns empty array when empty array is passed to read()', function () { + return bot.read([]).then((response) => { + expect(response).to.be.instanceOf(Array).of.length(0); + }); + }); + it('successfully reads multiple pages using pageid with read()', function () { return bot .read([11791 /* Main Page */, 25 /* MediaWiki:Sidebar */], {