modif test startAll

This commit is contained in:
Amaury Joly 2021-04-06 13:30:29 +02:00
parent 3afaee06e1
commit 6c9c49dbba

View File

@ -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 () {});