/* eslint-env jest */ import { excerptOf } from '../render-template'; import type { EditedPost } from '../../hooks/use-seo-meta'; const post = (content: string, excerpt = ''): EditedPost => ({ id: 1, title: 'Shipping & Returns', content, excerpt, slug: 'shipping-returns', link: 'https://shop.example/shipping-returns/', status: 'publish', featuredImageId: 0, terms: {}, }); describe('the automatic description in the preview', () => { it('reads the text without its headings, as the server does', () => { expect( excerptOf( post( '

Shipping

Orders ship within two working days.

' ) ) ).toBe('Orders ship within two working days.'); }); it('keeps cells apart and falls back to the headings when that is all there is', () => { expect( excerptOf(post('
SizeChest
')) ).toBe('Size Chest'); expect(excerptOf(post('

Only a heading

'))).toBe('Only a heading'); }); it('prefers a written excerpt', () => { expect(excerptOf(post('

Body.

', 'Written summary.'))).toBe( 'Written summary.' ); }); });