1- import { type AnyDocumentId , Repo } from '@automerge/automerge-repo' ;
1+ import { Repo } from '@automerge/automerge-repo' ;
22import { RepoContext } from '@automerge/automerge-repo-react-hooks' ;
3- import { Entity , Type , Utils } from '@graphprotocol/hypergraph' ;
3+ import { Entity , Type , store } from '@graphprotocol/hypergraph' ;
44import '@testing-library/jest-dom/vitest' ;
55import { act , cleanup , renderHook , waitFor } from '@testing-library/react' ;
66// biome-ignore lint/style/useImportType: <explanation>
@@ -45,10 +45,24 @@ describe('HypergraphSpaceContext', () => {
4545
4646 beforeEach ( ( ) => {
4747 repo = new Repo ( { } ) ;
48- const result = repo . findWithProgress ( Utils . idToAutomergeId ( spaceId ) as AnyDocumentId ) ;
49- const automergeDocHandle = result . handle ;
50- // set it to ready to interact with the document
51- automergeDocHandle . doneLoading ( ) ;
48+ store . send ( { type : 'setRepo' , repo } ) ;
49+ store . send ( {
50+ type : 'setSpace' ,
51+ spaceId,
52+ spaceState : {
53+ id : spaceId ,
54+ members : { } ,
55+ invitations : { } ,
56+ removedMembers : { } ,
57+ inboxes : { } ,
58+ lastEventHash : '' ,
59+ } ,
60+ name : 'Test Space' ,
61+ updates : { updates : [ ] , firstUpdateClock : 0 , lastUpdateClock : 0 } ,
62+ events : [ ] ,
63+ inboxes : [ ] ,
64+ keys : [ ] ,
65+ } ) ;
5266
5367 wrapper = ( { children } : Readonly < { children : React . ReactNode } > ) => (
5468 < RepoContext . Provider value = { repo } >
@@ -59,8 +73,8 @@ describe('HypergraphSpaceContext', () => {
5973
6074 describe ( 'useCreateEntity' , ( ) => {
6175 it ( 'should be able to create an entity through the useCreateEntity Hook' , async ( ) => {
62- const { result : createEntityResult } = renderHook ( ( ) => useCreateEntity ( Event ) , { wrapper } ) ;
6376 const { result : queryEntitiesResult , rerender } = renderHook ( ( ) => useQueryLocal ( Event ) , { wrapper } ) ;
77+ const { result : createEntityResult } = renderHook ( ( ) => useCreateEntity ( Event ) , { wrapper } ) ;
6478
6579 let createdEntity : Entity . Entity < typeof Event > | null = null ;
6680
0 commit comments