Skip to content

Commit

Permalink
chore: add VIcon vitest file(#20517)
Browse files Browse the repository at this point in the history
  • Loading branch information
iNSaNiA0821 committed Dec 12, 2024
1 parent 89c58dd commit 2cdef0f
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 126 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { VIcon } from '../VIcon'

// Utilities
import { render, screen } from '@test'

describe('VIcon', () => {
describe('icon prop', () => {
it('should render icon from default set', () => {
render(() => <VIcon icon="mdi-home" />)

const icon = screen.getByText('', { selector: '.mdi-home' })
expect(icon).toHaveClass('mdi-home')
expect(icon).toHaveClass('mdi')
})
})

describe('default slot', () => {
it('should render icon from default set', () => {
render(() => <VIcon>mdi-home</VIcon>)

const icon = screen.getByText('', { selector: '.mdi-home' })
expect(icon).toHaveClass('mdi-home')
expect(icon).toHaveClass('mdi')
})

it('should render default slot if no icon value is found', () => {
const Foo = () => (
<svg style="width: 100%; height: 100%;" class="foo">
<path d="M7,10L12,15L17,10H7Z" />
</svg>
)

render(() => (
<VIcon>
<Foo />
</VIcon>
))

const svg = screen.getByText('', { selector: '.foo' })
expect(svg).toBeInTheDocument()
})
})

it('should render svg icon', () => {
render(() => <VIcon icon="svg:M7,10L12,15L17,10H7Z" />)

const svg = screen.getByText('', { selector: 'svg' })
expect(svg).toBeInTheDocument()
const path = svg.querySelector('path')
expect(path).toHaveAttribute('d', 'M7,10L12,15L17,10H7Z')
})

it('should render class icon', () => {
render(() => <VIcon icon="class:foo" />)

const icon = screen.getByText('', { selector: '.foo' })
expect(icon).toHaveClass('foo')
})
})
126 changes: 0 additions & 126 deletions packages/vuetify/src/components/VIcon/__tests__/VIcon.spec.cy.tsx

This file was deleted.

0 comments on commit 2cdef0f

Please sign in to comment.