Skip to content

Commit

Permalink
changes added
Browse files Browse the repository at this point in the history
  • Loading branch information
bakshiutkarsha committed May 26, 2020
1 parent e40387f commit 8730bc6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion test/unit/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ test('wikitext comparison', async(t) => {
const wikicode = `According to the principle of conservation of mechanical energy, the mechanical energy of an [[isolated system]] remains constant in time, as long as the system is free of [[friction]] and other non-conservative forces.`;
const html = `<p id="mwAQ">According to the principle of conservation of mechanical energy, the mechanical energy of an <a rel="mw:WikiLink" href="./Isolated_system" title="Isolated system" id="mwAg">isolated system</a> remains constant in time, as long as the system is free of <a rel="mw:WikiLink" href="./Friction" title="Friction" id="mwAw">friction</a> and other non-conservative forces.</p>`;
const resultHtml = await convertWikicodeToHtml(wikicode, 'https://en.wikipedia.org/');
t.equals(html, resultHtml, 'HTML matches')
t.equal(html, resultHtml, `HTML and Wikitext match`);
})
15 changes: 5 additions & 10 deletions test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Downloader from '../src/Downloader';
import { Dump } from '../src/Dump';
import axios from 'axios';
import execa = require('execa');
import logger from '../src/Logger';

export function leftPad(_num: number, length: number) {
const num = `${_num}`;
Expand Down Expand Up @@ -68,13 +67,9 @@ export async function zimcheck(filePath: string) {
}

export async function convertWikicodeToHtml(wikicode: string, baseUrl: string): Promise<string> {
return axios.post(`${baseUrl}api/rest_v1/transform/wikitext/to/html`, {
'wikitext': wikicode,
'body_only': true,
})
.then((resp: any) => {
return resp.data;
}).catch((err) => {
return err;
});
const resp = await axios.post(`${baseUrl}api/rest_v1/transform/wikitext/to/html`, {
wikitext: wikicode,
body_only: true,
})
return resp.data;
}

0 comments on commit 8730bc6

Please sign in to comment.