Skip to content

Commit

Permalink
fix: add a test for importing to pub
Browse files Browse the repository at this point in the history
  • Loading branch information
tefkah committed Jan 10, 2024
1 parent cec6031 commit f4f12f0
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/test.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ describe('PubPub', () => {

// it('should be able to update a community', async () => {})

let importedPubId: string
it('should be able to import a pub', async () => {
const { body } = await pubpub.pub.text.import({
files: [
Expand All @@ -190,6 +191,35 @@ describe('PubPub', () => {
expect(JSON.stringify(doc)?.includes('heya')).toBeTruthy()
expect(pub).toHaveProperty('title')
expect(pub.title).toBe('imported pub')

importedPubId = pub.id
}, 20000)

it('should be able to import to a pub', async () => {
const { body } = await pubpub.pub.text.importToPub(
{
files: [
{
blob: new Blob([':D'], { type: 'text/plain' }),
filename: 'happy.txt',
},
],
method: 'append',
},
{
params: {
pubId: importedPubId,
},
},
)

const { doc, pub } = body

expect(pub.id).toEqual(importedPubId)

const stringDoc = JSON.stringify(doc)
expect(stringDoc).toContain(':D')
expect(stringDoc).toContain('heya')
}, 20000)

it('should be able to query things', async () => {
Expand Down

0 comments on commit f4f12f0

Please sign in to comment.