rsnext/test/unit/image-rendering.test.ts
JJ Kasper 005b13f1ac
Move unit tests to one folder and migrate them to TypeScript (#28427)
* Move unit tests to one folder

* Migrate unit tests to TypeScript

* add test types to lint

* Ensure ts(x) tests are run with util

* Add tsx extension to jest config

* bump
2021-08-24 07:52:45 -05:00

23 lines
677 B
TypeScript

/* eslint-env jest */
import React from 'react'
import ReactDOM from 'react-dom/server'
import Image from 'next/image'
import cheerio from 'cheerio'
describe('Image rendering', () => {
it('should render Image on its own', async () => {
const element = React.createElement(Image, {
id: 'unit-image',
src: '/test.png',
width: 100,
height: 100,
loading: 'eager',
})
const html = ReactDOM.renderToString(element)
const $ = cheerio.load(html)
const img = $('#unit-image')
expect(img.attr('id')).toBe('unit-image')
expect(img.attr('src')).toContain('test.png')
expect(img.attr('srcset')).toContain('test.png')
})
})