Skip to content

Commit

Permalink
spec(icon-service): update
Browse files Browse the repository at this point in the history
  • Loading branch information
simeonoff committed Sep 27, 2021
1 parent 421a55f commit a7d1738
Showing 1 changed file with 2 additions and 27 deletions.
29 changes: 2 additions & 27 deletions projects/igniteui-angular/src/lib/icon/icon.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { TestBed } from '@angular/core/testing';
import { IgxIconService } from './icon.service';
import { DOCUMENT } from '@angular/common';

import { configureTestSuite } from '../test-utils/configure-suite';
import { first } from 'rxjs/operators';
import { HttpClientModule } from '@angular/common/http';

describe('Icon Service', () => {
fdescribe('Icon Service', () => {
configureTestSuite();
const MY_FONT = 'my-awesome-icons';
const ALIAS = 'awesome';
Expand Down Expand Up @@ -55,11 +54,9 @@ describe('Icon Service', () => {

it('should add custom svg icon from url', () => {
const iconService = TestBed.inject(IgxIconService) as IgxIconService;
const document = TestBed.inject(DOCUMENT);

const name = 'test';
const family = 'svg-icons';
const iconKey = family + '_' + name;

spyOn(XMLHttpRequest.prototype, 'open').and.callThrough();
spyOn(XMLHttpRequest.prototype, 'send');
Expand All @@ -68,26 +65,17 @@ describe('Icon Service', () => {

expect(XMLHttpRequest.prototype.open).toHaveBeenCalledTimes(1);
expect(XMLHttpRequest.prototype.send).toHaveBeenCalledTimes(1);

const svgElement = document.querySelector(`svg[id='${iconKey}']`);
expect(svgElement).toBeDefined();
expect(iconService.isSvgIconCached(name, family)).toBeTruthy();
});

it('should add custom svg icon from text', () => {
const iconService = TestBed.inject(IgxIconService) as IgxIconService;
const document = TestBed.inject(DOCUMENT);

const name = 'test';
const family = 'svg-icons';
const iconKey = family + '_' + name;

iconService.addSvgIconFromText(name, svgText, family);

expect(iconService.isSvgIconCached(name, family)).toBeTruthy();
expect(iconService.getSvgIconKey(name, family)).toEqual(iconKey);

const svgElement = document.querySelector(`svg[id='${iconKey}']`);
expect(svgElement).toBeDefined();
});

it('should emit loading event for a custom svg icon from url', done => {
Expand All @@ -113,17 +101,4 @@ describe('Icon Service', () => {

iconService.addSvgIcon(name, 'test.svg', family);
});

it('should create svg container inside the body', () => {
const iconService = TestBed.inject(IgxIconService) as IgxIconService;
const document = TestBed.inject(DOCUMENT);

const name = 'test';
const family = 'svg-icons';

iconService.addSvgIconFromText(name, svgText, family);

const svgContainer = document.body.querySelector('.igx-svg-container');
expect(svgContainer).not.toBeNull();
});
});

0 comments on commit a7d1738

Please sign in to comment.