mirror of
https://github.com/bitwarden/browser
synced 2026-01-05 10:03:21 +00:00
* create libs/assets * treeshake lib and filter out non-icons from icon story * update docs * fix icon colors in browser and desktop * better name for vault icon * move illustrations
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
import { ComponentFixture, TestBed } from "@angular/core/testing";
|
|
|
|
import { Icon, svgIcon } from "@bitwarden/assets/svg";
|
|
|
|
import { BitIconComponent } from "./icon.component";
|
|
|
|
describe("IconComponent", () => {
|
|
let fixture: ComponentFixture<BitIconComponent>;
|
|
|
|
beforeEach(async () => {
|
|
await TestBed.configureTestingModule({
|
|
imports: [BitIconComponent],
|
|
}).compileComponents();
|
|
|
|
fixture = TestBed.createComponent(BitIconComponent);
|
|
fixture.detectChanges();
|
|
});
|
|
|
|
it("should have empty innerHtml when input is not an Icon", () => {
|
|
const fakeIcon = { svg: "harmful user input" } as Icon;
|
|
|
|
fixture.componentRef.setInput("icon", fakeIcon);
|
|
fixture.detectChanges();
|
|
|
|
const el = fixture.nativeElement as HTMLElement;
|
|
expect(el.innerHTML).toBe("");
|
|
});
|
|
|
|
it("should contain icon when input is a safe Icon", () => {
|
|
const icon = svgIcon`<svg><text x="0" y="15">safe icon</text></svg>`;
|
|
|
|
fixture.componentRef.setInput("icon", icon);
|
|
fixture.detectChanges();
|
|
|
|
const el = fixture.nativeElement as HTMLElement;
|
|
expect(el.innerHTML).toBe(`<svg><text x="0" y="15">safe icon</text></svg>`);
|
|
});
|
|
});
|