Skip to content

Commit

Permalink
fix(Toggle): fix the height problem of the switch element (#3780)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonguo committed May 3, 2024
1 parent d833a0a commit ff1570c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/Toggle/styles/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// todo: Consider renaming as .rs-toggle
.rs-toggle {
position: relative;
display: inline-block;

// Default size is middle.
.toggle(md);
Expand Down
23 changes: 15 additions & 8 deletions src/Toggle/test/ToggleStylesSpec.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
import React from 'react';
import { getDOMNode, getStyle, toRGB } from '@test/utils';
import { render } from '@testing-library/react';
import { toRGB } from '@test/utils';
import Toggle from '../index';

import '../styles/index.less';

describe('Toggle styles', () => {
it('Should render the correct styles', () => {
const dom = getDOMNode(<Toggle />);
assert.equal(
getStyle(dom.querySelector('.rs-toggle-presentation') as HTMLElement, 'backgroundColor'),
toRGB('#d9d9d9'),
'Toggle background-color'
it('Should render the correct background color', () => {
const { container } = render(<Toggle />);

// eslint-disable-next-line testing-library/no-container
expect(container.querySelector('.rs-toggle-presentation')).to.have.style(
'background-color',
toRGB('#d9d9d9')
);
});

it('Should be inline-block', () => {
const { container } = render(<Toggle />);

expect(container.firstChild).to.have.style('display', 'inline-block');
});
});

0 comments on commit ff1570c

Please sign in to comment.