Skip to content

Commit 1300b0b

Browse files
committed
Update tests to get colors from CSS variables
1 parent f5757f6 commit 1300b0b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

src/__tests__/Skeleton.test.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ it('renders the required number of skeletons', () => {
2828
expect(skeletonElements).toHaveLength(4)
2929
})
3030

31+
it('changes the color of the skeleton', () => {
32+
render(<Skeleton baseColor="purple" highlightColor="red" />)
33+
34+
const skeleton = getSkeleton()
35+
36+
expect(skeleton.style.getPropertyValue('--base-color')).toBe('purple')
37+
expect(skeleton.style.getPropertyValue('--highlight-color')).toBe('red')
38+
})
39+
3140
it('renders a skeleton with styles', () => {
3241
const style = { borderRadius: 10, height: 50, width: 50 }
3342
render(<Skeleton style={style} />)

src/__tests__/SkeletonTheme.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ it('styles the skeleton', () => {
2525

2626
const skeleton = getSkeleton()
2727
expect(skeleton).toHaveStyle({ borderRadius: '1rem' })
28-
expect(skeleton).toHaveStyle({ backgroundColor: 'black' })
28+
expect(skeleton.style.getPropertyValue('--base-color')).toBe('black')
2929
})
3030

3131
it('is overridden by Skeleton props', () => {
@@ -37,7 +37,7 @@ it('is overridden by Skeleton props', () => {
3737

3838
const skeleton = getSkeleton()
3939
expect(skeleton).toHaveStyle({ borderRadius: '2rem' })
40-
expect(skeleton).toHaveStyle({ backgroundColor: 'black' })
40+
expect(skeleton.style.getPropertyValue('--base-color')).toBe('black')
4141
})
4242

4343
it('styles the skeleton through a portal', () => {
@@ -52,5 +52,5 @@ it('styles the skeleton through a portal', () => {
5252

5353
const skeleton = getSkeleton()
5454
expect(skeleton).toHaveStyle({ borderRadius: '1rem' })
55-
expect(skeleton).toHaveStyle({ backgroundColor: 'black' })
55+
expect(skeleton.style.getPropertyValue('--base-color')).toBe('black')
5656
})

0 commit comments

Comments
 (0)