Skip to content

Commit 9687d06

Browse files
committed
chore: add a couple of unit tests for the fixes
1 parent ff4ea0a commit 9687d06

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/lib/expansion/expansion.spec.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,46 @@ describe('MdExpansionPanel', () => {
7676
button.focus();
7777
expect(document.activeElement).not.toBe(button, 'Expected button to no longer be focusable.');
7878
}));
79+
80+
it('should be able to hide the toggle', () => {
81+
const fixture = TestBed.createComponent(PanelWithContent);
82+
const header = fixture.debugElement.query(By.css('.mat-expansion-panel-header')).nativeElement;
83+
84+
fixture.detectChanges();
85+
86+
expect(header.querySelector('.mat-expansion-indicator'))
87+
.toBeTruthy('Expected indicator to be shown.');
88+
89+
fixture.componentInstance.hideToggle = true;
90+
fixture.detectChanges();
91+
92+
expect(header.querySelector('.mat-expansion-indicator'))
93+
.toBeFalsy('Expected indicator to be hidden.');
94+
});
95+
96+
it('should update the indicator rotation when the expanded state is toggled programmatically',
97+
fakeAsync(() => {
98+
const fixture = TestBed.createComponent(PanelWithContent);
99+
100+
fixture.detectChanges();
101+
tick(250);
102+
103+
const arrow = fixture.debugElement.query(By.css('.mat-expansion-indicator')).nativeElement;
104+
105+
expect(arrow.style.transform).toBe('rotate(0deg)', 'Expected no rotation.');
106+
107+
fixture.componentInstance.expanded = true;
108+
fixture.detectChanges();
109+
tick(250);
110+
111+
expect(arrow.style.transform).toBe('rotate(180deg)', 'Expected 180 degree rotation.');
112+
}));
79113
});
80114

81115

82116
@Component({template: `
83117
<md-expansion-panel [expanded]="expanded"
118+
[hideToggle]="hideToggle"
84119
(opened)="openCallback()"
85120
(closed)="closeCallback()">
86121
<md-expansion-panel-header>Panel Title</md-expansion-panel-header>
@@ -89,6 +124,7 @@ describe('MdExpansionPanel', () => {
89124
</md-expansion-panel>`})
90125
class PanelWithContent {
91126
expanded: boolean = false;
127+
hideToggle: boolean = false;
92128
openCallback = jasmine.createSpy('openCallback');
93129
closeCallback = jasmine.createSpy('closeCallback');
94130
}

0 commit comments

Comments
 (0)