A calm place to write long-form, and publish it to the open social web.
skypress.blog/
1import { describe, expect, it } from 'vitest';
2import { isProfileOwner } from './cta';
3
4const PROFILE = 'did:plc:profile';
5
6describe( 'isProfileOwner', () => {
7 it( 'is true when signed in and the viewer DID matches the profile DID', () => {
8 expect( isProfileOwner( 'signed-in', 'did:plc:profile', PROFILE ) ).toBe( true );
9 } );
10
11 it( 'is false when signed in as a different DID', () => {
12 expect( isProfileOwner( 'signed-in', 'did:plc:someone-else', PROFILE ) ).toBe( false );
13 } );
14
15 it( 'is false when the viewer DID is null', () => {
16 expect( isProfileOwner( 'signed-in', null, PROFILE ) ).toBe( false );
17 } );
18
19 it( 'is false for loading, signed-out and error statuses even if a DID matches', () => {
20 expect( isProfileOwner( 'loading', PROFILE, PROFILE ) ).toBe( false );
21 expect( isProfileOwner( 'signed-out', PROFILE, PROFILE ) ).toBe( false );
22 expect( isProfileOwner( 'error', PROFILE, PROFILE ) ).toBe( false );
23 } );
24} );