Add convert to subgraph toolbox button

This commit is contained in:
filtered
2025-05-22 18:19:15 +10:00
parent bdc1ac1004
commit 6f9c481b38
4 changed files with 198 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
import { mount } from '@vue/test-utils'
import Button from 'primevue/button'
import PrimeVue from 'primevue/config'
import Tooltip from 'primevue/tooltip'
import { describe, expect, it, vi } from 'vitest'
import ConvertToSubgraphButton from '@/components/graph/selectionToolbox/ConvertToSubgraphButton.vue'
// Mock the command store
vi.mock('@/stores/commandStore', () => ({
useCommandStore: vi.fn(() => ({
execute: vi.fn()
}))
}))
// Mock i18n
vi.mock('vue-i18n', () => ({
useI18n: vi.fn(() => ({
t: vi.fn((key) => key)
}))
}))
describe('ConvertToSubgraphButton', () => {
const mountComponent = () => {
return mount(ConvertToSubgraphButton, {
global: {
plugins: [PrimeVue],
directives: { tooltip: Tooltip },
components: { Button }
}
})
}
it('renders correctly', () => {
const wrapper = mountComponent()
expect(wrapper.find('button').exists()).toBe(true)
expect(wrapper.find('.pi-box').exists()).toBe(true)
})
it('has the correct tooltip', () => {
const wrapper = mountComponent()
const buttonElement = wrapper.find('button')
// Check that the tooltip directive is applied
expect(buttonElement.attributes('data-pd-tooltip')).toBe('true')
})
})