Skip to content

Commit

Permalink
test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
latin-panda committed Oct 8, 2024
1 parent 55e7058 commit 9d6dc1c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions webapp/tests/karma/ts/services/training-cards.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -771,4 +771,39 @@ describe('TrainingCardsService', () => {
.to.equal('Training Cards :: Cannot create document ID, user context does not have the "name" property.');
}
});

describe('Display training cards once', () => {
afterEach(() => window.localStorage.removeItem('training-cards-last-viewed-date'));

it('should display training when it has not been displayed today', async () => {
routeSnapshotService.get.returns({ data: { hideTraining: false } });
window.localStorage.setItem('training-cards-last-viewed-date', '2024-05-23 20:29:25');
clock = sinon.useFakeTimers(new Date('2025-05-25 20:29:25'));

service.displayTrainingCards();

expect(modalService.show.calledOnce).to.be.true;
});

it('should display training when last viewed date is empty', async () => {
routeSnapshotService.get.returns({ data: { hideTraining: false } });
window.localStorage.setItem('training-cards-last-viewed-date', '');
clock = sinon.useFakeTimers(new Date('2025-05-25 20:29:25'));

service.displayTrainingCards();

expect(modalService.show.calledOnce).to.be.true;
});

it('should not display training when it has been displayed today', async () => {
routeSnapshotService.get.returns({ data: { hideTraining: false } });
window.localStorage.setItem('training-cards-last-viewed-date', '2024-05-23 20:29:25');
clock = sinon.useFakeTimers(new Date('2024-05-23 06:29:25'));

service.displayTrainingCards();

expect(modalService.show.notCalled).to.be.true;
});
});

});

0 comments on commit 9d6dc1c

Please sign in to comment.