Я делаю автоматический тест для моего углового приложения, и я получил эту ошибку: Невозможно получить свойство 'unuseGeometry' с неопределенным или пустым указанием .Я не знаю, в чем дело, для проверки я использую браузер Edge.
it('should call goToInitialMenu()', () => {
spyOn(component, 'goToInitialMenu');
component.goToInitialMenu();
fixture.whenStable().then(()=> {
expect(component.goToInitialMenu).toHaveBeenCalled();
});
});
Полный тестовый файл:
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
import { SinglePlayerMenuComponent } from './single-player-menu.component';
import { HttpClientModule } from '@angular/common/http';
fdescribe('SinglePlayerMenuComponent', () => {
let component: SinglePlayerMenuComponent;
let fixture: ComponentFixture<SinglePlayerMenuComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ SinglePlayerMenuComponent ],
schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
providers: [SinglePlayerMenuComponent],
imports: [ HttpClientModule ],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SinglePlayerMenuComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should call goToInitialMenu()', () => {
spyOn(component, 'goToInitialMenu');
component.goToInitialMenu();
fixture.whenStable().then(()=> {
expect(component.goToInitialMenu).toHaveBeenCalled();
});
});
});
Это файл компонента:
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Song } from 'src/app/shared/song/song.model';
import { SceneOrchestratorService } from 'src/app/services/scene-orchestrator.service';
import { Scene } from 'src/app/shared/scene/scene.enum';
import { SongService } from 'src/app/services/song.service';
import { Subscription } from 'rxjs';
@Component({
selector: 'a-single-player-menu',
templateUrl: './single-player-menu.component.html',
styleUrls: ['./single-player-menu.component.css']
})
export class SinglePlayerMenuComponent implements OnInit, OnDestroy {
private _songSrvSubscription: Subscription;
constructor(private _sceneOrchestratorSrv: SceneOrchestratorService,
private _songSrv: SongService) { }
private _songs: Song[];
private _selectedSong: Song;
ngOnInit() {
this._songSrvSubscription = this._songSrv.getTopRaitedSongsList().subscribe(
(result: Song[]) => {
this.songs = result;
});
}
ngOnDestroy() {
if (this._songSrvSubscription != undefined) {
this._songSrvSubscription.unsubscribe();
}
}
get songs(): Song[] {
return this._songs;
}
set songs(songs: Song[]) {
console.log(songs)
this._songs = songs;
}
get selectedSong() {
return this._selectedSong;
}
set selectedSong(songSelected: Song) {
this._selectedSong = songSelected;
}
selectTheSong(song: Song) {
this._selectedSong = song;
}
goToInitialMenu() {
this._sceneOrchestratorSrv.actualScene = Scene.initialMenu;
}
}
У меня такой же код в другом компоненте, и он работает нормально, я не знаю, почему в этом компоненте я получил эту ошибку.