|
| 1 | +import { describe, it, expect } from 'vitest'; |
| 2 | +import { mount } from '@vue/test-utils'; |
| 3 | +import MultipleCellMethodsWarning from '../MultipleCellMethodsWarning.vue'; |
| 4 | + |
| 5 | +describe('MultipleCellMethodsWarning', () => { |
| 6 | + // Helper to create wrapper |
| 7 | + const createWrapper = (props: any) => { |
| 8 | + return mount(MultipleCellMethodsWarning, { |
| 9 | + props, |
| 10 | + }); |
| 11 | + }; |
| 12 | + |
| 13 | + // Test that the component renders when visible is true |
| 14 | + it('renders warning when visible is true', () => { |
| 15 | + const wrapper = createWrapper({ |
| 16 | + visible: true, |
| 17 | + }); |
| 18 | + |
| 19 | + expect(wrapper.html()).toBeTruthy(); |
| 20 | + expect(wrapper.text()).toContain('Multiple Cell Methods Detected:'); |
| 21 | + expect(wrapper.text()).toContain('variable_cell_methods'); |
| 22 | + expect(wrapper.text()).toContain('to_dask()'); |
| 23 | + }); |
| 24 | + |
| 25 | + // Test that the component does not render when visible is false |
| 26 | + it('does not render when visible is false', () => { |
| 27 | + const wrapper = createWrapper({ |
| 28 | + visible: false, |
| 29 | + }); |
| 30 | + |
| 31 | + expect(wrapper.find('.bg-orange-50').exists()).toBe(false); |
| 32 | + }); |
| 33 | + |
| 34 | + // Test that warning icon is displayed |
| 35 | + it('displays warning icon', () => { |
| 36 | + const wrapper = createWrapper({ |
| 37 | + visible: true, |
| 38 | + }); |
| 39 | + |
| 40 | + const icon = wrapper.find('.pi-exclamation-triangle'); |
| 41 | + expect(icon.exists()).toBe(true); |
| 42 | + }); |
| 43 | + |
| 44 | + // Test that code elements are rendered for technical terms |
| 45 | + it('renders code elements for technical terms', () => { |
| 46 | + const wrapper = createWrapper({ |
| 47 | + visible: true, |
| 48 | + }); |
| 49 | + |
| 50 | + const codeElements = wrapper.findAll('code'); |
| 51 | + expect(codeElements.length).toBeGreaterThanOrEqual(2); |
| 52 | + expect(codeElements.some((el) => el.text().includes('variable_cell_methods'))).toBe(true); |
| 53 | + expect(codeElements.some((el) => el.text().includes('to_dask()'))).toBe(true); |
| 54 | + }); |
| 55 | + |
| 56 | + // Test that the component has proper styling classes |
| 57 | + it('has proper warning styling classes', () => { |
| 58 | + const wrapper = createWrapper({ |
| 59 | + visible: true, |
| 60 | + }); |
| 61 | + |
| 62 | + const outerDiv = wrapper.find('div'); |
| 63 | + expect(outerDiv.classes()).toContain('bg-orange-50'); |
| 64 | + expect(outerDiv.classes()).toContain('border-orange-200'); |
| 65 | + }); |
| 66 | +}); |
0 commit comments