const chai = require("chai"); const sinon = require("sinon"); const proxyquire = require("proxyquire"); const Parser = require("rss-parser"); const expect = chai.expect; describe("RSS Youtube", function () { let rssYoutubeService; let timecode; let routage; let parseUrlStub; let mockedInput = { items: [ { id: "::account", url: isoDate: Date.now().toISOString(), "media:group": { "media:description": [ "my description" ] } ] }; beforeEach(function () { timecode = { "lastCheck": "2020-11-12T17:44:11.713Z", "MyUser": "2020-11-12T17:44:11.713Z" }; routage = { log: sinon.stub(), send: sinon.stub() }; parseUrlStub = sinon.stub(Parser.prototype, "parseURL") .callsFake((_, callback) => callback(null, "data")); rssYoutubeService = proxyquire("../services/rss-youtube", { "../modules/routage": () => routage, "../db/rss-youtube.json": { config: { timeLoop: 5, urlFeeds: "https://www.youtube.com/feeds/videos.xml?channel_id=", sliceDescription: 142 }, feeds: { MyUser: "Some channel" }, timecode } }); }); afterEach(function () { Parser.prototype.parseURL.reset(); }); });