Skip to content

Commit

Permalink
chore: add a couple of unit tests for the fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
crisbeto committed Jul 27, 2017
1 parent 0342642 commit d09d215
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/lib/expansion/expansion.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,47 @@ describe('MdExpansionPanel', () => {
expect(styles.marginLeft).toBe('37px');
expect(styles.marginRight).toBe('37px');
}));

it('should be able to hide the toggle', () => {
const fixture = TestBed.createComponent(PanelWithContent);
const header = fixture.debugElement.query(By.css('.mat-expansion-panel-header')).nativeElement;

fixture.detectChanges();

expect(header.querySelector('.mat-expansion-indicator'))
.toBeTruthy('Expected indicator to be shown.');

fixture.componentInstance.hideToggle = true;
fixture.detectChanges();

expect(header.querySelector('.mat-expansion-indicator'))
.toBeFalsy('Expected indicator to be hidden.');
});

it('should update the indicator rotation when the expanded state is toggled programmatically',
fakeAsync(() => {
const fixture = TestBed.createComponent(PanelWithContent);

fixture.detectChanges();
tick(250);

const arrow = fixture.debugElement.query(By.css('.mat-expansion-indicator')).nativeElement;

expect(arrow.style.transform).toBe('rotate(0deg)', 'Expected no rotation.');

fixture.componentInstance.expanded = true;
fixture.detectChanges();
tick(250);

expect(arrow.style.transform).toBe('rotate(180deg)', 'Expected 180 degree rotation.');
}));
});


@Component({
template: `
<md-expansion-panel [expanded]="expanded"
[hideToggle]="hideToggle"
(opened)="openCallback()"
(closed)="closeCallback()">
<md-expansion-panel-header>Panel Title</md-expansion-panel-header>
Expand All @@ -118,6 +153,7 @@ describe('MdExpansionPanel', () => {
})
class PanelWithContent {
expanded: boolean = false;
hideToggle: boolean = false;
openCallback = jasmine.createSpy('openCallback');
closeCallback = jasmine.createSpy('closeCallback');
}
Expand Down

0 comments on commit d09d215

Please sign in to comment.