diff --git a/test/01_standardParsing.test.js b/test/01_standardParsing.test.js index 2bec299d..041c4ae6 100644 --- a/test/01_standardParsing.test.js +++ b/test/01_standardParsing.test.js @@ -1,6 +1,5 @@ import fs from 'fs'; import * as path from 'path'; -import fetch from 'node-fetch'; import { expect } from 'chai'; import { loadEPUB } from '../dist/node/index.js'; @@ -8,61 +7,61 @@ const list = JSON.parse(await fs.promises.readFile(new URL('./standardParsing/li const JW_CDN = 'https://app.jw-cdn.org/apis/pub-media/GETPUBMEDIALINKS?'; const fetchData = async (language, issue, pub) => { - let data = []; - let fixture = []; + let data = []; + let fixture = []; - const url = - JW_CDN + - new URLSearchParams({ - langwritten: language, - pub, - fileformat: 'epub', - output: 'json', - issue, - }); + const url = + JW_CDN + + new URLSearchParams({ + langwritten: language, + pub, + fileformat: 'epub', + output: 'json', + issue, + }); - const res = await fetch(url); + const res = await fetch(url); - if (res.status === 200) { - const result = await res.json(); - const epubEntry = result.files[language].EPUB; + if (res.status === 200) { + const result = await res.json(); + const epubEntry = result.files[language].EPUB; - const epubFile = epubEntry[0].file; - const epubUrl = epubFile.url; - const epubName = path.basename(epubUrl); - data = await loadEPUB({ url: epubUrl }); - fixture = (await import(`./fixtures/${epubName.replace('.epub', '.js')}`)).default; - } + const epubFile = epubEntry[0].file; + const epubUrl = epubFile.url; + const epubName = path.basename(epubUrl); + data = await loadEPUB({ url: epubUrl }); + fixture = (await import(`./fixtures/${epubName.replace('.epub', '.js')}`)).default; + } - return { data, fixture }; + return { data, fixture }; }; describe('Testing Standard Parsing', () => { - for (let i = 0; i < list.length; i++) { - const { language, issue } = list[i]; + for (let i = 0; i < list.length; i++) { + const { language, issue } = list[i]; - describe(`Test loadEPUB function for ${language} language`, async () => { - it(`Parsing Meeting Workbook EPUB file`, async () => { - const { data, fixture } = await fetchData(language, issue, 'mwb'); + describe(`Test loadEPUB function for ${language} language`, async () => { + it(`Parsing Meeting Workbook EPUB file`, async () => { + const { data, fixture } = await fetchData(language, issue, 'mwb'); - for (let a = 0; a < fixture.length; a++) { - const week = fixture[a]; - for (let [key, value] of Object.entries(week)) { - expect(data[a]).to.have.property(key).equal(value); - } - } - }); + for (let a = 0; a < fixture.length; a++) { + const week = fixture[a]; + for (let [key, value] of Object.entries(week)) { + expect(data[a]).to.have.property(key).equal(value); + } + } + }); - it(`Parsing Watchtower Study EPUB file`, async () => { - const { data, fixture } = await fetchData(language, issue, 'w'); + it(`Parsing Watchtower Study EPUB file`, async () => { + const { data, fixture } = await fetchData(language, issue, 'w'); - for (let a = 0; a < fixture.length; a++) { - const week = fixture[a]; - for (let [key, value] of Object.entries(week)) { - expect(data[a]).to.have.property(key).equal(value); - } - } - }); - }); - } + for (let a = 0; a < fixture.length; a++) { + const week = fixture[a]; + for (let [key, value] of Object.entries(week)) { + expect(data[a]).to.have.property(key).equal(value); + } + } + }); + }); + } }); diff --git a/test/02_enhancedParsing.test.js b/test/02_enhancedParsing.test.js index e7cd5b74..8dd36b11 100644 --- a/test/02_enhancedParsing.test.js +++ b/test/02_enhancedParsing.test.js @@ -1,6 +1,5 @@ import fs from 'fs'; import * as path from 'path'; -import fetch from 'node-fetch'; import { expect } from 'chai'; import { loadEPUB } from '../dist/node/index.js';