Estou na aula 10, e não consegui passar pelo teste quando o ID não é informado, dá o erro: Error: Expected null to be truthy. Vou postar todo o spec e ts. Se alguém ver onde estou errando e puder me ajudar, eu agradeço muito.
like-widget.component.spec.ts
describe(LikeWidgetComponent.name, () =>{
let fixture: ComponentFixture<LikeWidgetComponent> = null;
beforeEach( async ()=> {
await TestBed.configureTestingModule({
imports: [LikeWidgetModule]
}).compileComponents();
fixture = TestBed.createComponent(LikeWidgetComponent);
});
it('Should create component' , () => {
const component = fixture.componentInstance;
expect(component).toBeTruthy();
});
it('Deve gerar ID quando não for informado', () => {
const component = fixture.componentInstance;
fixture.detectChanges();
expect(component.id).toBeTruthy();
} );
});
LikeWidgetComponent
@Component({
selector: 'app-like-widget',
templateUrl: './like-widget.component.html',
styleUrls: ['like-widget.component.scss']
})
export class LikeWidgetComponent implements OnInit{
@Output() public liked = new EventEmitter<void>();
@Input() public likes = 0;
@Input() public id = null;
public fonts = { faThumbsUp }
constructor( private uniqueIdService: UniqueIdService ){}
public ngOnInit() : void {
console.log('Aqui', this.id)
if( !this.id ){
this.uniqueIdService.generatedUniqueIdWidthPrefix('like-widget');
}
}
public like() : void {
this.liked.emit();
}
}