-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NAS-132995: Implement iSCSI connections card
- Loading branch information
1 parent
fda29c1
commit b55723b
Showing
3 changed files
with
67 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 23 additions & 13 deletions
36
...csi/target/all-targets/target-details/connections-card/connections-card.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,40 @@ | ||
import { createComponentFactory, Spectator } from '@ngneat/spectator/jest'; | ||
import { Spectator, createComponentFactory } from '@ngneat/spectator/jest'; | ||
import { mockApi, mockCall } from 'app/core/testing/utils/mock-api.utils'; | ||
import { IscsiGlobalSession } from 'app/interfaces/iscsi-global-config.interface'; | ||
import { IscsiTarget } from 'app/interfaces/iscsi.interface'; | ||
import { | ||
AuthorizedNetworksCardComponent, | ||
} from 'app/pages/sharing/iscsi/target/all-targets/target-details/authorized-networks-card/authorized-networks-card.component'; | ||
import { ConnectionsCardComponent } from './connections-card.component'; | ||
|
||
describe('ConnectionsCardComponent', () => { | ||
let spectator: Spectator<ConnectionsCardComponent>; | ||
|
||
describe('AuthorizedNetworksCardComponent', () => { | ||
let spectator: Spectator<AuthorizedNetworksCardComponent>; | ||
const createComponent = createComponentFactory({ | ||
component: AuthorizedNetworksCardComponent, | ||
component: ConnectionsCardComponent, | ||
providers: [ | ||
mockApi([ | ||
mockCall('iscsi.global.sessions', [ | ||
{ initiator: 'iqn.1991-05.com.microsoft:initiator1', initiator_addr: '192.168.1.100' }, | ||
{ initiator: 'iqn.1991-05.com.microsoft:initiator2', initiator_addr: '192.168.1.101' }, | ||
] as IscsiGlobalSession[]), | ||
]), | ||
], | ||
}); | ||
|
||
beforeEach(() => { | ||
spectator = createComponent({ | ||
props: { | ||
target: { | ||
auth_networks: ['192.168.1.10/24', '10.0.0.1/24'], | ||
name: 'Target1', | ||
} as IscsiTarget, | ||
}, | ||
}); | ||
}); | ||
|
||
it('shows a list of networks authorized for the target', () => { | ||
const networks = spectator.queryAll('.network'); | ||
it('displays session information when available', () => { | ||
spectator.detectChanges(); | ||
|
||
expect(networks).toHaveLength(2); | ||
expect(networks[0]).toHaveText('192.168.1.10/24'); | ||
expect(networks[1]).toHaveText('10.0.0.1/24'); | ||
const connections = spectator.queryAll('.connection'); | ||
expect(connections).toHaveLength(2); | ||
expect(connections[0]).toHaveText('iqn.1991-05.com.microsoft:initiator1 | 192.168.1.100'); | ||
expect(connections[1]).toHaveText('iqn.1991-05.com.microsoft:initiator2 | 192.168.1.101'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters