|
|
|
@ -5,7 +5,7 @@ import * as Parser from "rss-parser";
|
|
|
|
|
import {
|
|
|
|
|
ListenerRSSInfos as ListenerRRSInfo,
|
|
|
|
|
ListenerRss as Listeners,
|
|
|
|
|
} from "./../src/index";
|
|
|
|
|
} from "../";
|
|
|
|
|
|
|
|
|
|
// Unit test
|
|
|
|
|
import assert from "assert";
|
|
|
|
@ -20,7 +20,6 @@ const expect = chai.expect;
|
|
|
|
|
|
|
|
|
|
describe("test class RSS: jsonfile", function () {
|
|
|
|
|
const infosListener: ListenerRRSInfo = {
|
|
|
|
|
name: "my-test-service",
|
|
|
|
|
address: "fake.rss.service",
|
|
|
|
|
timeloop: 15,
|
|
|
|
|
customfields: {
|
|
|
|
@ -74,7 +73,6 @@ describe("test class RSS: jsonfile", function () {
|
|
|
|
|
// assertions
|
|
|
|
|
// myListener data
|
|
|
|
|
expect(myListener.timeloop).to.eql(15);
|
|
|
|
|
expect(myListener.name).to.eql("my-test-service");
|
|
|
|
|
expect(myListener.address).to.eql("fake.rss.service");
|
|
|
|
|
expect(myListener.customfields).to.eql({
|
|
|
|
|
description: ["media:group", "media:description"],
|
|
|
|
@ -91,7 +89,6 @@ describe("test class RSS: jsonfile", function () {
|
|
|
|
|
|
|
|
|
|
it("builds without issues (raw infos : 4 params)", function () {
|
|
|
|
|
const myListener = new Listeners({
|
|
|
|
|
name: "my-test-service",
|
|
|
|
|
address: "fake.rss.service",
|
|
|
|
|
timeloop: 15,
|
|
|
|
|
customfields: {
|
|
|
|
@ -103,7 +100,6 @@ describe("test class RSS: jsonfile", function () {
|
|
|
|
|
// assertions
|
|
|
|
|
// myListener data
|
|
|
|
|
expect(myListener.timeloop).to.eql(15);
|
|
|
|
|
expect(myListener.name).to.eql("my-test-service");
|
|
|
|
|
expect(myListener.address).to.eql("fake.rss.service");
|
|
|
|
|
expect(myListener.customfields).to.eql({
|
|
|
|
|
description: ["media:group", "media:description"],
|
|
|
|
@ -120,14 +116,12 @@ describe("test class RSS: jsonfile", function () {
|
|
|
|
|
|
|
|
|
|
it("builds without issues (raw infos : just 2 params)", function () {
|
|
|
|
|
const myListener = new Listeners({
|
|
|
|
|
name: "my-test-service",
|
|
|
|
|
address: "fake.rss.service",
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// assertions
|
|
|
|
|
// myListener data
|
|
|
|
|
expect(myListener.timeloop).to.eql(5 * 60);
|
|
|
|
|
expect(myListener.name).to.eql("my-test-service");
|
|
|
|
|
expect(myListener.address).to.eql("fake.rss.service");
|
|
|
|
|
expect(myListener.customfields).to.eql(undefined);
|
|
|
|
|
expect(myListener.parser)
|
|
|
|
@ -142,7 +136,6 @@ describe("test class RSS: jsonfile", function () {
|
|
|
|
|
|
|
|
|
|
it("builds without issues (raw infos: just 3 params (no custom fields))", function () {
|
|
|
|
|
const myListener = new Listeners({
|
|
|
|
|
name: "my-test-service",
|
|
|
|
|
address: "fake.rss.service",
|
|
|
|
|
timeloop: 15,
|
|
|
|
|
});
|
|
|
|
@ -150,7 +143,6 @@ describe("test class RSS: jsonfile", function () {
|
|
|
|
|
// assertions
|
|
|
|
|
// myListener data
|
|
|
|
|
expect(myListener.timeloop).to.eql(15);
|
|
|
|
|
expect(myListener.name).to.eql("my-test-service");
|
|
|
|
|
expect(myListener.address).to.eql("fake.rss.service");
|
|
|
|
|
expect(myListener.customfields).to.eql(undefined);
|
|
|
|
|
expect(myListener.parser)
|
|
|
|
@ -164,7 +156,6 @@ describe("test class RSS: jsonfile", function () {
|
|
|
|
|
|
|
|
|
|
it("The build without issues (raw infos : just 3 params (no timeloop))", function () {
|
|
|
|
|
const myListener = new Listeners({
|
|
|
|
|
name: "my-test-service",
|
|
|
|
|
address: "fake.rss.service",
|
|
|
|
|
customfields: {
|
|
|
|
|
description: ["media:group", "media:description"],
|
|
|
|
@ -175,7 +166,6 @@ describe("test class RSS: jsonfile", function () {
|
|
|
|
|
// assertions
|
|
|
|
|
// myListener data
|
|
|
|
|
expect(myListener.timeloop).to.eql(5 * 60);
|
|
|
|
|
expect(myListener.name).to.eql("my-test-service");
|
|
|
|
|
expect(myListener.address).to.eql("fake.rss.service");
|
|
|
|
|
expect(myListener.customfields).to.eql({
|
|
|
|
|
description: ["media:group", "media:description"],
|
|
|
|
@ -220,7 +210,6 @@ describe("test class RSS: jsonfile", function () {
|
|
|
|
|
stubParser.rejects(err);
|
|
|
|
|
|
|
|
|
|
const myListener = new Listeners({
|
|
|
|
|
name: "my-test-service",
|
|
|
|
|
address: "bad.rss.service",
|
|
|
|
|
customfields: {
|
|
|
|
|
description: ["media:group", "media:description"],
|
|
|
|
@ -409,7 +398,7 @@ describe("test class RSS: jsonfile", function () {
|
|
|
|
|
// then
|
|
|
|
|
await clock.tickAsync(1);
|
|
|
|
|
expect(updateListenerSpy).to.have.been.calledOnce;
|
|
|
|
|
expect(newEntriesListenerSpy).to.not.have.been.called;
|
|
|
|
|
expect(newEntriesListenerSpy).to.have.been.calledOnce;
|
|
|
|
|
|
|
|
|
|
// given
|
|
|
|
|
stubParser.resolves(newRSSOutput);
|
|
|
|
@ -417,7 +406,7 @@ describe("test class RSS: jsonfile", function () {
|
|
|
|
|
// then
|
|
|
|
|
await clock.tickAsync(60000);
|
|
|
|
|
expect(updateListenerSpy).to.have.been.calledTwice;
|
|
|
|
|
expect(newEntriesListenerSpy).to.have.been.calledOnce;
|
|
|
|
|
expect(newEntriesListenerSpy).to.have.been.calledTwice;
|
|
|
|
|
expect(newEntriesListenerSpy).to.have.been.calledWith([newEntry]);
|
|
|
|
|
|
|
|
|
|
// given
|
|
|
|
|