Skip to content

Commit 94a83cf

Browse files
committed
Add pokemon link unit tests.
1 parent 4e7b07a commit 94a83cf

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

src/app/components/banner-grid/banner-grid.component.spec.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ComponentFixture, TestBed } from '@angular/core/testing';
2-
2+
import { RouterTestingModule } from '@angular/router/testing';
33
import { BannerGridComponent } from './banner-grid.component';
44

55
describe('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

Comments
 (0)