const { JSDOM } = require("jsdom"); const sampleFeed = require("fs") .readFileSync(__dirname + "/fixtures/contentful.rss.xml") .toString(); const sampleFeedParsed = require("./fixtures/contentful.rss.json"); const { expect } = require("chai"); const fetch = require("node-fetch"); const moment = (global.moment = require("moment")); const { stub } = require("sinon"); const { version } = require("../package.json"); describe("jquery.rss", () => { let $, element, originalAjax; const feedUrl = "https://www.contentful.com/blog/feed.xml"; const fakeGetJson = content => { originalAjax = $.ajax; $.ajax = function({ url, success }) { success({ responseData: { feed: { entries: [ { content: content, contentSnippet: content } ] } } }); }; }; before(() => { const { window, document } = new JSDOM(``); global.window = window; global.document = window.document; $ = global.jQuery = require("jquery"); require("../dist/jquery.rss.min"); }); beforeEach(() => { element = $("
").appendTo($("body")); }); afterEach(() => { if (typeof originalAjax === "function") { $.ajax = originalAjax; originalAjax = null; } }); it("supports multiple rss feeds", done => { originalAjax = $.ajax; $.ajax = function({ url, success }) { expect(url).to.include( "q=https%3A%2F%2Fwww.contentful.com%2Fblog%2Ffeed.xml,http%3A%2F%2Fwww.ebaytechblog.com%2Ffeed%2F" ); done(); }; var $container = element; $container.rss([ "https://www.contentful.com/blog/feed.xml", "http://www.ebaytechblog.com/feed/" ]); }); it("renders an unordered list by default", function(done) { var $container = element; $container.rss(feedUrl, {}, function() { var renderedContent = $container.html().replace(/\n/g, ""); expect(renderedContent).to.match(/