-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add unit test and improve code coverage (#10)
- Loading branch information
Showing
1 changed file
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,54 @@ | ||
import expect from 'expect.js'; | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import TestUtils, { Simulate } from 'react-addons-test-utils'; | ||
import Enzyme, { mount } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-15' | ||
import TestUtils, { Simulate } from 'react-dom/test-utils'; | ||
import Carousel from '../src'; | ||
|
||
Enzyme.configure({ adapter: new Adapter() }) | ||
|
||
describe('Carousel', () => { | ||
it('className prop works', () => { | ||
const node = mount(<Carousel className="test-classname"/>) | ||
expect(node.props().className).to.equal('test-classname') | ||
}) | ||
|
||
it('prefixCls prop works', () => { | ||
const node = mount(<Carousel prefixCls="test-prefix"/>) | ||
expect(node.find('.test-prefix')).to.have.length(1) | ||
}) | ||
|
||
it('centerDots prop works', () => { | ||
const node1 = mount(<Carousel prefixCls="test-prefix" />) | ||
expect(node1.find('.test-prefix-dots-centered')).to.have.length(1) | ||
|
||
const node2 = mount(<Carousel prefixCls="test-prefix" centerDots={false}> | ||
</Carousel>) | ||
expect(node2.find('.test-prefix-dots-centered')).to.have.length(0) | ||
}) | ||
|
||
it('largeArrowsAndDots prop works', () => { | ||
const node1 = mount(<Carousel prefixCls="test-prefix"/>) | ||
expect(node1.find('.test-prefix-large-mode')).to.have.length(0) | ||
|
||
const node2 = mount(<Carousel prefixCls="test-prefix" largeArrowsAndDots/>) | ||
expect(node2.find('.test-prefix-large-mode')).to.have.length(1) | ||
}) | ||
|
||
it('arrows === always works', () => { | ||
const node1 = mount(<Carousel prefixCls="test-prefix" arrows="test"/>) | ||
expect(node1.find('.test-prefix-always-show-arrows')).to.have.length(0) | ||
|
||
const node2 = mount(<Carousel prefixCls="test-prefix" arrows="always"/>) | ||
expect(node1.find('.test-prefix-always-show-arrows')).to.have.length(0) | ||
}) | ||
|
||
it('coverage improve', () => { | ||
// code coverage for children.length > 0 | ||
mount(<Carousel> | ||
<div>a</div> | ||
</Carousel>) | ||
}) | ||
|
||
}); |