@@ -2,11 +2,8 @@ import '@testing-library/jest-dom/vitest';
22import { cleanup , renderHook } from '@testing-library/react' ;
33// biome-ignore lint/style/useImportType: <explanation>
44import React from 'react' ;
5- import { type PrivateKeyAccount , generatePrivateKey , privateKeyToAccount } from 'viem/accounts' ;
65import { afterEach , describe , expect , it } from 'vitest' ;
76
8- import type { Identity } from '@graphprotocol/hypergraph' ;
9-
107import { HypergraphAuthProvider , useAuthenticated , useHypergraphAccountId } from '../src/HypergraphAuthContext.js' ;
118
129afterEach ( ( ) => {
@@ -15,36 +12,21 @@ afterEach(() => {
1512
1613const storageMockDict = { } as { [ key : string ] : string } ;
1714const storageMock = {
18- getItem : ( key : string ) => {
15+ getItem ( key : string ) {
1916 return storageMockDict [ key ] || null ;
2017 } ,
21- setItem : ( key : string , value : string ) => {
18+ setItem ( key : string , value : string ) {
2219 storageMockDict [ key ] = value ;
2320 } ,
24- removeItem : ( key : string ) => {
21+ removeItem ( key : string ) {
2522 delete storageMockDict [ key ] ;
2623 } ,
2724} ;
28- const accountSigner = ( account : PrivateKeyAccount ) : Identity . Signer => {
29- return {
30- signMessage : async ( message : string ) => {
31- return account . signMessage ( { message } ) ;
32- } ,
33- getAddress : async ( ) => {
34- return account . address ;
35- } ,
36- } ;
37- } ;
3825
3926describe ( 'HypergraphAuthContext' , ( ) => {
4027 it ( 'should render the HypergraphAuthProvider and be initially unauthenticetd' , async ( ) => {
41- // generate a random private key to simulate a user wallet
42- const account = privateKeyToAccount ( generatePrivateKey ( ) ) ;
43- const signer = accountSigner ( account ) ;
4428 const wrapper = ( { children } : Readonly < { children : React . ReactNode } > ) => (
45- < HypergraphAuthProvider storage = { storageMock } signer = { signer } >
46- { children }
47- </ HypergraphAuthProvider >
29+ < HypergraphAuthProvider storage = { storageMock } > { children } </ HypergraphAuthProvider >
4830 ) ;
4931
5032 const { result : authenticatedResult } = renderHook ( ( ) => useAuthenticated ( ) , { wrapper } ) ;
0 commit comments