diff --git a/README.md b/README.md index a0848af..dcae97d 100644 --- a/README.md +++ b/README.md @@ -107,12 +107,10 @@ const finalHTML = ` #### [amp-accordion](https://www.ampproject.org/docs/reference/components/amp-accordion) -#### [amp-bind](https://www.ampproject.org/docs/reference/components/amp-bind) +#### [amp-ad](https://www.ampproject.org/docs/reference/components/amp-ad) #### [amp-install-serviceworker](https://www.ampproject.org/docs/reference/components/amp-install-serviceworker) -#### [amp-ad](https://www.ampproject.org/docs/reference/components/amp-ad) - Example usage: ```jsx @@ -129,6 +127,24 @@ Props: - dataNoServiceWorkerFallbackUrlMatch (optional) - dataNoServiceWorkerFallbackShellUrl (optional) +### [amp-bind](https://www.ampproject.org/docs/reference/components/amp-bind) +Example usage: +```jsx + +

I will get the [text] and [class] attributes

+
+``` +### [amp-state](https://www.ampproject.org/docs/reference/components/amp-bind) +Example usage: +```jsx + + {{ + dog: 10, + cat: 90 + }} + +``` + ## Todo - [ ] Define all the AMP components with their properties and scripts in a JSON file and use that to generate them. diff --git a/src/__tests__/components/State-test.js b/src/__tests__/components/State-test.js new file mode 100644 index 0000000..e14b31b --- /dev/null +++ b/src/__tests__/components/State-test.js @@ -0,0 +1,29 @@ +import React from 'react' +import State from '../../components/State' +import Helmet from '../../utils/Helmet' +import { renderComponent } from '../test-utils' + +describe('State', () => { + it('works', () => { + const res = renderComponent( + + {{ + lion: 'mammal' + }} + + ) + expect(res.toJSON()).toMatchSnapshot() + }) + + it('injects the right script tag', () => { + renderComponent( + + {{}} + + ) + Helmet.canUseDOM = false + const staticHead = Helmet.renderStatic() + expect(staticHead.scriptTags).toMatchSnapshot() + }) +}) + diff --git a/src/__tests__/components/__snapshots__/State-test.js.snap b/src/__tests__/components/__snapshots__/State-test.js.snap new file mode 100644 index 0000000..5f84399 --- /dev/null +++ b/src/__tests__/components/__snapshots__/State-test.js.snap @@ -0,0 +1,26 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`State injects the right script tag 1`] = ` +Array [ + Object { + "async": true, + "custom-element": "amp-bind", + "src": "https://cdn.ampproject.org/v0/amp-bind-0.1.js", + }, +] +`; + +exports[`State works 1`] = ` + +