-
Notifications
You must be signed in to change notification settings - Fork 0
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
602436a
commit d02a073
Showing
10 changed files
with
1,353 additions
and
390 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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,11 +1,10 @@ | ||
import * as React from 'react'; | ||
// import * as React from 'react'; | ||
import * as ReactDOM from 'react-dom'; | ||
import { Thing } from '../src'; | ||
|
||
describe('it', () => { | ||
it('renders without crashing', () => { | ||
const div = document.createElement('div'); | ||
ReactDOM.render(<Thing />, div); | ||
// ReactDOM.render(<Thing />, div); | ||
ReactDOM.unmountComponentAtNode(div); | ||
}); | ||
}); |
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,43 @@ | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
import { ProductCard } from '../../src/components'; | ||
import { product1 } from '../data/products'; | ||
|
||
const { act } = renderer; | ||
|
||
describe('ProductCard', () => { | ||
test('Debe de mostrar el componente correctamente', () => { | ||
const wrapper = renderer.create( | ||
<ProductCard product={product1}> | ||
{() => <h1>Product Card</h1>} | ||
</ProductCard> | ||
); | ||
|
||
expect(wrapper.toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
test('Debe de incrementar el contador', () => { | ||
const wrapper = renderer.create( | ||
<ProductCard product={product1}> | ||
{({ count, increaseBy }) => ( | ||
<> | ||
<h1>Product Card</h1> | ||
<span>{count}</span> | ||
<button onClick={() => increaseBy(1)}></button> | ||
</> | ||
)} | ||
</ProductCard> | ||
); | ||
|
||
let tree = wrapper.toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
|
||
act(() => { | ||
(tree as any).children[2].props.onClick(); | ||
}); | ||
|
||
tree = wrapper.toJSON(); | ||
|
||
expect((tree as any).children[1].children[0]).toBe('1'); | ||
}); | ||
}); |
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,20 @@ | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
import { ProductImage, ProductCard } from '../../src/components'; | ||
import { product2 } from '../data/products'; | ||
|
||
describe('ProductImage', () => { | ||
test('Debe de mostrar el componente correctamente con la imagen personalizada', () => { | ||
const wrapper = renderer.create(<ProductImage img="https://hola.jpg" />); | ||
|
||
expect(wrapper.toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
test('Debe de mostrar el componente con la imagen del producto', () => { | ||
const wrapper = renderer.create( | ||
<ProductCard product={product2}>{() => <ProductImage />}</ProductCard> | ||
); | ||
|
||
expect(wrapper.toJSON()).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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
import { ProductTitle, ProductCard } from '../../src/components'; | ||
import { product1 } from '../data/products'; | ||
|
||
describe('ProductTitle', () => { | ||
test('Debe de mostrar el componente correctamente con el titulo personalizado', () => { | ||
const wrapper = renderer.create( | ||
<ProductTitle title="Custom Product" className="custom-class" /> | ||
); | ||
expect(wrapper.toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
test('Debe de mostrar el componente con el nombre del producto', () => { | ||
const wrapper = renderer.create( | ||
<ProductCard product={product1}>{() => <ProductTitle />}</ProductCard> | ||
); | ||
expect(wrapper.toJSON()).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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ProductCard Debe de incrementar el contador 1`] = ` | ||
<div | ||
className="productCard undefined" | ||
> | ||
<h1> | ||
Product Card | ||
</h1> | ||
<span> | ||
0 | ||
</span> | ||
<button | ||
onClick={[Function]} | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`ProductCard Debe de mostrar el componente correctamente 1`] = ` | ||
<div | ||
className="productCard undefined" | ||
> | ||
<h1> | ||
Product Card | ||
</h1> | ||
</div> | ||
`; | ||
|
||
exports[`ProductCard debe de incrementar el contador 1`] = ` | ||
<div | ||
className="productCard undefined" | ||
> | ||
<h1> | ||
Product Card | ||
</h1> | ||
<span> | ||
0 | ||
</span> | ||
<button | ||
onClick={[Function]} | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`ProductCard debe de mostrar el componente correctamente 1`] = ` | ||
<div | ||
className="productCard undefined" | ||
> | ||
<h1> | ||
Product Card | ||
</h1> | ||
</div> | ||
`; |
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,41 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ProductImage Debe de mostrar el componente con la imagen del producto 1`] = ` | ||
<div | ||
className="productCard undefined" | ||
> | ||
<img | ||
alt="Product" | ||
className="productImg undefined" | ||
src="./coffee-mug.png" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`ProductImage Debe de mostrar el componente correctamente con la imagen personalizada 1`] = ` | ||
<img | ||
alt="Product" | ||
className="productImg undefined" | ||
src="https://hola.jpg" | ||
/> | ||
`; | ||
|
||
exports[`ProductImage debe de mostrar el componente con la imagen del producto 1`] = ` | ||
<div | ||
className="productCard undefined" | ||
> | ||
<img | ||
alt="Product" | ||
className="productImg undefined" | ||
src="./coffee-mug.png" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`ProductImage debe de mostrar el componente correctamente con la imagen personalizada 1`] = ` | ||
<img | ||
alt="Product" | ||
className="productImg undefined" | ||
src="https://hola.jpg" | ||
/> | ||
`; |
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,21 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ProductTitle Debe de mostrar el componente con el nombre del producto 1`] = ` | ||
<div | ||
className="productCard undefined" | ||
> | ||
<span | ||
className="productDescription undefined" | ||
> | ||
Coffee Mug - Sin Imagen | ||
</span> | ||
</div> | ||
`; | ||
|
||
exports[`ProductTitle Debe de mostrar el componente correctamente con el titulo personalizado 1`] = ` | ||
<span | ||
className="productDescription custom-class" | ||
> | ||
Custom Product | ||
</span> | ||
`; |
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,11 @@ | ||
export const product1 = { | ||
id: '1', | ||
title: 'Coffee Mug - Sin Imagen', | ||
// img: './coffee-mug.png' | ||
} | ||
|
||
export const product2 = { | ||
id: '2', | ||
title: 'Coffee Mug - Con Imagen', | ||
img: './coffee-mug.png' | ||
} |