|
| 1 | +/* global describe, it */ |
| 2 | +/* eslint react/prefer-stateless-function: 0 */ |
| 3 | + |
| 4 | +import { React, TestUtils, expect } from './helpers' |
| 5 | +import loopable from '../src/loop' |
| 6 | + |
| 7 | +describe('Loopable', () => { |
| 8 | + it('should return first-child if first', () => { |
| 9 | + expect(loopable(0, 4)).to.eql({ 'first-child': true, 'nth-child': 0, 'even': true }) |
| 10 | + }) |
| 11 | + |
| 12 | + it('should return last-child if last', () => { |
| 13 | + expect(loopable(3, 4)).to.eql({ 'last-child': true, 'nth-child': 3, 'odd': true }) |
| 14 | + }) |
| 15 | + |
| 16 | + it('should return even if even', () => { |
| 17 | + expect(loopable(2, 4)).to.eql({ 'even': true, 'nth-child': 2 }) |
| 18 | + }) |
| 19 | + |
| 20 | + it('should return odd if odd', () => { |
| 21 | + expect(loopable(1, 4)).to.eql({ 'odd': true, 'nth-child': 1 }) |
| 22 | + }) |
| 23 | + |
| 24 | + it('should return simple css', () => { |
| 25 | + class Component extends React.Component { |
| 26 | + render() { |
| 27 | + return <div className="body" /> |
| 28 | + } |
| 29 | + } |
| 30 | + const component = TestUtils.renderIntoDocument(<Component { ...loopable(3, 4) } />) |
| 31 | + expect(component.props).to.eql({ 'last-child': true, 'nth-child': 3, 'odd': true }) |
| 32 | + }) |
| 33 | +}) |
0 commit comments