Add loadHostLinks test

pull/10616/head
Delmer Reed 2018-07-10 18:06:05 -04:00
parent d7e7981143
commit 96cae2c583
1 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,61 @@
import {loadHostsLinks} from 'src/hosts/apis'
import {source} from 'test/resources'
import {HostNames} from 'src/types/hosts'
import {DashboardSwitcherLinks} from 'src/types/dashboards'
describe('hosts.apis.loadHostLinks', () => {
const socure = {...source, id: '897'}
const hostNames: HostNames = {
'zelda.local': {
name: 'zelda.local',
},
'gannon.local': {
name: 'gannon.local',
},
'korok.local': {
name: 'korok.local',
},
}
const hostNamesAJAX = async () => hostNames
const options = {
activeHost: {
name: 'korok.local',
},
getHostNamesAJAX: hostNamesAJAX,
}
it('can load the host links', async () => {
const hostLinks = await loadHostsLinks(socure, options)
const expectedLinks: DashboardSwitcherLinks = {
active: {
key: 'korok.local',
text: 'korok.local',
to: '/sources/897/hosts/korok.local',
},
links: [
{
key: 'zelda.local',
text: 'zelda.local',
to: '/sources/897/hosts/zelda.local',
},
{
key: 'gannon.local',
text: 'gannon.local',
to: '/sources/897/hosts/gannon.local',
},
{
key: 'korok.local',
text: 'korok.local',
to: '/sources/897/hosts/korok.local',
},
],
}
expect(hostLinks).toEqual(expectedLinks)
})
})