Skip to content

Commit

Permalink
fix: mock ipfs pubsub in ceramic api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
v-stickykeys committed Jan 1, 2021
1 parent 3ddd272 commit dd9b096
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/core/src/__tests__/ceramic-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ const generateStringOfSize = (size): string => {
return random_data.join('');
}

const TOPIC = '/ceramic'

describe('Ceramic API', () => {
jest.setTimeout(15000)
let ipfs: IpfsApi;
Expand All @@ -87,6 +89,7 @@ describe('Ceramic API', () => {

const createCeramic = async (c: CeramicConfig = {}): Promise<Ceramic> => {
c.anchorOnRequest = false
c.pubsubTopic = TOPIC
const ceramic = await Ceramic.create(ipfs, c)

const provider = new Ed25519Provider(seed)
Expand All @@ -104,13 +107,24 @@ describe('Ceramic API', () => {
Bootstrap: []
}
})
ipfs.pubsub.subscribe = jest.fn()
ipfs.pubsub.ls = jest.fn(
() => new Promise((resolve, reject) => {
resolve([TOPIC])
reject()
})
)
})

afterAll(async () => {
await ipfs.stop(() => console.log('IPFS stopped'))
await tmpFolder.cleanup()
})

afterEach(async () => {
await ceramic.close()
})

describe('API', () => {
it('can load the previous document commit', async () => {
ceramic = await createCeramic()
Expand Down

0 comments on commit dd9b096

Please sign in to comment.