Skip to content

Commit

Permalink
Add test for downloading map images
Browse files Browse the repository at this point in the history
  • Loading branch information
audiodude committed Jul 19, 2024
1 parent ebd2a4d commit 157c2b9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/unit/downloader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,19 @@ describe('Downloader class', () => {
expect(LondonImage.responseHeaders['content-type']).toMatch(/image\//i)
})

test('downloadContent successfully downloads a map image', async () => {
const { data: LondonHtml } = await Axios.get('https://en.wikipedia.org/api/rest_v1/page/html/London')
const doc = domino.createDocument(LondonHtml)
const imgToGet = Array.from(doc.querySelectorAll('.mw-kartographer-map img'))[0]
let imgToGetSrc = ''
if (imgToGet.getAttribute('src')) {
imgToGetSrc = imgToGet.getAttribute('src')
}
// This is the downloading of an image
const LondonImage = await downloader.downloadContent(imgToGetSrc)
expect(LondonImage.responseHeaders['content-type']).toMatch(/image\//i)
})

describe('getArticle method', () => {
let dump: Dump
const wikimediaMobileRenderer = new WikimediaMobileRenderer()
Expand Down

0 comments on commit 157c2b9

Please sign in to comment.