Skip to content

Commit d09d215

Browse files
committed
chore: add a couple of unit tests for the fixes
1 parent 0342642 commit d09d215

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
@@ -103,12 +103,47 @@ describe('MdExpansionPanel', () => {
103103
expect(styles.marginLeft).toBe('37px');
104104
expect(styles.marginRight).toBe('37px');
105105
}));
106+
107+
it('should be able to hide the toggle', () => {
108+
const fixture = TestBed.createComponent(PanelWithContent);
109+
const header = fixture.debugElement.query(By.css('.mat-expansion-panel-header')).nativeElement;
110+
111+
fixture.detectChanges();
112+
113+
expect(header.querySelector('.mat-expansion-indicator'))
114+
.toBeTruthy('Expected indicator to be shown.');
115+
116+
fixture.componentInstance.hideToggle = true;
117+
fixture.detectChanges();
118+
119+
expect(header.querySelector('.mat-expansion-indicator'))
120+
.toBeFalsy('Expected indicator to be hidden.');
121+
});
122+
123+
it('should update the indicator rotation when the expanded state is toggled programmatically',
124+
fakeAsync(() => {
125+
const fixture = TestBed.createComponent(PanelWithContent);
126+
127+
fixture.detectChanges();
128+
tick(250);
129+
130+
const arrow = fixture.debugElement.query(By.css('.mat-expansion-indicator')).nativeElement;
131+
132+
expect(arrow.style.transform).toBe('rotate(0deg)', 'Expected no rotation.');
133+
134+
fixture.componentInstance.expanded = true;
135+
fixture.detectChanges();
136+
tick(250);
137+
138+
expect(arrow.style.transform).toBe('rotate(180deg)', 'Expected 180 degree rotation.');
139+
}));
106140
});
107141

108142

109143
@Component({
110144
template: `
111145
<md-expansion-panel [expanded]="expanded"
146+
[hideToggle]="hideToggle"
112147
(opened)="openCallback()"
113148
(closed)="closeCallback()">
114149
<md-expansion-panel-header>Panel Title</md-expansion-panel-header>
@@ -118,6 +153,7 @@ describe('MdExpansionPanel', () => {
118153
})
119154
class PanelWithContent {
120155
expanded: boolean = false;
156+
hideToggle: boolean = false;
121157
openCallback = jasmine.createSpy('openCallback');
122158
closeCallback = jasmine.createSpy('closeCallback');
123159
}

0 commit comments

Comments
 (0)