paperless-ngx/src-ui/src/app/components/common/clearable-badge/clearable-badge.component.spec.ts
2024-01-19 22:28:32 -08:00

46 lines
1.4 KiB
TypeScript

import { ComponentFixture, TestBed } from '@angular/core/testing'
import { ClearableBadgeComponent } from './clearable-badge.component'
import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons'
describe('ClearableBadgeComponent', () => {
let component: ClearableBadgeComponent
let fixture: ComponentFixture<ClearableBadgeComponent>
beforeEach(async () => {
TestBed.configureTestingModule({
declarations: [ClearableBadgeComponent],
imports: [NgxBootstrapIconsModule.pick(allIcons)],
}).compileComponents()
fixture = TestBed.createComponent(ClearableBadgeComponent)
component = fixture.componentInstance
fixture.detectChanges()
})
it('should support selected', () => {
component.selected = true
expect(component.active).toBeTruthy()
})
it('should support numbered', () => {
component.number = 3
fixture.detectChanges()
expect(component.active).toBeTruthy()
expect((fixture.nativeElement as HTMLDivElement).textContent).toContain('3')
})
it('should support selected', () => {
let clearedResult
component.selected = true
fixture.detectChanges()
component.cleared.subscribe((clear) => {
clearedResult = clear
})
fixture.nativeElement
.querySelectorAll('button')[0]
.dispatchEvent(new MouseEvent('click'))
expect(clearedResult).toBeTruthy()
})
})