This repository has been archived by the owner on Oct 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(snackbar): Improvements + test coverage (#200)
* Remove `mdc-button` from snackbar dependency : ref MDC v0.21 update. * Refactor individual snackbar directive files into the `snackbar.component.ts` * Add return type to functions. * Add initial test coverage.
- Loading branch information
Showing
7 changed files
with
115 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Component, DebugElement } from '@angular/core'; | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
import { | ||
MdcSnackbarComponent, | ||
MdcSnackbarModule, | ||
} from '../../../src/lib/public_api'; | ||
|
||
describe('MdcSnackbarComponent', () => { | ||
let fixture: ComponentFixture<any>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [MdcSnackbarModule], | ||
declarations: [ | ||
SimpleSnack, | ||
] | ||
}); | ||
TestBed.compileComponents(); | ||
})); | ||
|
||
describe('behaviors', () => { | ||
let snackBarDebugElement: DebugElement; | ||
let snackBarInstance: MdcSnackbarComponent; | ||
let testComponent: SimpleSnack; | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(SimpleSnack); | ||
fixture.detectChanges(); | ||
|
||
snackBarDebugElement = fixture.debugElement.query(By.directive(MdcSnackbarComponent)); | ||
snackBarInstance = snackBarDebugElement.componentInstance; | ||
testComponent = fixture.debugElement.componentInstance; | ||
}); | ||
|
||
it('#should have mdc-snackbar by default', () => { | ||
expect(snackBarDebugElement.nativeElement.classList) | ||
.toContain('mdc-snackbar', 'Expected to have mdc-snackbar'); | ||
}); | ||
|
||
it('#should apply class based on property', () => { | ||
testComponent.isAlignStart = true; | ||
fixture.detectChanges(); | ||
expect(snackBarDebugElement.nativeElement.classList.contains('mdc-snackbar--align-start')).toBe(true); | ||
}); | ||
}); | ||
}); | ||
|
||
@Component({ | ||
template: | ||
` | ||
<mdc-snackbar | ||
[alignStart]="isAlignStart"> | ||
</mdc-snackbar> | ||
` | ||
}) | ||
class SimpleSnack { | ||
isAlignStart: boolean = false; | ||
} |