11import { ComponentFixture , TestBed } from '@angular/core/testing' ;
2-
2+ import { RouterTestingModule } from '@angular/router/testing' ;
33import { BannerGridComponent } from './banner-grid.component' ;
44
55describe ( 'BannerGridComponent' , ( ) => {
@@ -8,7 +8,7 @@ describe('BannerGridComponent', () => {
88
99 beforeEach ( async ( ) => {
1010 await TestBed . configureTestingModule ( {
11- imports : [ BannerGridComponent ] ,
11+ imports : [ BannerGridComponent , RouterTestingModule ] ,
1212 } ) . compileComponents ( ) ;
1313
1414 fixture = TestBed . createComponent ( BannerGridComponent ) ;
@@ -19,4 +19,26 @@ describe('BannerGridComponent', () => {
1919 it ( 'should create' , ( ) => {
2020 expect ( component ) . toBeTruthy ( ) ;
2121 } ) ;
22+
23+ describe ( 'getPokemonLink' , ( ) => {
24+ it ( 'should return correct URL format with lowercase pokemon name' , ( ) => {
25+ const pokemon = { title : 'Charizard' } ;
26+ expect ( component . getPokemonLink ( pokemon ) ) . toBe (
27+ '/pokemon-optimized/charizard'
28+ ) ;
29+ } ) ;
30+
31+ it ( 'should work with different pokemon names' , ( ) => {
32+ const testCases = [
33+ { input : 'Blastoise' , expected : '/pokemon-optimized/blastoise' } ,
34+ { input : 'Venusaur' , expected : '/pokemon-optimized/venusaur' } ,
35+ { input : 'PIKACHU' , expected : '/pokemon-optimized/pikachu' } ,
36+ ] ;
37+
38+ testCases . forEach ( test => {
39+ const pokemon = { title : test . input } ;
40+ expect ( component . getPokemonLink ( pokemon ) ) . toBe ( test . expected ) ;
41+ } ) ;
42+ } ) ;
43+ } ) ;
2244} ) ;
0 commit comments