-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
botonic-react: add tests to wa product carousel component
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
...ages/botonic-react/tests/components/__snapshots__/whatsapp-product-carousel.test.jsx.snap
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[`renders Whatsapp Product Carousel component with card indexes 1`] = ` | ||
<message | ||
bodyParameters="[{"type":"text","text":"Pepito"},{"type":"text","text":"Test"}]" | ||
cards="[{"card_index":1,"catalog_id":"fake-catalog-id","product_retailer_id":"fake-product-id-2"},{"card_index":1,"catalog_id":"fake-catalog-id","product_retailer_id":"fake-product-id-1"}]" | ||
templateLanguage="en_US" | ||
templateName="fake-template-name" | ||
type="whatsapp-product-carousel" | ||
/> | ||
`; | ||
|
||
exports[`renders Whatsapp Product Carousel component without card indexes 1`] = ` | ||
<message | ||
bodyParameters="[{"type":"text","text":"Pepito"},{"type":"text","text":"Test"}]" | ||
cards="[{"card_index":0,"catalog_id":"fake-catalog-id","product_retailer_id":"fake-product-id-2"},{"card_index":1,"catalog_id":"fake-catalog-id","product_retailer_id":"fake-product-id-1"}]" | ||
templateLanguage="en_US" | ||
templateName="fake-template-name" | ||
type="whatsapp-product-carousel" | ||
/> | ||
`; |
48 changes: 48 additions & 0 deletions
48
packages/botonic-react/tests/components/whatsapp-product-carousel.test.jsx
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,48 @@ | ||
import { expect, test } from '@jest/globals' | ||
import React from 'react' | ||
import TestRenderer from 'react-test-renderer' | ||
|
||
import { WhatsappProductCarousel } from '../../src/components' | ||
|
||
const renderToJSON = sut => TestRenderer.create(sut).toJSON() | ||
|
||
const getProps = withIndexes => { | ||
return { | ||
templateName: 'fake-template-name', | ||
templateLanguage: 'en_US', | ||
cards: [ | ||
{ | ||
card_index: withIndexes ? 1 : undefined, | ||
catalog_id: 'fake-catalog-id', | ||
product_retailer_id: 'fake-product-id-2', | ||
}, | ||
{ | ||
card_index: withIndexes ? 0 : undefined, | ||
catalog_id: 'fake-catalog-id', | ||
product_retailer_id: 'fake-product-id-1', | ||
}, | ||
], | ||
bodyParameters: [ | ||
{ | ||
type: 'text', | ||
text: 'Pepito', | ||
}, | ||
{ | ||
type: 'text', | ||
text: 'Test', | ||
}, | ||
], | ||
} | ||
} | ||
|
||
test('renders Whatsapp Product Carousel component without card indexes', () => { | ||
const props = getProps(false) | ||
const tree = renderToJSON(<WhatsappProductCarousel {...props} />) | ||
expect(tree).toMatchSnapshot() | ||
}) | ||
|
||
test('renders Whatsapp Product Carousel component with card indexes', () => { | ||
const props = getProps(true) | ||
const tree = renderToJSON(<WhatsappProductCarousel {...props} />) | ||
expect(tree).toMatchSnapshot() | ||
}) |