|
16 | 16 | * limitations under the License. |
17 | 17 | */ |
18 | 18 | import { describe, it, expect, vi } from 'vitest'; |
19 | | -import { buildColumnNodes, buildTableNodes } from './TreeNodeBuilder'; |
| 19 | +import { buildColumnNodes, buildPluginNode, buildTableNodes } from './TreeNodeBuilder'; |
20 | 20 | import type { UsageCounts } from './TreeNodeBuilder'; |
21 | | -import type { ColumnInfo, TableInfo } from '../../types'; |
| 21 | +import type { ColumnInfo, PluginInfo, TableInfo } from '../../types'; |
22 | 22 | import type { ReactElement } from 'react'; |
23 | 23 | import { EyeOutlined, TableOutlined, ThunderboltOutlined } from '@ant-design/icons'; |
24 | 24 |
|
@@ -234,3 +234,28 @@ describe('buildTableNodes icons', () => { |
234 | 234 | expect(iconOf('MATERIALIZED VIEW')).toBe(ThunderboltOutlined); |
235 | 235 | }); |
236 | 236 | }); |
| 237 | + |
| 238 | +describe('buildPluginNode', () => { |
| 239 | + const plugin: PluginInfo = { name: 'splunk', type: 'splunk', enabled: true, browsable: true }; |
| 240 | + |
| 241 | + it('collapses a lone schema named after the plugin', () => { |
| 242 | + const node = buildPluginNode( |
| 243 | + plugin, |
| 244 | + { splunk: [{ name: 'splunk', plugin: 'splunk', type: 'schema', browsable: true }] }, |
| 245 | + { splunk: [{ name: 'main', schema: 'splunk', type: 'TABLE' }] }, |
| 246 | + {}, {}, {}, {}, |
| 247 | + ); |
| 248 | + |
| 249 | + expect(node.children?.map((c) => c.key)).toEqual(['table:splunk:main']); |
| 250 | + }); |
| 251 | + |
| 252 | + it('keeps the schema level when schemas differ from the plugin name', () => { |
| 253 | + const node = buildPluginNode( |
| 254 | + plugin, |
| 255 | + { splunk: [{ name: 'splunk.audit', plugin: 'splunk', type: 'schema', browsable: true }] }, |
| 256 | + {}, {}, {}, {}, {}, |
| 257 | + ); |
| 258 | + |
| 259 | + expect(node.children?.map((c) => c.key)).toEqual(['schema:splunk.audit']); |
| 260 | + }); |
| 261 | +}); |
0 commit comments