From b70025bfdc5f3d7aa3e827f6cadfa1e21483a038 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 6 Apr 2021 10:25:21 +0200 Subject: Remove libxmljs in favour of pure JS implem --- server/tests/feeds/feeds.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'server/tests/feeds') diff --git a/server/tests/feeds/feeds.ts b/server/tests/feeds/feeds.ts index f1055ea44..7bad81751 100644 --- a/server/tests/feeds/feeds.ts +++ b/server/tests/feeds/feeds.ts @@ -2,7 +2,7 @@ import 'mocha' import * as chai from 'chai' -import * as libxmljs from 'libxmljs' +import * as xmlParser from 'fast-xml-parser' import { addAccountToAccountBlocklist, addAccountToServerBlocklist, @@ -139,12 +139,15 @@ describe('Test syndication feeds', () => { it('Should contain a valid enclosure (covers RSS 2.0 endpoint)', async function () { for (const server of servers) { const rss = await getXMLfeed(server.url, 'videos') - const xmlDoc = libxmljs.parseXmlString(rss.text) - const xmlEnclosure = xmlDoc.get('/rss/channel/item/enclosure') - expect(xmlEnclosure).to.exist - expect(xmlEnclosure.attr('type').value()).to.be.equal('application/x-bittorrent') - expect(xmlEnclosure.attr('length').value()).to.be.equal('218910') - expect(xmlEnclosure.attr('url').value()).to.contain('720.torrent') + expect(xmlParser.validate(rss.text)).to.be.true + + const xmlDoc = xmlParser.parse(rss.text, { parseAttributeValue: true, ignoreAttributes: false }) + + const enclosure = xmlDoc.rss.channel.item[0].enclosure + expect(enclosure).to.exist + expect(enclosure['@_type']).to.equal('application/x-bittorrent') + expect(enclosure['@_length']).to.equal(218910) + expect(enclosure['@_url']).to.contain('720.torrent') } }) -- cgit v1.2.3