Compare commits

..

1 Commits

Author SHA1 Message Date
d1992274cb Test enhancement (fix given / when / then) 2021-07-06 14:52:58 +02:00

View File

@ -416,26 +416,32 @@ describe("test class RSS: jsonfile", function () {
// when
myListener.start();
await clock.tickAsync(1);
// 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);
// then
// when
await clock.tickAsync(60000);
// then
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
newEntriesListenerSpy.resetHistory();
// then
// when
await clock.tickAsync(60000);
// then
expect(updateListenerSpy).to.have.been.calledThrice;
expect(updateListenerSpy).to.have.been.calledWith(mockedRSSOutput);
expect(newEntriesListenerSpy).to.not.have.been.called;
@ -482,17 +488,20 @@ describe("test class RSS: jsonfile", function () {
// when
myListener.start();
await clock.tickAsync(1);
// then
await clock.tickAsync(1);
expect(updateListenerSpy).to.have.been.calledOnce;
expect(newEntriesListenerSpy).to.not.have.been.calledOnce;
// given
stubParser.resolves(newRSSOutput);
// then
// when
await clock.tickAsync(60000);
// then
expect(updateListenerSpy).to.have.been.calledTwice;
expect(newEntriesListenerSpy).to.have.been.calledOnce;
expect(newEntriesListenerSpy).to.have.been.calledWith([newEntry]);
@ -500,8 +509,10 @@ describe("test class RSS: jsonfile", function () {
// given
newEntriesListenerSpy.resetHistory();
// then
// when
await clock.tickAsync(60000);
// then
expect(updateListenerSpy).to.have.been.calledThrice;
expect(updateListenerSpy).to.have.been.calledWith(mockedRSSOutput);
expect(newEntriesListenerSpy).to.not.have.been.called;