вот такой набор:
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { MaterialModule } from './utils/material/material.module';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent,
],
providers: [
MaterialModule,
],
schemas: [
CUSTOM_ELEMENTS_SCHEMA,
],
}).compileComponents();
}));
it(`Should create the app`, async(() => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
});
В MaterialModule:
import { NgModule } from '@angular/core';
import {
MatButtonModule, MatCardModule, MatFormFieldModule,
MatIconModule, MatInputModule,
MatMenuModule, MatSnackBarModule, MatToolbarModule
} from '@angular/material';
@NgModule({
imports: [
MatToolbarModule, MatMenuModule, MatIconModule,
MatCardModule, MatFormFieldModule,
MatInputModule, MatButtonModule, MatSnackBarModule],
exports: [
MatToolbarModule, MatMenuModule, MatIconModule, MatCardModule, MatFormFieldModule, MatInputModule,
MatButtonModule, MatSnackBarModule],
})
export class MaterialModule {}При запуске получаю: `There is no directive with "exportAs" set to "matMenu" ("erLink="/"><mat-icon>account_balance_wallet</mat-icon></a><span class="free-space"></span><mat-menu [ERROR ->]#appMenu="matMenu"><a *ngIf="!isLogged" routerLink="/login/" mat-menu-item>Вход</a><a *ngIf="!isLogge"): ng:///DynamicTestModule/AppComponent.html@0:153
Can't bind to 'matMenuTriggerFor' since it isn't a known property of 'a'. ("l}})</a><a *ngIf="isLogged" mat-menu-item (click)="logout()">Выход</a></mat-menu><a mat-icon-button [ERROR ->][matMenuTriggerFor]="appMenu"><mat-icon>{{isLogged ? "account_circle" : "lock"}}</mat-icon></a></mat-"): ng:///DynamicTestModule/AppComponent.html@0:486
`
так модуль надо импортировать, а не провайдить
Обсуждают сегодня