Skip to content

Commit

Permalink
chore: update test
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Nov 2, 2023
1 parent 26604a3 commit 76be37f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Simple, easy and performance countdown for angular

[![NPM version](https://img.shields.io/npm/v/ngx-countdown.svg)](https://www.npmjs.com/package/ngx-countdown)
[![Ci](https://github.com/cipchk/ngx-countdown/workflows/Ci/badge.svg)](https://github.com/cipchk/ngx-countdown/actions?query=workflow%3ACi)
[![codecov](https://codecov.io/github/cipchk/ngx-countdown/graph/badge.svg?token=SPQeYvppgH)](https://codecov.io/github/cipchk/ngx-countdown)

## Demo

Expand Down
25 changes: 25 additions & 0 deletions lib/spec/component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,31 @@ describe('Component: ngx-countdown', () => {
expect(context.comp.i.text).toBe(`0`);
tick(2000);
}));
it('Support fractional seconds', fakeAsync(() => {
context.config = { leftTime: 2, format: 'S' };
fixture.detectChanges();
tick(250);
fixture.detectChanges();
expect(context.comp.i.value).toBeGreaterThan(1001);
tick(2000);
}));
it('Pretty text', fakeAsync(() => {
context.config = { leftTime: 2, prettyText: jasmine.createSpy() };
fixture.detectChanges();
tick(250);
fixture.detectChanges();
expect(context.config.prettyText).toHaveBeenCalled();
tick(2000);
}));
describe('#stopTime', () => {
it('should be working', fakeAsync(() => {
context.config = { stopTime: new Date().getTime() + 1000 * 2 };
fixture.detectChanges();
tick(1001);
expect(context.comp.left).toBe(1000);
tick(3000);
}));
});
});

describe('[actions]', () => {
Expand Down

0 comments on commit 76be37f

Please sign in to comment.