当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript web.MdcSnackbar类代码示例

本文整理汇总了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();
    }));
  });
});
开发者ID:cd8608,项目名称:angular-mdc-web,代码行数:58,代码来源:snackbar.test.ts

示例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);
    });
开发者ID:cd8608,项目名称:angular-mdc-web,代码行数:8,代码来源:snackbar.test.ts

示例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()
   );
 }
开发者ID:dArignac,项目名称:treasury,代码行数:9,代码来源:movie-list.component.ts


注:本文中的@angular-mdc/web.MdcSnackbar类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。