-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
91d0bf0
commit 1a1a4a8
Showing
11 changed files
with
95 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const { MediaWikiApi } = require('..') | ||
const { env } = require('node:process') | ||
|
||
const api = new MediaWikiApi('https://zh.moegirl.org.cn/api.php', { | ||
headers: { | ||
'api-user-agent': env.MOEGIRL_API_USER_AGENT || '', | ||
}, | ||
}) | ||
|
||
const username = env.MOEGIRL_USERNAME || '' | ||
const password = env.MOEGIRL_PASSWORD || '' | ||
|
||
api.login(username, password).then(console.info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { MediaWikiApi } from '../dist/index.js' | ||
import { env } from 'node:process' | ||
|
||
const api = new MediaWikiApi('https://zh.moegirl.org.cn/api.php', { | ||
headers: { | ||
'api-user-agent': env.MOEGIRL_API_USER_AGENT || '', | ||
}, | ||
}) | ||
|
||
const username = env.MOEGIRL_USERNAME || '' | ||
const password = env.MOEGIRL_PASSWORD || '' | ||
|
||
api.login(username, password).then(console.info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { describe, it } from 'mocha' | ||
import { expect } from 'chai' | ||
import { env } from 'process' | ||
import { MediaWikiApi } from '../src/index' | ||
|
||
const api = new MediaWikiApi('https://zh.moegirl.org.cn/api.php', { | ||
headers: { | ||
'api-user-agent': env.MOEGIRL_API_USER_AGENT || '', | ||
}, | ||
}) | ||
|
||
const username = env.MOEGIRL_USERNAME || '' | ||
const password = env.MOEGIRL_PASSWORD || '' | ||
|
||
const now = new Date() | ||
const editTitle = `User:${username}/sandbox/wiki-saikou` | ||
let editPageid = 0 | ||
let editNewrevid = 0 | ||
|
||
describe('Actions', () => { | ||
it('Login', async () => { | ||
const login = await api.login(username, password) | ||
expect(login.result).to.equal('Success') | ||
}) | ||
|
||
it('Do edit', async () => { | ||
const { | ||
data: { edit }, | ||
} = await api.postWithEditToken({ | ||
action: 'edit', | ||
title: editTitle, | ||
text: now.toISOString(), | ||
summary: '[Automatic] Unit tests for https://npm.im/wiki-saikou', | ||
}) | ||
expect(edit.result).to.equal('Success') | ||
editPageid = edit.pageid | ||
editNewrevid = edit.newrevid | ||
}) | ||
|
||
it('Check edit contents', async () => { | ||
const { | ||
data: { | ||
query: { | ||
pages: [page], | ||
}, | ||
}, | ||
} = await api.get({ | ||
action: 'query', | ||
revids: editNewrevid, | ||
prop: 'revisions', | ||
rvprop: 'user|content', | ||
}) | ||
expect(page.pageid).to.equal(editPageid) | ||
expect(page.revisions[0].user).to.equal(username) | ||
expect(page.revisions[0].content).to.equal(now.toISOString()) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters