|
|
|
@ -1,5 +1,6 @@ |
|
|
|
import { createDirectiveFactory, SpectatorDirective } from '@ngneat/spectator/vitest'; |
|
|
|
import { EllipsisDirective } from '../directives/ellipsis.directive'; |
|
|
|
import { setInputSignal } from './utils'; |
|
|
|
|
|
|
|
describe('EllipsisDirective', () => { |
|
|
|
let spectator: SpectatorDirective<EllipsisDirective>; |
|
|
|
@ -13,12 +14,13 @@ describe('EllipsisDirective', () => { |
|
|
|
spectator = createDirective( |
|
|
|
'<div [abpEllipsis]="width" [abpEllipsisEnabled]="true" [title]="title">test content</div>', |
|
|
|
{ |
|
|
|
hostProps: { |
|
|
|
title: 'test title', |
|
|
|
width: '100px', |
|
|
|
}, |
|
|
|
detectChanges: false, |
|
|
|
}, |
|
|
|
); |
|
|
|
setInputSignal(spectator.directive.width, '100px'); |
|
|
|
setInputSignal(spectator.directive.enabled, true); |
|
|
|
setInputSignal(spectator.directive.title, 'title'); |
|
|
|
spectator.detectChanges(); |
|
|
|
directive = spectator.directive; |
|
|
|
el = spectator.query('div'); |
|
|
|
}); |
|
|
|
@ -28,15 +30,15 @@ describe('EllipsisDirective', () => { |
|
|
|
}); |
|
|
|
|
|
|
|
test('should have 100px ellipsis width', () => { |
|
|
|
expect(directive.width).toBe('100px'); |
|
|
|
expect(directive.width()).toBe('100px'); |
|
|
|
}); |
|
|
|
|
|
|
|
test('should be enabled if abpEllipsisEnabled input is true', () => { |
|
|
|
expect(directive.enabled).toBe(true); |
|
|
|
expect(directive.enabled()).toBe(true); |
|
|
|
}); |
|
|
|
|
|
|
|
test('should have given title', () => { |
|
|
|
expect(directive.title).toBe('test title'); |
|
|
|
expect(directive.title()).toBe('title'); |
|
|
|
}); |
|
|
|
|
|
|
|
test('should add abp-ellipsis-inline class to element if width is given', () => { |
|
|
|
@ -48,6 +50,7 @@ describe('EllipsisDirective when title is not specified', () => { |
|
|
|
let spectator: SpectatorDirective<EllipsisDirective>; |
|
|
|
let directive: EllipsisDirective; |
|
|
|
let el: HTMLDivElement; |
|
|
|
|
|
|
|
const createDirective = createDirectiveFactory({ |
|
|
|
directive: EllipsisDirective, |
|
|
|
}); |
|
|
|
@ -62,12 +65,16 @@ describe('EllipsisDirective when title is not specified', () => { |
|
|
|
}, |
|
|
|
}, |
|
|
|
); |
|
|
|
setInputSignal(spectator.directive.width, '100px'); |
|
|
|
setInputSignal(spectator.directive.enabled, true); |
|
|
|
setInputSignal(spectator.directive.title, undefined); |
|
|
|
spectator.detectChanges(); |
|
|
|
directive = spectator.directive; |
|
|
|
el = spectator.query('div') as HTMLDivElement; |
|
|
|
}); |
|
|
|
|
|
|
|
test('should have element innerText as title', () => { |
|
|
|
expect(directive.title).toBe(el.innerText); |
|
|
|
expect(directive.title()).toBe(el.innerText); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
@ -89,6 +96,10 @@ describe('EllipsisDirective when width is not given', () => { |
|
|
|
}, |
|
|
|
}, |
|
|
|
); |
|
|
|
setInputSignal(spectator.directive.width, undefined); |
|
|
|
setInputSignal(spectator.directive.enabled, true); |
|
|
|
setInputSignal(spectator.directive.title, 'test title'); |
|
|
|
spectator.detectChanges(); |
|
|
|
directive = spectator.directive; |
|
|
|
el = spectator.query('div') as HTMLDivElement; |
|
|
|
}); |
|
|
|
|