feat: enhance tests with router, HTTP client, and animations support
This commit is contained in:
@@ -1,23 +1,20 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ProductImage } from './product-image';
|
||||
|
||||
describe('ProductImage', () => {
|
||||
let component: ProductImage;
|
||||
let fixture: ComponentFixture<ProductImage>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [ProductImage]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(ProductImage);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({ imports: [ProductImage] });
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
it('it renders the image with proper src and alt', () => {
|
||||
const fixture = TestBed.createComponent(ProductImage);
|
||||
fixture.componentRef.setInput('imgUrl', 'https://example.com/a.jpg');
|
||||
fixture.componentRef.setInput('alt', 'Acer Iconia');
|
||||
fixture.detectChanges();
|
||||
|
||||
const img: HTMLImageElement = fixture.nativeElement.querySelector('img');
|
||||
expect(img.src).toBe('https://example.com/a.jpg');
|
||||
expect(img.alt).toBe('Acer Iconia');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user