/* 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( '
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('| Size | Chest |
|---|
Body.
', 'Written summary.'))).toBe( 'Written summary.' ); }); });