diff --git a/tests/index-spec.ts b/tests/index-spec.ts index 49563f5..6ace843 100644 --- a/tests/index-spec.ts +++ b/tests/index-spec.ts @@ -119,7 +119,6 @@ describe("test class GestionListener", function () { const ml = new ManageListener({ path: "tests/RessourcesTest/RealRessources/save_no_history.json", }); - const fileConfig = require("./RessourcesTest/RealRessources/save_no_history.json"); const spy = sinon.spy(); @@ -130,39 +129,35 @@ describe("test class GestionListener", function () { ]; ml.on("update", spy); - - fileConfig.forEach((_: any, i: number) => { + tabChannelId.forEach((item: string) => { nock("https://www.youtube.com") - .get(`/feeds/videos.xml?channel_id=${tabChannelId[i]}`) + .get(`/feeds/videos.xml?channel_id=${item}`) .replyWithFile( 200, - path.join( - __dirname, - `RessourcesTest/RealRessources/${tabChannelId[i]}.rss` - ), + path.join(__dirname, `RessourcesTest/RealRessources/${item}.rss`), { "content-type": "text/xml", charset: "utf-8" } ); }); // when ml.startAll(); + + await clock.tickAsync(2); await events.once(ml, "update"); //expect expect(spy).to.have.been.calledThrice; - console.log("first assertion pass"); - // given spy.resetHistory(); // when - await clock.tickAsync(10000); - await events.once(ml, "update"); + await clock.tickAsync(12000); + ml.stopAll(); //expect - // expect(spy).to.have.been.calledOnce; + expect(spy).to.have.been.calledOnce; }); it("should call correctly the events with a new entry (no aggregation)", function () {});