I have a router animation, which works well. Its fairly simple. However I cannot get the test to pass.
I have the set up for it as below.
import { Component, OnInit, ElementRef, ViewChild } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { fader } from 'app/route-animations';
@Component({
selector: 'app-logged-in-layout',
templateUrl: './logged-in-layout.component.html',
styleUrls: ['./logged-in-layout.component.less'],
animations: [fader],
})
export class LoggedInLayoutComponent implements OnInit {
constructor() {}
prepareRoute(outlet: RouterOutlet) {
return (
outlet &&
outlet.activatedRouteData &&
outlet.activatedRouteData['animation']
);
}
The html is as follows
<main [@routeAnimations]="prepareRoute(outlet)" class="content">
<router-outlet #outlet="outlet"></router-outlet>
</main>
Below I have an image for the test results
Now I realise there is a template ref called #outlet, but what I don't know is do I define that in the test file or the component file
How would I do that?
My test file is
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { LoggedInLayoutComponent } from './logged-in-layout.component';
import { RouterOutlet } from '@angular/router';
describe('LoggedInLayoutComponent', () => {
let component: LoggedInLayoutComponent;
let fixture: ComponentFixture<LoggedInLayoutComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [LoggedInLayoutComponent],
providers: [RouterOutlet],
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(LoggedInLayoutComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
Any guidance would be appreciated.
