Commit cdcc4449 authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰 Committed by Tomek Mrugalski

[#164] SharedNetworksPage test fixed

parent 5e9e639c
......@@ -11,6 +11,12 @@ import { DHCPService } from '../backend'
import { HttpClient, HttpHandler } from '@angular/common/http'
import { of } from 'rxjs'
class MockParamMap {
get(name: string): string | null {
return null
}
}
describe('SharedNetworksPageComponent', () => {
let component: SharedNetworksPageComponent
let fixture: ComponentFixture<SharedNetworksPageComponent>
......@@ -27,8 +33,8 @@ describe('SharedNetworksPageComponent', () => {
{
provide: ActivatedRoute,
useValue: {
snapshot: { queryParams: {} },
queryParamMap: of({}),
snapshot: { queryParamMap: new MockParamMap() },
queryParamMap: of(new MockParamMap()),
},
},
DHCPService,
......
......@@ -55,13 +55,17 @@ export class SharedNetworksPageComponent implements OnInit {
this.updateOurQueryParams(ssParams)
// subscribe to subsequent changes to query params
this.route.queryParamMap.subscribe((params) => {
this.route.queryParamMap.subscribe(
(params) => {
this.updateOurQueryParams(params)
let event = { first: 0, rows: 10 }
if (this.networksTable) {
event = this.networksTable.createLazyLoadMetadata()
}
this.loadNetworks(event)
},
(error) => {
console.log(error)
})
}
......@@ -83,9 +87,13 @@ export class SharedNetworksPageComponent implements OnInit {
const params = this.queryParams
this.dhcpApi
.getSharedNetworks(event.first, event.rows, params.appId, params.dhcpVersion, params.text)
.subscribe((data) => {
.subscribe(
(data) => {
this.networks = data.items
this.totalNetworks = data.total
},
(error) => {
console.log(error)
})
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment