/**
* @jest-environment jsdom
*/
import React from 'react'
import renderer from 'react-test-renderer'
import Prism from '../src'
const CODE = `
console.log('hello, world!')
`
const render = (el: typeof renderer.create.arguments[0]) =>
renderer.create(el).toJSON()
test('renders a code block', () => {
const result = render({CODE})
expect(result).toMatchSnapshot()
})
test('renders with no className', () => {
// @ts-expect-error className is required by the type definition
const json = render()
expect(json).toMatchSnapshot()
})
test('renders with other languages', () => {
const json = render(
)
expect(json).toMatchSnapshot()
})
const HIGHLIGHT_CODE = `
console.log('hello, world!') // highlight-line
`
test('highlights inline comment', () => {
const result = render({HIGHLIGHT_CODE})
expect(result).toMatchSnapshot()
})
const HIGHLIGHT_START_END = `
// highlight-start
console.log('hello, world!')
// highlight-end
let other = "no highlight"
`
test('highlight start and end', () => {
const result = render(
{HIGHLIGHT_START_END}
)
expect(result).toMatchSnapshot()
})
const NO_HIGHLIGHT = `
// highlight-start
console.log('hello, world!')
`
test('no highlight', () => {
const result = render({NO_HIGHLIGHT})
expect(result).toMatchSnapshot()
})
const MULTIPLE_HIGHLIGHTS_START_END = `
// highlight-start
// i am highlighted!
// highlight-end
// no highlight here ...
// highlight-start
// i am highlighted, and
// so am i!
// highlight-end
// no highlight here either ...
`
test('multiple highlights start and end', () => {
const result = render(
{MULTIPLE_HIGHLIGHTS_START_END}
)
expect(result).toMatchSnapshot()
})