From 27bfa1a59616c61b605a6bba41c7cee98c62463e Mon Sep 17 00:00:00 2001 From: Giacomo Ferlaino Date: Fri, 13 Mar 2020 22:27:30 +0100 Subject: [PATCH] feat: Added isVisible method tests --- .../specs/ng2-fittext.directive.spec.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/lib/directives/specs/ng2-fittext.directive.spec.ts b/src/lib/directives/specs/ng2-fittext.directive.spec.ts index 262add9..32c2ce7 100644 --- a/src/lib/directives/specs/ng2-fittext.directive.spec.ts +++ b/src/lib/directives/specs/ng2-fittext.directive.spec.ts @@ -175,4 +175,23 @@ describe('Class: Ng2FittextDirective', () => { expect(ng2FittextDirective.isDone()).toBe(defaultDoneValue); }); }); + + describe('Method: isVisible', () => { + it('Should return the true if getStartFontSizeFromHeight() is greater than zero', () => { + spyOn(ng2FittextDirective, 'getStartFontSizeFromHeight').and.returnValue( + 1 + ); + expect(ng2FittextDirective.isVisible()).toBe(true); + }); + + it('Should return the false if getStartFontSizeFromHeight() is smaller or equal to zero', () => { + const spy = spyOn( + ng2FittextDirective, + 'getStartFontSizeFromHeight' + ).and.returnValue(0); + expect(ng2FittextDirective.isVisible()).toBe(false); + spy.and.returnValue(-1); + expect(ng2FittextDirective.isVisible()).toBe(false); + }); + }); });