@fiscozen/input 3.0.2 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1588,5 +1588,109 @@ describe('FzCurrencyInput', () => {
1588
1588
  })
1589
1589
  })
1590
1590
  })
1591
+
1592
+ describe('Slot forwarding', () => {
1593
+ it('should not render empty help text span when helpText slot is not provided', async () => {
1594
+ const wrapper = mount(FzCurrencyInput, {
1595
+ props: {
1596
+ label: 'Label',
1597
+ modelValue: 10,
1598
+ },
1599
+ })
1600
+
1601
+ await wrapper.vm.$nextTick()
1602
+
1603
+ const helpSpan = wrapper.find(`[id$="-help"]`)
1604
+ expect(helpSpan.exists()).toBe(false)
1605
+ })
1606
+
1607
+ it('should render help text span when helpText slot is provided', async () => {
1608
+ const wrapper = mount(FzCurrencyInput, {
1609
+ props: {
1610
+ label: 'Label',
1611
+ modelValue: 10,
1612
+ },
1613
+ slots: {
1614
+ helpText: 'Enter an amount',
1615
+ },
1616
+ })
1617
+
1618
+ await wrapper.vm.$nextTick()
1619
+
1620
+ const helpSpan = wrapper.find(`[id$="-help"]`)
1621
+ expect(helpSpan.exists()).toBe(true)
1622
+ expect(helpSpan.text()).toContain('Enter an amount')
1623
+ })
1624
+
1625
+ it('should render label from label prop when label slot is not provided', async () => {
1626
+ const wrapper = mount(FzCurrencyInput, {
1627
+ props: {
1628
+ label: 'Amount',
1629
+ modelValue: 10,
1630
+ },
1631
+ })
1632
+
1633
+ await wrapper.vm.$nextTick()
1634
+
1635
+ const label = wrapper.find('label')
1636
+ expect(label.exists()).toBe(true)
1637
+ expect(label.text()).toContain('Amount')
1638
+ })
1639
+
1640
+ it('should render custom label slot instead of label prop', async () => {
1641
+ const wrapper = mount(FzCurrencyInput, {
1642
+ props: {
1643
+ label: 'Amount',
1644
+ modelValue: 10,
1645
+ },
1646
+ slots: {
1647
+ label: '<strong>Custom Label</strong>',
1648
+ },
1649
+ })
1650
+
1651
+ await wrapper.vm.$nextTick()
1652
+
1653
+ const strong = wrapper.find('strong')
1654
+ expect(strong.exists()).toBe(true)
1655
+ expect(strong.text()).toBe('Custom Label')
1656
+
1657
+ const defaultLabel = wrapper.find('label')
1658
+ expect(defaultLabel.exists()).toBe(false)
1659
+ })
1660
+
1661
+ it('should not render error message container when errorMessage slot is not provided', async () => {
1662
+ const wrapper = mount(FzCurrencyInput, {
1663
+ props: {
1664
+ label: 'Label',
1665
+ modelValue: 10,
1666
+ error: true,
1667
+ },
1668
+ })
1669
+
1670
+ await wrapper.vm.$nextTick()
1671
+
1672
+ const errorContainer = wrapper.find('[role="alert"]')
1673
+ expect(errorContainer.exists()).toBe(false)
1674
+ })
1675
+
1676
+ it('should render error message when error is true and errorMessage slot is provided', async () => {
1677
+ const wrapper = mount(FzCurrencyInput, {
1678
+ props: {
1679
+ label: 'Label',
1680
+ modelValue: 10,
1681
+ error: true,
1682
+ },
1683
+ slots: {
1684
+ errorMessage: 'Invalid amount',
1685
+ },
1686
+ })
1687
+
1688
+ await wrapper.vm.$nextTick()
1689
+
1690
+ const errorContainer = wrapper.find('[role="alert"]')
1691
+ expect(errorContainer.exists()).toBe(true)
1692
+ expect(errorContainer.text()).toContain('Invalid amount')
1693
+ })
1694
+ })
1591
1695
  })
1592
1696