tabbed DNC card, machine-numbered downloads, themed backup history
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import {
|
||||
toApiPath, subst, rows, mapTitle, mapBadge, mapMeta, manageLink,
|
||||
keyvalueFields, tableColumns, badges, panelVisible,
|
||||
keyvalueFields, tableColumns, badges, panelVisible, tabSections,
|
||||
} from './pluginAssetPanels'
|
||||
|
||||
const warrantyPanel = {
|
||||
@@ -98,3 +98,35 @@ describe('keyvalue + table + badge', () => {
|
||||
expect(badges({ render: 'badge', _data: { badges: [{ label: 'B', color: '#222' }] } })).toEqual([{ label: 'B', color: '#222' }])
|
||||
})
|
||||
})
|
||||
|
||||
describe('tabSections', () => {
|
||||
const panel = {
|
||||
render: 'tabs',
|
||||
_data: {
|
||||
sections: [
|
||||
{ label: 'General', fields: [{ label: 'Cnc', value: 'OKUMA' }] },
|
||||
{ label: 'eFocas', fields: [{ label: 'IpAddr', value: '192.168.1.1', mono: true }] },
|
||||
// A section whose fields all dropped out must not leave an empty tab.
|
||||
{ label: 'NTSHR', fields: [] },
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
it('returns one entry per non-empty section', () => {
|
||||
expect(tabSections(panel).map((s) => s.label)).toEqual(['General', 'eFocas'])
|
||||
})
|
||||
|
||||
it('formats field values and carries mono through', () => {
|
||||
const efocas = tabSections(panel)[1]
|
||||
expect(efocas.fields[0]).toEqual({ label: 'IpAddr', value: '192.168.1.1', mono: true })
|
||||
})
|
||||
|
||||
it('is empty for a payload with no sections', () => {
|
||||
expect(tabSections({ render: 'tabs', _data: null })).toEqual([])
|
||||
})
|
||||
|
||||
it('drives panel visibility', () => {
|
||||
expect(panelVisible(panel)).toBe(true)
|
||||
expect(panelVisible({ render: 'tabs', _data: { sections: [] } })).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user