A calm place to write long-form, and publish it to the open social web. skypress.blog/
0

Configure Feed

Select the types of activity you want to include in your feed.

at trunk 1.5 kB View raw
1import { describe, it, expect } from 'vitest'; 2import { act, createElement } from 'react'; 3import { createRoot } from 'react-dom/client'; 4 5( globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean } ).IS_REACT_ACT_ENVIRONMENT = true; 6 7import PublishedPill from './PublishedPill'; 8 9function render( props: { url: string; isEditing: boolean } ) { 10 const container = document.createElement( 'div' ); 11 document.body.appendChild( container ); 12 const root = createRoot( container ); 13 act( () => { 14 root.render( createElement( PublishedPill, props ) ); 15 } ); 16 return { 17 container, 18 cleanup: () => { 19 root.unmount(); 20 container.remove(); 21 }, 22 }; 23} 24 25describe( 'PublishedPill', () => { 26 it( 'shows the live copy and links to the article for a new publish', () => { 27 const { container, cleanup } = render( { 28 url: 'https://skypress.blog/jeherve.com/my-blog/hello', 29 isEditing: false, 30 } ); 31 expect( container.textContent ).toContain( "It's live" ); 32 const link = container.querySelector( 'a' )!; 33 expect( link.getAttribute( 'href' ) ).toBe( 34 'https://skypress.blog/jeherve.com/my-blog/hello' 35 ); 36 expect( link.textContent ).toContain( 'Read it' ); 37 cleanup(); 38 } ); 39 40 it( 'shows the updated copy when editing', () => { 41 const { container, cleanup } = render( { 42 url: 'https://x', 43 isEditing: true, 44 } ); 45 expect( container.textContent ).toContain( 'Updated' ); 46 expect( container.textContent ).not.toContain( "It's live" ); 47 cleanup(); 48 } ); 49} );