Skip to content

Commit

Permalink
Add some more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarkelov committed May 7, 2019
1 parent 2b2caf0 commit 27d0c1f
Showing 1 changed file with 46 additions and 22 deletions.
68 changes: 46 additions & 22 deletions tests/Slider.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ describe('Slider', () => {
const wrapper = mount(
<Nouislider range={{ min: 0, max: 100 }} start={[20, 80]} connect />,
);

expect(wrapper.render().hasClass('noUi-target')).toBe(true);
});

Expand All @@ -34,7 +33,7 @@ describe('Slider', () => {
connect
/>,
);
expect(wrapper.render().hasClass('test')).toBe(true);
expect(wrapper.hasClass('test')).toBe(true);
});

test('should add cursor style if clickablePips props was passed', () => {
Expand All @@ -49,31 +48,56 @@ describe('Slider', () => {
}}
/>,
);
expect(
wrapper
.render()
.html()
.includes('cursor: pointer'),
).toBe(true);
});

test('areEqual return right result', () => {
const wrapper = mount(
<Nouislider
className="test"
range={{ min: 0, max: 100 }}
start={20}
connect
/>,
);
wrapper.setProps({ start: 80 });
expect(wrapper.render().html().includes('aria-valuenow="80.0"')).toBe(true);
expect(wrapper.html().includes('cursor: pointer')).toBe(true);
});

test('disabled prop should passed correctly', () => {
const wrapper = mount(
<Nouislider range={{ min: 0, max: 100 }} start={[20, 80]} disabled />,
);
expect(wrapper.render().prop('disabled')).toBe(true);
expect(wrapper.prop('disabled')).toBe(true);
});

describe('areEqual', () => {
test('return right result for start', () => {
const wrapper = mount(
<Nouislider
className="test"
range={{ min: 0, max: 100 }}
start={20}
connect
/>,
);
wrapper.setProps({ start: 80 });
expect(wrapper.html().includes('aria-valuenow="80.0"')).toBe(true);
});

test('return right result for disabled', () => {
const wrapper = mount(
<Nouislider
className="test"
range={{ min: 0, max: 100 }}
start={20}
connect
disabled={false}
/>,
);
wrapper.setProps({ disabled: true });
expect(wrapper.prop('disabled')).toBe(true);
});

test('return right result for range', () => {
const wrapper = mount(
<Nouislider
className="test"
range={{ min: 0, max: 50 }}
start={20}
connect
disabled={false}
/>,
);
wrapper.setProps({ range: { min: 0, max: 100 } });
expect(wrapper.html().includes('aria-valuemax="100.0"')).toBe(true);
});
});
});

0 comments on commit 27d0c1f

Please sign in to comment.