Skip to content

Commit

Permalink
add test for bot.read() with empty array, add some TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
siddharthvp committed Oct 17, 2023
1 parent 5388018 commit 2b26fc3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/bot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,7 @@ export class Mwn {
): Promise<ApiEditResponse> {
editConfig = editConfig || this.options.editConfig;

// TODO: use baserevid instead of basetimestamp for conflict handling
let basetimestamp: string, curtimestamp: string;

return this.request({
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions tests/bot.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */], {
Expand Down

0 comments on commit 2b26fc3

Please sign in to comment.