import { mount } from '@vue/test-utils' import { describe, expect, it } from 'vitest' import AdductText from '../../components/AdductText.vue' import ChemicalFormula from '../../components/ChemicalFormula.vue' describe('ChemicalFormula', () => { it('renders formula typography and an adduct as separate parts', () => { const wrapper = mount(ChemicalFormula, { props: { formula: 'C6H12O6', adduct: '[M+H]+', pill: true }, }) expect(wrapper.findAll('.mint-chem-formula__subscript').map(node => node.text())) .toEqual(['6', '12', '6']) expect(wrapper.getComponent(AdductText).text()).toBe('[M+H]+') expect(wrapper.classes()).toContain('mint-chem-formula--pill') }) it('should render a hydrate coefficient full size when the formula has a hydrate', () => { const wrapper = mount(ChemicalFormula, { props: { formula: 'CuSO4ยท5H2O' } }) expect(wrapper.find('.mint-chem-formula__coefficient').text()).toBe('5') }) it('renders explicit empty text when no formula is available', () => { expect(mount(ChemicalFormula, { props: { emptyText: 'Unknown' } }).text()).toBe('Unknown') }) it('supports standalone sans-serif adduct labels', () => { expect(mount(AdductText, { props: { value: '[M-H]-', font: 'sans' } }).classes()) .toContain('mint-adduct-text--sans') }) it('should render a trailing adduct charge as a superscript when the value is bracketed', () => { expect(mount(AdductText, { props: { value: '[M+2H]2+' } }).get('.mint-adduct-text__charge').text()) .toBe('2+') }) it('should keep an unbracketed adduct as one run when no charge can be split', () => { expect(mount(AdductText, { props: { value: 'M+H' } }).find('.mint-adduct-text__charge').exists()) .toBe(false) }) })