@angular/material/snack-bar#MatSnackBarRef TypeScript Examples

The following examples show how to use @angular/material/snack-bar#MatSnackBarRef. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: snackbar.component.spec.ts    From leapp with Mozilla Public License 2.0 6 votes vote down vote up
describe("SnackbarComponent", () => {
  let component: SnackbarComponent;
  let fixture: ComponentFixture<SnackbarComponent>;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [],
      providers: [
        { provide: MAT_SNACK_BAR_DATA, useValue: {} },
        { provide: MatSnackBarRef, useValue: {} },
      ].concat(mustInjected()),
    }).compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(SnackbarComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  it("should create", () => {
    expect(component).toBeTruthy();
  });
});
Example #2
Source File: snackbar.service.ts    From WowUp with GNU General Public License v3.0 6 votes vote down vote up
public showSnackbar(localeKey: string, config?: SnackbarConfig): MatSnackBarRef<CenteredSnackbarComponent> {
    const message: string = this._translateService.instant(localeKey, config?.localeArgs as unknown);
    const data: CenteredSnackbarComponentData = {
      message,
    };
    return this._snackBar.openFromComponent(CenteredSnackbarComponent, {
      duration: config?.timeout ?? 5000,
      panelClass: ["wowup-snackbar", "text-1", ...(config?.classes ?? [])],
      data,
    });
  }
Example #3
Source File: integration-bar.component.spec.ts    From leapp with Mozilla Public License 2.0 5 votes vote down vote up
describe("IntegrationBarComponent", () => {
  let component: IntegrationBarComponent;
  let fixture: ComponentFixture<IntegrationBarComponent>;

  beforeEach(async(() => {
    const spyRepositoryService = jasmine.createSpyObj("Repository", {
      getProfiles: [],
      getSessions: [],
      getSegments: [],
      listAwsSsoIntegrations: [],
    });
    const spyBehaviouralSubjectService = jasmine.createSpyObj("BehaviouralSubjectService", [], {
      integrations: [],
      integrations$: { subscribe: () => {} },
      setIntegrations: (_awsSsoIntegrations: AwsSsoIntegration[]) => void {},
      getIntegrations: () => [],
    });
    const spyLeappCoreService = jasmine.createSpyObj("LeappCoreService", [], {
      repository: spyRepositoryService,
      awsCoreService: { getRegions: () => ["mocked-region-1", "mocked-region-2"] },
      awsSsoOidcService: { listeners: [] },
      behaviouralSubjectService: spyBehaviouralSubjectService,
      awsSsoIntegrationService: { getIntegrations: () => [] },
    });

    TestBed.configureTestingModule({
      imports: [RouterTestingModule],
      declarations: [IntegrationBarComponent],
      providers: [
        { provide: MAT_SNACK_BAR_DATA, useValue: {} },
        { provide: MatSnackBarRef, useValue: {} },
      ].concat(mustInjected().concat([{ provide: AppProviderService, useValue: spyLeappCoreService }])),
    }).compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(IntegrationBarComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
    component.subscription = {
      unsubscribe: () => {},
    };
    component.subscription2 = {
      unsubscribe: () => {},
    };
    component.subscription3 = {
      unsubscribe: () => {},
    };
  });

  it("should create", () => {
    expect(component).toBeTruthy();
  });
});
Example #4
Source File: titlebar.component.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
private _snackBarRef: MatSnackBarRef<CenteredSnackbarComponent> | undefined;
Example #5
Source File: snackbar.service.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
public showSuccessSnackbar(localeKey: string, config?: SnackbarConfig): MatSnackBarRef<CenteredSnackbarComponent> {
    return this.showSnackbar(localeKey, {
      ...config,
      classes: [...(config?.classes ?? []), "snackbar-success"],
    });
  }
Example #6
Source File: snackbar.service.ts    From WowUp with GNU General Public License v3.0 5 votes vote down vote up
public showErrorSnackbar(localeKey: string, config?: SnackbarConfig): MatSnackBarRef<CenteredSnackbarComponent> {
    return this.showSnackbar(localeKey, {
      ...config,
      classes: [...(config?.classes ?? []), "snackbar-error"],
    });
  }
Example #7
Source File: error-snackbar.component.ts    From qbit-matUI with MIT License 5 votes vote down vote up
constructor(@Inject(MAT_SNACK_BAR_DATA) private data: any, public snackBarRef: MatSnackBarRef<ErrorSnackbarComponent>) { this.message = this.data.message; }
Example #8
Source File: info-snackbar.component.ts    From qbit-matUI with MIT License 5 votes vote down vote up
constructor(@Inject(MAT_SNACK_BAR_DATA) private data: any, public snackBarRef: MatSnackBarRef<InfoSnackbarComponent>) { this.message = this.data.message; }
Example #9
Source File: success-snackbar.component.ts    From qbit-matUI with MIT License 5 votes vote down vote up
constructor(@Inject(MAT_SNACK_BAR_DATA) private data: any, public snackBarRef: MatSnackBarRef<SuccessSnackbarComponent>) { this.message = this.data.message; }
Example #10
Source File: warn-snackbar.component.ts    From qbit-matUI with MIT License 5 votes vote down vote up
constructor(@Inject(MAT_SNACK_BAR_DATA) private data: any, public snackBarRef: MatSnackBarRef<WarnSnackbarComponent>) { this.message = this.data.message; }
Example #11
Source File: snackbar.service.ts    From qbit-matUI with MIT License 5 votes vote down vote up
/** Keep track of which snackbars are rendering */
  private _snackbar_open: MatSnackBarRef<unknown>;
Example #12
Source File: toast-message.component.ts    From fyle-mobile-app with MIT License 5 votes vote down vote up
constructor(
    @Inject(MAT_SNACK_BAR_DATA)
    public data: { icon: string; message: string; redirectionText: string; showCloseButton: boolean },
    private snackBarRef: MatSnackBarRef<ToastMessageComponent>
  ) {}
Example #13
Source File: genes-list.component.ts    From open-genes-frontend with Mozilla Public License 2.0 5 votes vote down vote up
private snackBarRef: MatSnackBarRef<SnackBarComponent>;