Added Ng2FittextDirective class unit tests #32

Merged
giacomoferlaino merged 11 commits from master into master 2020-03-16 11:28:52 +00:00
2 changed files with 9 additions and 1 deletions
Showing only changes of commit afa67c729b - Show all commits

View file

@ -58,7 +58,7 @@ export class Ng2FittextDirective
return this.fontSize; return this.fontSize;
} }
calculateFontSize(fontSize: number, speed: number) { calculateFontSize(fontSize: number, speed: number): number {
return Math.floor(fontSize / speed); return Math.floor(fontSize / speed);
} }

View file

@ -93,4 +93,12 @@ describe('Class: Ng2FittextDirective', () => {
expect(ng2FittextDirective.getFontSize()).toEqual(1000); expect(ng2FittextDirective.getFontSize()).toEqual(1000);
}); });
}); });
describe('Method: calculateFontSize', () => {
it('Should return the font size rounded down', () => {
expect(ng2FittextDirective.calculateFontSize(10, 3)).toEqual(3);
expect(ng2FittextDirective.calculateFontSize(9, 3)).toEqual(3);
expect(ng2FittextDirective.calculateFontSize(8, 3)).toEqual(2);
});
});
}); });