Skip to content

Commit

Permalink
fix: address w3up upload test expectations
Browse files Browse the repository at this point in the history
  • Loading branch information
joaosa committed May 7, 2024
1 parent 0d9b41b commit 2dba4d4
Showing 1 changed file with 11 additions and 20 deletions.
31 changes: 11 additions & 20 deletions packages/w3up-client/test/client.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { toCAR } from './helpers/car.js'
import { mockService, mockServiceConf } from './helpers/mocks.js'
import { File } from './helpers/shims.js'
import { Client } from '../src/client.js'
import { validateAuthorization } from './helpers/utils.js'
import { validateAuthorization, setupBlobAddResponse } from './helpers/utils.js'
import { getFilecoinOfferResponse } from './helpers/filecoin.js'

describe('Client', () => {
Expand All @@ -43,19 +43,10 @@ describe('Client', () => {
assert.equal(invocation.capabilities.length, 1)
assert.equal(capability.can, BlobCapabilities.add.can)
assert.equal(capability.with, alice.currentSpace()?.did())

return {
ok: {
status: 'upload',
headers: { 'x-test': 'true' },
url: 'http://localhost:9200',
link: /** @type {import('@web3-storage/upload-client/types').CARLink} */ (
invocation.capabilities[0].nb?.link
),
with: space.did(),
allocated: capability.nb.size,
},
}
return setupBlobAddResponse(
{ issuer: space, with: space, proofs: [], audience: alice.agent },
invocation
)
}),
},
filecoin: {
Expand Down Expand Up @@ -112,8 +103,8 @@ describe('Client', () => {
},
})

assert(service.store.add.called)
assert.equal(service.store.add.callCount, 1)
assert(service.blob.add.called)
assert.equal(service.blob.add.callCount, 1)
assert(service.upload.add.called)
assert.equal(service.upload.add.callCount, 1)

Expand Down Expand Up @@ -219,8 +210,8 @@ describe('Client', () => {
},
})

assert(service.store.add.called)
assert.equal(service.store.add.callCount, 1)
assert(service.blob.add.called)
assert.equal(service.blob.add.callCount, 1)
assert(service.upload.add.called)
assert.equal(service.upload.add.callCount, 1)

Expand Down Expand Up @@ -311,8 +302,8 @@ describe('Client', () => {
},
})

assert(service.store.add.called)
assert.equal(service.store.add.callCount, 1)
assert(service.blob.add.called)
assert.equal(service.blob.add.callCount, 1)
assert(service.upload.add.called)
assert.equal(service.upload.add.callCount, 1)
})
Expand Down

0 comments on commit 2dba4d4

Please sign in to comment.