本文整理汇总了TypeScript中@angular-mdc/web.MdcSnackbar类的典型用法代码示例。如果您正苦于以下问题:TypeScript MdcSnackbar类的具体用法?TypeScript MdcSnackbar怎么用?TypeScript MdcSnackbar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MdcSnackbar类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('MdcSnackbar', () => {
let snackbar: MdcSnackbar;
let simpleMessage = 'Simple message!';
let simpleActionLabel = 'Ok';
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [MdcSnackbarModule],
declarations: [SimpleSnack]
});
TestBed.compileComponents();
}));
describe('behaviors', () => {
let testSnackbar: MdcSnackbar;
let fixture: ComponentFixture<any>;
beforeEach(() => {
fixture = TestBed.createComponent(SimpleSnack);
snackbar = fixture.componentInstance.snackbar;
fixture.detectChanges();
});
it('#should open a simple message', () => {
snackbar.show(simpleMessage);
});
it('#should open a simple message with a button', fakeAsync(() => {
let snackbarRef = snackbar.show(simpleMessage, simpleActionLabel);
fixture.detectChanges();
tick(1000);
snackbarRef.componentInstance.actionButton.nativeElement.click();
fixture.detectChanges();
flush();
}));
it('#should open a snackbar with config', () => {
let snackbarRef = snackbar.show(simpleMessage, simpleActionLabel, { timeout: 3000, align: 'start', focusAction: true });
expect(snackbar.isShowing()).toBe(true);
fixture.detectChanges();
snackbar.dismiss();
expect(snackbar.isShowing()).toBe(false);
});
it('#should close an open snackbar', fakeAsync(() => {
let snackbarRef = snackbar.show(simpleMessage);
fixture.detectChanges();
tick(1000);
snackbarRef = snackbar.show(simpleMessage);
fixture.detectChanges();
flush();
}));
});
});
示例2: it
it('#should open a snackbar with config', () => {
let snackbarRef = snackbar.show(simpleMessage, simpleActionLabel, { timeout: 3000, align: 'start', focusAction: true });
expect(snackbar.isShowing()).toBe(true);
fixture.detectChanges();
snackbar.dismiss();
expect(snackbar.isShowing()).toBe(false);
});
示例3:
() => {
// FIXME send to sentry
this.snackbar.open(
'An error occurred while removing the item. This may happened because the underlying TheMovieDB service returned an invalid response. '
+ 'Please refresh the page an try again!',
'Close',
this.getSnackbarConfig()
);
}