diff --git a/src/listener-rss.ts b/src/listener-rss.ts index f72011c..db49208 100644 --- a/src/listener-rss.ts +++ b/src/listener-rss.ts @@ -1,5 +1,8 @@ import Parser from "rss-parser"; -import { ListenerRSSInfos as ListenerInfo } from "./Models/ListenerRSSInfos"; +import { + ListenerRSSInfos as ListenerInfo, + ListenerRSSInfos, +} from "./Models/ListenerRSSInfos"; import EventEmitter from "events"; const DEFAULT_TIMELOOP: number = 5 * 60; // default timeloop is 5 min @@ -10,7 +13,6 @@ const DEFAULT_TIMELOOP: number = 5 * 60; // default timeloop is 5 min * Emit 'newEntries' when the fetch has new entris */ export class ListenerRss extends EventEmitter { - name: string = ""; address: string = ""; timeloop: number = DEFAULT_TIMELOOP; // time in seconds customfields?: { [key: string]: string[] | string }; @@ -103,4 +105,17 @@ export class ListenerRss extends EventEmitter { stop(): void { this.loopRunning = false; } + + /** + * @brief parse the datas inti a ListenerRSSInfos object + * @return return a ListenerRSSInfos object + */ + getProperty(): ListenerRSSInfos { + return { + address: this.address, + customfields: this.customfields, + lastEntriesLinks: this.lastEntriesLinks, + timeloop: this.timeloop, + }; + } } diff --git a/tests/index-spec.ts b/tests/index-spec.ts index 279d156..8ddef98 100644 --- a/tests/index-spec.ts +++ b/tests/index-spec.ts @@ -195,6 +195,16 @@ describe("test class RSS: jsonfile", function () { }); }); + describe("export property", function () { + it("should export properties into a ListenerRSSInfos", function () { + // given + const myListener = new Listeners(infosListener); + + // assertions + expect(myListener.getProperty()).to.be.eql(infosListener); + }); + }); + describe("data fetching", function () { it("fetches without issues", async function () { // given