mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
committed by
Eugenio Romano
parent
53d96679ea
commit
e39a2b149b
@@ -23,6 +23,7 @@ import { HighlightDirective } from './highlight.directive';
|
||||
import { setupTestBed } from '../testing/setupTestBed';
|
||||
import { CoreModule } from '../core.module';
|
||||
|
||||
/* spellchecker: disable */
|
||||
const template: string = `
|
||||
<div id="outerDiv1" adf-highlight adf-highlight-selector=".highlightable" adf-highlight-class="highlight-for-free-willy">
|
||||
<div id="innerDiv11" class="highlightable">Lorem ipsum salana-eyong-aysis dolor sit amet</div>
|
||||
@@ -36,7 +37,7 @@ const template: string = `
|
||||
|
||||
@Component({ selector: 'adf-test-component', template })
|
||||
class TestComponent {
|
||||
@ViewChildren(HighlightDirective) public hightlightDirectives;
|
||||
@ViewChildren(HighlightDirective) public highlightDirectives;
|
||||
}
|
||||
|
||||
describe('HighlightDirective', () => {
|
||||
@@ -59,8 +60,8 @@ describe('HighlightDirective', () => {
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should replace the searched text with the default hightlight class in the proper element (adf-highlight-selector)', () => {
|
||||
component.hightlightDirectives.last.highlight('salana-eyong-aysis');
|
||||
it('should replace the searched text with the default highlight class in the proper element (adf-highlight-selector)', () => {
|
||||
component.highlightDirectives.last.highlight('salana-eyong-aysis');
|
||||
fixture.detectChanges();
|
||||
|
||||
const containerElement = fixture.debugElement.query(By.css('#innerDiv21'));
|
||||
@@ -68,8 +69,8 @@ describe('HighlightDirective', () => {
|
||||
expect(containerElement.nativeElement.innerHTML).toBe('Lorem ipsum <span class="adf-highlight">salana-eyong-aysis</span> dolor sit amet');
|
||||
});
|
||||
|
||||
it('should replace the searched text with the default hightlight class in every proper element (highlight-for-free-willy)', () => {
|
||||
component.hightlightDirectives.first.highlight('salana-eyong-aysis');
|
||||
it('should replace the searched text with the default highlight class in every proper element (highlight-for-free-willy)', () => {
|
||||
component.highlightDirectives.first.highlight('salana-eyong-aysis');
|
||||
fixture.detectChanges();
|
||||
|
||||
const containerElement1 = fixture.debugElement.query(By.css('#innerDiv11'));
|
||||
@@ -81,7 +82,7 @@ describe('HighlightDirective', () => {
|
||||
});
|
||||
|
||||
it('should NOT replace the searched text in an element without the proper selector class', () => {
|
||||
component.hightlightDirectives.first.highlight('salana-eyong-aysis');
|
||||
component.highlightDirectives.first.highlight('salana-eyong-aysis');
|
||||
fixture.detectChanges();
|
||||
|
||||
const containerElement1 = fixture.debugElement.query(By.css('#innerDiv12'));
|
||||
@@ -92,7 +93,7 @@ describe('HighlightDirective', () => {
|
||||
it('should NOT reinsert the same text to the innerText if there was no change at all (search string is not found)', () => {
|
||||
const highlighter = TestBed.get(HighlightTransformService);
|
||||
spyOn(highlighter, 'highlight').and.returnValue({ changed: false, text: 'Modified text' });
|
||||
component.hightlightDirectives.first.highlight('salana-eyong-aysis');
|
||||
component.highlightDirectives.first.highlight('salana-eyong-aysis');
|
||||
fixture.detectChanges();
|
||||
|
||||
const containerElement = fixture.debugElement.query(By.css('#innerDiv11'));
|
||||
@@ -103,7 +104,7 @@ describe('HighlightDirective', () => {
|
||||
it('should do the search only if there is a search string presented', () => {
|
||||
const highlighter = TestBed.get(HighlightTransformService);
|
||||
spyOn(highlighter, 'highlight').and.callThrough();
|
||||
component.hightlightDirectives.first.highlight('');
|
||||
component.highlightDirectives.first.highlight('');
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(highlighter.highlight).not.toHaveBeenCalled();
|
||||
@@ -114,7 +115,7 @@ describe('HighlightDirective', () => {
|
||||
spyOn(highlighter, 'highlight').and.callThrough();
|
||||
|
||||
const callback = function() {
|
||||
component.hightlightDirectives.first.highlight('raddish', '');
|
||||
component.highlightDirectives.first.highlight('raddish', '');
|
||||
fixture.detectChanges();
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user