Skip to content

Commit

Permalink
[#1447] Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
fivitti committed Sep 17, 2024
1 parent f89b6d0 commit 7160b18
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[formatComplexTypes]="true"
></app-cascaded-parameters-board>
</p-fieldset>
<p-fieldset legend="Global DHCP Options" class="col" *ngIf="dhcpOptions.length > 0">
<p-fieldset legend="Global DHCP Options" class="col">
<app-dhcp-option-set-view [options]="dhcpOptions" [levels]="['global']"></app-dhcp-option-set-view>
</p-fieldset>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,20 @@ import { By } from '@angular/platform-browser'
import { ButtonModule } from 'primeng/button'
import { TableModule } from 'primeng/table'
import { TooltipModule } from 'primeng/tooltip'
import { DhcpOptionSetViewComponent } from '../dhcp-option-set-view/dhcp-option-set-view.component'
import { TreeModule } from 'primeng/tree'
import { HelpTipComponent } from '../help-tip/help-tip.component'
import { OverlayPanelModule } from 'primeng/overlaypanel'
import { TagModule } from 'primeng/tag'

describe('KeaGlobalConfigurationViewComponent', () => {
let component: KeaGlobalConfigurationViewComponent
let fixture: ComponentFixture<KeaGlobalConfigurationViewComponent>

beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ButtonModule, FieldsetModule, NoopAnimationsModule, TableModule, TooltipModule],
declarations: [CascadedParametersBoardComponent, KeaGlobalConfigurationViewComponent],
imports: [ButtonModule, FieldsetModule, NoopAnimationsModule, TableModule, TooltipModule, TreeModule, OverlayPanelModule, TagModule],
declarations: [CascadedParametersBoardComponent, KeaGlobalConfigurationViewComponent, DhcpOptionSetViewComponent, HelpTipComponent]
}).compileComponents()

fixture = TestBed.createComponent(KeaGlobalConfigurationViewComponent)
Expand Down Expand Up @@ -44,4 +49,10 @@ describe('KeaGlobalConfigurationViewComponent', () => {
component.onEditBegin()
expect(component.editBegin.emit).toHaveBeenCalled()
})

it('should display the DHCP options view', () => {
const fieldset = fixture.debugElement.query(By.css("[legend='Global DHCP Options']"))
expect(fieldset).toBeTruthy()
expect(fieldset.nativeElement.innerText).toContain('No options configured')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class KeaGlobalConfigurationViewComponent {
/**
* Holds fetched DHCP options.
*/
@Input() dhcpOptions: DHCPOption[][] = []
@Input() dhcpOptions: DHCPOption[][] = [[]]

/**
* Boolean flag indicating if the edit button should be disabled.
Expand Down

0 comments on commit 7160b18

Please sign in to comment.