import { async, ComponentFixture, fakeAsync, tick, TestBed } from '@angular/core/testing'; import { ReplaceAllPipe } from '@pipes' import { IconOverviewItemComponent } from './icon-overview-item.component'; import { ClipboardModule } from 'ngx-clipboard'; describe('IconOverviewItemComponent', () => { let component: IconOverviewItemComponent; let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ IconOverviewItemComponent, ReplaceAllPipe, ], imports: [ ClipboardModule, ], }) .compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(IconOverviewItemComponent); component = fixture.componentInstance; fixture.detectChanges(); }); it('creates the component', () => { expect(component).toBeTruthy(); }); describe('copySuccess()', () => { it('sets the copied to true', () => { component.copySuccess(); fixture.detectChanges(); expect(component.copied).toBe(true); }) it('resets the copied value after timeout', fakeAsync(() => { component.copySuccess(); tick(3000); fixture.detectChanges(); expect(component.copied).toBe(false); })) }); });