Added Ng2FittextDirective class unit tests #32
2 changed files with 25 additions and 1 deletions
|
|
@ -137,7 +137,7 @@ export class Ng2FittextDirective
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getStartFontSizeFromHeight(): number {
|
getStartFontSizeFromHeight(): number {
|
||||||
return this.container
|
return this.container
|
||||||
? this.container.clientHeight
|
? this.container.clientHeight
|
||||||
: this.el.nativeElement.parentElement.clientHeight;
|
: this.el.nativeElement.parentElement.clientHeight;
|
||||||
|
|
|
||||||
|
|
@ -144,4 +144,28 @@ describe('Class: Ng2FittextDirective', () => {
|
||||||
).toBe(true);
|
).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Method: getStartFontSizeFromHeight', () => {
|
||||||
|
it('Should return the container clientHeight value if the container is present', () => {
|
||||||
|
const containerClientHeight = 10;
|
||||||
|
ng2FittextDirective.container = {
|
||||||
|
clientHeight: containerClientHeight,
|
||||||
|
} as HTMLElement;
|
||||||
|
expect(ng2FittextDirective.getStartFontSizeFromHeight()).toEqual(
|
||||||
|
containerClientHeight
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should return the parentElement clientHeight value if no container is present', () => {
|
||||||
|
const parentlientHeight = 11;
|
||||||
|
elMock.nativeElement = {
|
||||||
|
parentElement: {
|
||||||
|
clientHeight: parentlientHeight,
|
||||||
|
},
|
||||||
|
} as HTMLElement;
|
||||||
|
expect(ng2FittextDirective.getStartFontSizeFromHeight()).toEqual(
|
||||||
|
parentlientHeight
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue