forked from casesandberg/reactcss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloop.test.js
More file actions
26 lines (21 loc) · 871 Bytes
/
loop.test.js
File metadata and controls
26 lines (21 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import React from 'react'
import loopable from '../src/loop'
describe('Loopable', () => {
test('should return first-child if first', () => {
expect(loopable(0, 4)).toEqual({ 'first-child': true, 'nth-child': 0, 'even': true })
})
test('should return last-child if last', () => {
expect(loopable(3, 4)).toEqual({ 'last-child': true, 'nth-child': 3, 'odd': true })
})
test('should return even if even', () => {
expect(loopable(2, 4)).toEqual({ 'even': true, 'nth-child': 2 })
})
test('should return odd if odd', () => {
expect(loopable(1, 4)).toEqual({ 'odd': true, 'nth-child': 1 })
})
test('should return simple css', () => {
const Component = () => <div className="body" />
const rendered = <Component { ...loopable(3, 4) } />
expect(rendered.props).toEqual({ 'last-child': true, 'nth-child': 3, 'odd': true })
})
})