-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
12 changed files
with
12,258 additions
and
7,898 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
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
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 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,46 @@ | ||
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,31 @@ | ||
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,24 @@ | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
import ProductCard, { ProductTitle } from '../../src/components'; | ||
import { product1 } from '../data/products'; | ||
|
||
describe('ProductTitle', () => { | ||
test('debe mostrar el componente con el titulo personalizado', () => { | ||
const wrapper = renderer.create(<ProductTitle title="Custom Product" />) | ||
|
||
expect(wrapper.toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
test('debe mostrar el componente con el titulo por defecto', () => { | ||
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,27 @@ | ||
// 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> | ||
`; |
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[`ProductImage debe de mostrar el componente con la imagen del producto 1`] = ` | ||
<div | ||
className="productCard undefined" | ||
> | ||
<img | ||
alt="Product Image" | ||
className="productImg undefined" | ||
src="./coffee-mug.png" | ||
/> | ||
</div> | ||
`; | ||
|
||
exports[`ProductImage debe de mostrar el componente correctamente con la imagen personalizada 1`] = ` | ||
<img | ||
alt="Product Image" | ||
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 mostrar el componente con el titulo personalizado 1`] = ` | ||
<span | ||
className="productDescription undefined" | ||
> | ||
Custom Product | ||
</span> | ||
`; | ||
|
||
exports[`ProductTitle debe mostrar el componente con el titulo por defecto 1`] = ` | ||
<div | ||
className="productCard undefined" | ||
> | ||
<span | ||
className="productDescription undefined" | ||
> | ||
Coffee Mug - Sin imagen | ||
</span> | ||
</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,10 @@ | ||
export const product1 = { | ||
id: '1', | ||
title: 'Coffee Mug - Sin imagen', | ||
} | ||
|
||
export const product2 = { | ||
id: '1', | ||
title: 'Coffee Mug - Con imagen', | ||
img: './coffee-mug.png' | ||
} |