Comments (1)
I rewrote the tests for the component and also added a test for "Ref". For all other components, I would use this testing way. @estevanmaito Is there any further development of the project planned? I would rewrite all the tests for RTL compatibility.
import React, { createRef } from 'react'
import { render, screen, within } from '@testing-library/react'
import Avatar from '../Avatar'
const avatar = () => screen.getByTestId('avatar')
const img = () => within(avatar()).getByRole('img')
describe('Avatar', () => {
it('should render without crashing', () => {
render(<Avatar src="#" />)
expect(avatar()).toBeInTheDocument()
})
describe('Root', () => {
it('should render with base styles', () => {
const expectedClasses = 'relative rounded-full inline-block'
render(<Avatar src="#" />)
expect(avatar()).toHaveClass(expectedClasses)
})
describe('prop: ref', () => {
it('should be able to access the <Avatar />', () => {
const avatarRef = createRef<HTMLDivElement>()
render(<Avatar ref={avatarRef} src="#" />)
expect(avatar()).toEqual(avatarRef.current)
})
})
describe('prop: size', () => {
it('should render with large styles', () => {
const expectedClasses = 'w-10 h-10'
render(<Avatar src="#" size="large" />)
expect(avatar()).toHaveClass(expectedClasses)
})
it('should render with regular styles', () => {
const expectedClasses = 'w-8 h-8'
render(<Avatar src="#" size="regular" />)
expect(avatar()).toHaveClass(expectedClasses)
})
it('should render with small styles', () => {
const expectedClasses = 'w-6 h-6'
render(<Avatar src="#" size="small" />)
expect(avatar()).toHaveClass(expectedClasses)
})
})
})
describe('Image', () => {
it('should contain an image with the correct src', () => {
const expectedSrc = '#'
render(<Avatar src="#" />)
expect(img()).toHaveAttribute('src', expectedSrc)
})
it('should contain an image with alt text', () => {
const expectedAltText = 'Lorem'
render(<Avatar src="#" alt="Lorem" />)
expect(img()).toHaveAccessibleName(expectedAltText)
})
})
})
from windmill-react-ui.
Related Issues (20)
- Select doesn't propagate undefined value set in option tag
- .form-input class breaks with Tailwind v2 HOT 1
- Typescript error with Input component: "Property 'css' is missing" HOT 4
- DateTime Picker & Tabs
- Can you change the theme color? HOT 12
- can you opensource the doc. HOT 1
- Is project still maintained?
- I want tailwind v3 compatibility for windmill react ui. HOT 5
- onChange function on pagination component shouldn't be ejecuted on the firtst render.
- TableFooter could use <tfoot> ? HOT 2
- ModalHeader should have option to position contents in `<header>` tag
- Having problem getting it to work with tailwind v3 . HOT 3
- Pagination information should receive labels instead of setting values as default in order to make it multi languange
- Trying to setup `windmill` library and got error after start app HOT 3
- Next Data Set Buttons in pagination that will take custom user function as prop HOT 1
- Is this project abanonded?
- This is dead af HOT 1
- WindmillUI.com domain has expired
- RTL feature HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from windmill-react-ui.