Skip to content

Commit

Permalink
fix(page-slide): cobre teste para pageContent
Browse files Browse the repository at this point in the history
  • Loading branch information
felipepetuco authored and CSimoesJr committed Mar 25, 2024
1 parent b4ee54a commit 6c68f55
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, DebugElement, ViewChild } from '@angular/core';
import { Component, DebugElement, ElementRef, ViewChild } from '@angular/core';
import { ComponentFixture, fakeAsync, flush, TestBed, tick, waitForAsync } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
Expand Down Expand Up @@ -238,4 +238,18 @@ describe('PoPageSlideComponent', () => {
component.close();
expect(component['sourceElement'].focus).toHaveBeenCalled();
});

it('should have pageContent.nativeElement defined', () => {
const div = document.createElement('div');
div.setAttribute('tabindex', '-1');

const mockElementRef = {
nativeElement: div
} as ElementRef;

component.pageContent = mockElementRef;
component['initFocus']();

expect(component.pageContent.nativeElement).toBeDefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ export class PoPageSlideComponent extends PoPageSlideBaseComponent {
this.firstElement.focus();
} else {
const elements = getFocusableElements(this.pageContent.nativeElement);
/* istanbul ignore next */
const element = elements[0] || this.pageContent.nativeElement;
element.focus();
}
Expand Down

0 comments on commit 6c68f55

Please sign in to comment.