|
1 | 1 | import React from 'react'
|
2 | 2 | import test from 'ava'
|
3 |
| -import { renderToString } from '../src' |
| 3 | +import { renderToString, AMP } from '../src' |
4 | 4 | import styled from 'styled-components'
|
5 | 5 |
|
6 |
| -test('RAMPT render', async t => { |
| 6 | +test('it renders simple node element', async t => { |
7 | 7 | const body = React.createElement('body', {})
|
8 | 8 | const output = renderToString(body)
|
9 | 9 | t.regex(output, /<body><\/body>/, 'Renders HTML template with body element.')
|
10 | 10 | })
|
11 | 11 |
|
| 12 | +const renderAllAMPComponents = () => { |
| 13 | + const Title = React.createElement(AMP.Title, {}, 'title') |
| 14 | + const Link = React.createElement(AMP.Link, { src: 'https://link' }, 'link') |
| 15 | + const body = React.createElement('body', {}, [Title, Link]) |
| 16 | + return renderToString(body) |
| 17 | +} |
| 18 | + |
| 19 | +test('it renders all AMP node element', t => { |
| 20 | + const render1 = renderAllAMPComponents() |
| 21 | + const render2 = renderAllAMPComponents() |
| 22 | + t.true(render1 === render2, 'Each render should not mix the state between each other.') |
| 23 | + t.snapshot(render1) |
| 24 | +}) |
| 25 | + |
| 26 | + |
12 | 27 | test('RAMPT render with styles', async t => {
|
13 | 28 | const styledBody = styled.body`background: red;`
|
14 | 29 | const body = React.createElement(styledBody, {})
|
|
0 commit comments