Skip to content
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.

Commit

Permalink
rm -r
Browse files Browse the repository at this point in the history
  • Loading branch information
ooade committed Mar 16, 2018
1 parent e902374 commit ee63f1b
Show file tree
Hide file tree
Showing 7 changed files with 7,382 additions and 105 deletions.
26 changes: 0 additions & 26 deletions __tests__/__snapshots__/index.js.snap

This file was deleted.

73 changes: 10 additions & 63 deletions __tests__/index.js
Original file line number Diff line number Diff line change
@@ -1,70 +1,17 @@
import React from 'react'
import { configure, mount, shallow } from 'enzyme'
import { mount } from 'enzyme'

import Adapter from 'enzyme-adapter-react-16'
import EnzymeToJSON from 'enzyme-to-json'

import ReactRough from '../src'

// Setup Enzyme Adapter
configure({ adapter: new Adapter() })

import Image from '../src/'

const image =
'https://res.cloudinary.com/stackpie/image/upload/v1513979515/-895520106_m1whb3.jpg'

const placeholder = image.replace('/upload/', '/upload/c_thumb,w_30/')

describe('pimg', () => {
test('renders correctly', () => {
const component = mount(<Image src={image} />)

expect(EnzymeToJSON(component)).toMatchSnapshot()
})
})

describe('Image', () => {
test('generates placeholder when loading', () => {
const component = mount(<Image src={image} />)

if (component.state().loading) {
expect(component.state().placeholder).toBe(placeholder)
}
})

test('src is emptyString if omitted', () => {
const component = mount(<Image/>)

expect(component.props().src).toBe('')
})

test('can take a placeholder prop', () => {
const component = mount(
<Image src={image} placeholder='http://myPlaceholder' />
)

expect(EnzymeToJSON(component)).toMatchSnapshot()
})

test('uses the default classNames when loading', () => {
const component = mount(<Image src={image} />)

if (component.state().loading) {
expect(component.childAt(0).props().className).toBe('pimg pimg__loading')
}
})

test('uses the loadingClassName passed when loading', () => {
const component = mount(<Image className="myImage" loadingClassName="image_is_loading" src={image} />)

if (component.state().loading) {
expect(component.childAt(0).props().className).toBe('myImage image_is_loading')
}
})

test('appends `__loading` if loadingClassName isn\'t passed', () => {
const component = mount(<Image className="myImage" src={image} />)

if (component.state().loading) {
expect(component.childAt(0).props().className).toBe('myImage myImage__loading')
}
})
})
// describe('ReactRough', () => {
// test('renders correctly', () => {
// const component = mount(<ReactRough />)
// expect(EnzymeToJSON(component)).toMatchSnapshot()
// })
// })
24 changes: 13 additions & 11 deletions examples/basic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@ import ReactDOM from 'react-dom'
import ReactRough from '../../src'

const App = () => (
<ReactRough
width="500"
height="200"
render={rc => {
rc.circle(80, 120, 50) // centerX, centerY, diameter
rc.ellipse(300, 100, 150, 80) // centerX, centerY, width, height
rc.line(80, 120, 300, 100) // x1, y1, x2, y2
}}
>
{/* <Circle data={[80, 120, 50]} />
<div>
<ReactRough
width="500"
height="200"
render={rc => {
rc.circle(80, 120, 50) // centerX, centerY, diameter
rc.ellipse(300, 100, 150, 80) // centerX, centerY, width, height
rc.line(80, 120, 300, 100) // x1, y1, x2, y2
}}
>
{/* <Circle data={[80, 120, 50]} />
<Ellipse data={[300, 100, 150, 80]} />
<Line data={[80, 120, 300, 100]} /> */}
</ReactRough>
</ReactRough>
</div>
)

ReactDOM.render(<App />, document.getElementById('root'))
Loading

0 comments on commit ee63f1b

Please sign in to comment.