A calm place to write long-form, and publish it to the open social web.
skypress.blog/
1import { describe, expect, it } from 'vitest';
2import { editLinkFor, editRkeyFromSearch } from './edit-link';
3
4describe( 'editLinkFor', () => {
5 it( 'builds the editor edit URL for an rkey', () => {
6 expect( editLinkFor( '3kabc123' ) ).toBe( '/editor?edit=3kabc123' );
7 } );
8} );
9
10describe( 'editRkeyFromSearch', () => {
11 it( 'reads the rkey from the edit param', () => {
12 expect( editRkeyFromSearch( '?edit=3kabc123' ) ).toBe( '3kabc123' );
13 } );
14
15 it( 'returns null when the param is absent', () => {
16 expect( editRkeyFromSearch( '?foo=bar' ) ).toBeNull();
17 expect( editRkeyFromSearch( '' ) ).toBeNull();
18 } );
19
20 it( 'returns null when the param is present but empty', () => {
21 expect( editRkeyFromSearch( '?edit=' ) ).toBeNull();
22 } );
23} );