Skip to content

Commit

Permalink
test(ButtonSet): refactor test file structure
Browse files Browse the repository at this point in the history
  • Loading branch information
emyarod committed Aug 6, 2020
1 parent db26942 commit 1d32b4c
Showing 1 changed file with 26 additions and 31 deletions.
57 changes: 26 additions & 31 deletions packages/react/src/components/ButtonSet/ButtonSet-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,31 @@ describe('ButtonSet', () => {
wrapper = shallow(<ButtonSet className="extra-class" />);
});

describe('Renders as expected', () => {
describe('renders children as expected', () => {
it('empty set', () => {
expect(wrapper.find('.child').length).toBe(0);
});

it('nonempty set', () => {
wrapper = shallow(
<ButtonSet>
<div className="test-child" />
<div className="test-child" />
</ButtonSet>
);
expect(wrapper.find('.test-child').length).toBe(2);
});
});
it('renders wrapper as expected', () => {
expect(wrapper.length).toBe(1);
});

describe('has the expected classes', () => {
it('horizontal set', () => {
expect(wrapper.hasClass(`${prefix}--btn-set`)).toEqual(true);
});

it('vertical set', () => {
wrapper.setProps({ stacked: true });
expect(wrapper.hasClass(`${prefix}--btn-set`)).toEqual(true);
expect(wrapper.hasClass(`${prefix}--btn-set--stacked`)).toEqual(true);
});
});
it('should render empty set as expected', () => {
expect(wrapper.find('.child').length).toBe(0);
});

it('should render nonempty set as expected', () => {
wrapper = shallow(
<ButtonSet>
<div className="test-child" />
<div className="test-child" />
</ButtonSet>
);
expect(wrapper.find('.test-child').length).toBe(2);
});

it('should render wrapper as expected', () => {
expect(wrapper.length).toBe(1);
});

it('should have the expected classes in a horizontal set', () => {
expect(wrapper.hasClass(`${prefix}--btn-set`)).toEqual(true);
});

it('should have the expected classes in a vertical set', () => {
wrapper.setProps({ stacked: true });
expect(wrapper.hasClass(`${prefix}--btn-set`)).toEqual(true);
expect(wrapper.hasClass(`${prefix}--btn-set--stacked`)).toEqual(true);
});
});

0 comments on commit 1d32b4c

Please sign in to comment.