Skip to content

Commit

Permalink
test: add coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoBorzi committed Mar 8, 2020
1 parent 8c1b8eb commit 3e39f47
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/app/shared/services/item-icon.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { TestBed } from '@angular/core/testing';

import { ItemIconService } from './item-icon.service';
import { ItemTemplate } from '@keira-types/item-template.type';
import { SqliteQueryService } from '@keira-shared/services/sqlite-query.service';
import { of } from 'rxjs';

describe('ItemIconService', () => {
let service: ItemIconService;
Expand All @@ -10,7 +13,16 @@ describe('ItemIconService', () => {
service = TestBed.inject(ItemIconService);
});

it('should be created', () => {
expect(service).toBeTruthy();
it('addIconLinkToRows() should correctly work', async () => {
const sqliteQueryService = TestBed.inject(SqliteQueryService);
const iconName = 'mock_icon_name';
spyOn(sqliteQueryService, 'getDisplayIdIcon').and.returnValue(of(iconName).toPromise());
const rows: Partial<ItemTemplate>[] = [
{ displayid: 123 },
];

await service.addIconLinkToRows(rows as ItemTemplate[]);

expect(rows[0].iconLink).toEqual(`https://wow.zamimg.com/images/wow/icons/medium/${iconName}.jpg`);
});
});

0 comments on commit 3e39f47

Please sign in to comment.