Skip to content

Commit

Permalink
test(igxExpansionPanel): fix failing tests due to refactor, #307
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorSlavov committed Sep 12, 2018
1 parent cb26d89 commit b9d5cbb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ export class IgxExpansionPanelComponent {
}

private playOpenAnimation(cb: () => void) {
if (!this.body) { // if not body element is passed, there is nothing to animate
return;
}
const animation = useAnimation(this.animationSettings.openAnimation);
const animationBuilder = this.builder.build(animation);
const openAnimationPlayer = animationBuilder.create(this.body.element.nativeElement.firstElementChild);
Expand All @@ -95,6 +98,9 @@ export class IgxExpansionPanelComponent {
}

private playCloseAnimation(cb: () => void) {
if (!this.body) { // if not body element is passed, there is nothing to animate
return;
}
const animation = useAnimation(this.animationSettings.closeAnimation);
const animationBuilder = this.builder.build(animation);
const closeAnimationPlayer = animationBuilder.create(this.body.element.nativeElement.firstElementChild);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const enum IconPositionClass {
RIGHT = 'igx-expansion-panel__header-icon--end',
NONE = 'igx-expansion-panel__header-icon--none',
}
fdescribe('igxExpansionPanel', () => {
describe('igxExpansionPanel', () => {
beforeEach(async(() => {
// TestBed.resetTestingModule();
TestBed.configureTestingModule({
Expand Down Expand Up @@ -169,7 +169,7 @@ fdescribe('igxExpansionPanel', () => {
expect(button.getAttribute('ng-reflect-icon-name')).toMatch(iconName);
}
if (collapsed) {
expect(panelContainer.lastElementChild.lastElementChild.children.length).toEqual(0);
expect(panelContainer.lastElementChild.children.length).toEqual(0);
} else {
const panelBody = panelContainer.getElementsByTagName(CSS_CLASS_PANEL_BODY)[0];
expect(panelBody).toBeDefined();
Expand Down Expand Up @@ -320,25 +320,25 @@ fdescribe('igxExpansionPanel', () => {
const button = fixture.nativeElement.querySelector('.' + CSS_CLASS_PANEL_ICON) as HTMLElement;
spyOn(panel.onCollapsed, 'emit').and.callThrough();
spyOn(panel.onExpanded, 'emit').and.callThrough();
verifyPanelExpansionState(true, panel, panelContainer, panelHeader, button, 0, 0);
verifyPanelExpansionState(true, panel, panelContainer, panelHeader, button);

panel.collapsed = false;
tick();
fixture.detectChanges();
tick();
verifyPanelExpansionState(false, panel, panelContainer, panelHeader, button, 0 , 1);
verifyPanelExpansionState(false, panel, panelContainer, panelHeader, button);

panel.collapsed = true;
tick();
fixture.detectChanges();
tick();
verifyPanelExpansionState(true, panel, panelContainer, panelHeader, button, 1, 1);
verifyPanelExpansionState(true, panel, panelContainer, panelHeader, button);

panel.collapsed = false;
tick();
fixture.detectChanges();
tick();
verifyPanelExpansionState(false, panel, panelContainer, panelHeader, button, 1, 2);
verifyPanelExpansionState(false, panel, panelContainer, panelHeader, button);
}));
it('Should change panel expansion state using API methods', fakeAsync(() => {
const fixture: ComponentFixture<IgxExpansionPanelListComponent> = TestBed.createComponent(IgxExpansionPanelListComponent);
Expand Down Expand Up @@ -525,7 +525,6 @@ fdescribe('igxExpansionPanel', () => {
tick();
fixture.detectChanges();
tick();
timesExpanded++;
verifyPanelExpansionState(false, panel, panelContainer, panelHeader, button, timesCollapsed, timesExpanded);

panel.toggle();
Expand Down Expand Up @@ -870,7 +869,7 @@ fdescribe('igxExpansionPanel', () => {
expect(bodyWrapper.attributes.getNamedItem('role').nodeValue).toEqual('region');
expect(bodyWrapper.attributes.getNamedItem('aria-label').nodeValue).toEqual(panel.id + '-region');
// expect(bodyWrapper.attributes.getNamedItem('aria-labelledby').nodeValue).toEqual('igx-expansion-panel-header-title-0');
expect(bodyWrapper.childElementCount).toEqual(1);
expect(bodyWrapper.childElementCount).toEqual(0);

header.click();
tick();
Expand Down Expand Up @@ -921,7 +920,7 @@ fdescribe('igxExpansionPanel', () => {
expect(bodyWrapper.attributes.getNamedItem('role').nodeValue).toEqual('region');
expect(bodyWrapper.attributes.getNamedItem('aria-label').nodeValue).toEqual(panel.id + '-region');
// expect(bodyWrapper.attributes.getNamedItem('aria-labelledby').nodeValue).toEqual('igx-expansion-panel-header-title-0');
expect(bodyWrapper.childElementCount).toEqual(1);
expect(bodyWrapper.childElementCount).toEqual(0);

header.click();
tick();
Expand Down Expand Up @@ -979,7 +978,7 @@ fdescribe('igxExpansionPanel', () => {
expect(bodyWrapper.attributes.getNamedItem('role').nodeValue).toEqual('region');
expect(bodyWrapper.attributes.getNamedItem('aria-label').nodeValue).toEqual(panel.id + '-region');
// expect(bodyWrapper.attributes.getNamedItem('aria-labelledby').nodeValue).toEqual('igx-expansion-panel-header-title-0');
expect(bodyWrapper.childElementCount).toEqual(1);
expect(bodyWrapper.childElementCount).toEqual(0);

header.click();
tick();
Expand Down

0 comments on commit b9d5cbb

Please sign in to comment.