-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
970f83f
commit e3b817c
Showing
11 changed files
with
168 additions
and
256 deletions.
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 +1,6 @@ | ||
module.exports = { extends: '@case/eslint-config' } | ||
module.exports = { | ||
extends: '@case/eslint-config', | ||
env: { | ||
jest: true | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`reactCSS should return complex css 1`] = ` | ||
<div> | ||
<div | ||
className="card" | ||
style={ | ||
Object { | ||
"MozBoxShadow": "0 4px 8px rgba(0,0,0,.15)", | ||
"OBoxShadow": "0 4px 8px rgba(0,0,0,.15)", | ||
"WebkitBoxShadow": "0 4px 8px rgba(0,0,0,.15)", | ||
"boxShadow": "0 4px 8px rgba(0,0,0,.15)", | ||
"msBoxShadow": "0 4px 8px rgba(0,0,0,.15)", | ||
} | ||
} | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`reactCSS should return multiple css 1`] = ` | ||
<div> | ||
<div | ||
className="title" | ||
style={ | ||
Object { | ||
"color": "red", | ||
} | ||
} | ||
/> | ||
<div | ||
className="card" | ||
style={ | ||
Object { | ||
"MozBoxShadow": "0 0 2px rgba(0,0,0,.1)", | ||
"OBoxShadow": "0 0 2px rgba(0,0,0,.1)", | ||
"WebkitBoxShadow": "0 0 2px rgba(0,0,0,.1)", | ||
"boxShadow": "0 0 2px rgba(0,0,0,.1)", | ||
"msBoxShadow": "0 0 2px rgba(0,0,0,.1)", | ||
} | ||
} | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`reactCSS should return simple css 1`] = ` | ||
<div | ||
className="body" | ||
style={ | ||
Object { | ||
"backgroundColor": "#fafafa", | ||
} | ||
} | ||
/> | ||
`; |
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
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,48 +1,39 @@ | ||
/* global describe, it */ | ||
|
||
import { expect } from './helpers' | ||
import flattenNames from '../src/flattenNames' | ||
|
||
describe('Combine', () => { | ||
it('should return basic strings', () => { | ||
test('should return basic strings', () => { | ||
const before = ['foo', 'bar', 'baz'] | ||
const after = ['foo', 'bar', 'baz'] | ||
|
||
expect(flattenNames(before)).to.eql(after) | ||
expect(flattenNames(before)).toEqual(after) | ||
}) | ||
|
||
it('should flatten arrays', () => { | ||
test('should flatten arrays', () => { | ||
const before = [['foo', 'bar'], [[['baz']]]] | ||
const after = ['foo', 'bar', 'baz'] | ||
|
||
expect(flattenNames(before)).to.eql(after) | ||
expect(flattenNames(before)).toEqual(after) | ||
}) | ||
|
||
it('should return key and key-true when value is true', () => { | ||
test('should return key and key-true when value is true', () => { | ||
const before = [{ foo: true }] | ||
const after = ['foo', 'foo-true'] | ||
|
||
expect(flattenNames(before)).to.eql(after) | ||
expect(flattenNames(before)).toEqual(after) | ||
}) | ||
|
||
it('should return key-false when value is false', () => { | ||
test('should return key-false when value is false', () => { | ||
const before = [{ foo: false }] | ||
const after = ['foo-false'] | ||
|
||
expect(flattenNames(before)).to.eql(after) | ||
expect(flattenNames(before)).toEqual(after) | ||
}) | ||
|
||
it('should return key-value when value is a string', () => { | ||
test('should return key-value when value is a string', () => { | ||
const before = [{ foo: 'bar' }] | ||
const after = ['foo-bar'] | ||
|
||
expect(flattenNames(before)).to.eql(after) | ||
expect(flattenNames(before)).toEqual(after) | ||
}) | ||
|
||
it('should return key-value when value is a number', () => { | ||
test('should return key-value when value is a number', () => { | ||
const before = [{ foo: 2 }] | ||
const after = ['foo-2'] | ||
|
||
expect(flattenNames(before)).to.eql(after) | ||
expect(flattenNames(before)).toEqual(after) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import React from 'react' | ||
import renderer from 'react-test-renderer' | ||
import reactCSS from '../src' | ||
|
||
describe('reactCSS', () => { | ||
test('should return simple css', () => { | ||
const Component = () => { | ||
const styles = reactCSS({ | ||
'default': { | ||
body: { | ||
backgroundColor: '#fafafa', | ||
}, | ||
}, | ||
}) | ||
return <div className="body" style={ styles.body } /> | ||
} | ||
const tree = renderer.create(<Component />).toJSON() | ||
expect(tree).toMatchSnapshot() | ||
}) | ||
|
||
test('should return multiple css', () => { | ||
const Component = ({ color }) => { | ||
const styles = reactCSS({ | ||
'default': { | ||
title: { | ||
color, | ||
}, | ||
card: { | ||
boxShadow: '0 0 2px rgba(0,0,0,.1)', | ||
}, | ||
}, | ||
}) | ||
return ( | ||
<div> | ||
<div className="title" style={ styles.title } /> | ||
<div className="card" style={ styles.card } /> | ||
</div> | ||
) | ||
} | ||
const tree = renderer.create(<Component color="red" />).toJSON() | ||
expect(tree).toMatchSnapshot() | ||
}) | ||
|
||
test('should return complex css', () => { | ||
const Component = ({ zIndex }) => { | ||
const styles = reactCSS({ | ||
'default': { | ||
card: { | ||
boxShadow: '0 0 2px rgba(0,0,0,.1)', | ||
}, | ||
}, | ||
'zIndex-2': { | ||
card: { | ||
boxShadow: '0 4px 8px rgba(0,0,0,.15)', | ||
}, | ||
}, | ||
}, { zIndex }) | ||
return ( | ||
<div> | ||
<div className="card" style={ styles.card } /> | ||
</div> | ||
) | ||
} | ||
const tree = renderer.create(<Component zIndex="2" />).toJSON() | ||
expect(tree).toMatchSnapshot() | ||
}) | ||
}) |
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,33 +1,26 @@ | ||
/* global describe, it */ | ||
/* eslint react/prefer-stateless-function: 0 */ | ||
|
||
import { React, TestUtils, expect } from './helpers' | ||
import React from 'react' | ||
import loopable from '../src/loop' | ||
|
||
describe('Loopable', () => { | ||
it('should return first-child if first', () => { | ||
expect(loopable(0, 4)).to.eql({ 'first-child': true, 'nth-child': 0, 'even': true }) | ||
test('should return first-child if first', () => { | ||
expect(loopable(0, 4)).toEqual({ 'first-child': true, 'nth-child': 0, 'even': true }) | ||
}) | ||
|
||
it('should return last-child if last', () => { | ||
expect(loopable(3, 4)).to.eql({ 'last-child': true, 'nth-child': 3, 'odd': true }) | ||
test('should return last-child if last', () => { | ||
expect(loopable(3, 4)).toEqual({ 'last-child': true, 'nth-child': 3, 'odd': true }) | ||
}) | ||
|
||
it('should return even if even', () => { | ||
expect(loopable(2, 4)).to.eql({ 'even': true, 'nth-child': 2 }) | ||
test('should return even if even', () => { | ||
expect(loopable(2, 4)).toEqual({ 'even': true, 'nth-child': 2 }) | ||
}) | ||
|
||
it('should return odd if odd', () => { | ||
expect(loopable(1, 4)).to.eql({ 'odd': true, 'nth-child': 1 }) | ||
test('should return odd if odd', () => { | ||
expect(loopable(1, 4)).toEqual({ 'odd': true, 'nth-child': 1 }) | ||
}) | ||
|
||
it('should return simple css', () => { | ||
class Component extends React.Component { | ||
render() { | ||
return <div className="body" /> | ||
} | ||
} | ||
const component = TestUtils.renderIntoDocument(<Component { ...loopable(3, 4) } />) | ||
expect(component.props).to.eql({ 'last-child': true, 'nth-child': 3, 'odd': true }) | ||
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 }) | ||
}) | ||
}) |
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
Oops, something went wrong.