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 3d28eb0
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 26 deletions.
6 changes: 3 additions & 3 deletions packages/w3up-client/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class Client extends Base {
*/
async uploadFile(file, options = {}) {
const conf = await this._invocationConfig([
StoreCapabilities.add.can,
BlobCapabilities.add.can,
UploadCapabilities.add.can,
])
options.connection = this._serviceConf.upload
Expand All @@ -120,7 +120,7 @@ export class Client extends Base {
*/
async uploadDirectory(files, options = {}) {
const conf = await this._invocationConfig([
StoreCapabilities.add.can,
BlobCapabilities.add.can,
UploadCapabilities.add.can,
])
options.connection = this._serviceConf.upload
Expand All @@ -141,7 +141,7 @@ export class Client extends Base {
*/
async uploadCAR(car, options = {}) {
const conf = await this._invocationConfig([
StoreCapabilities.add.can,
BlobCapabilities.add.can,
UploadCapabilities.add.can,
])
options.connection = this._serviceConf.upload
Expand Down
1 change: 0 additions & 1 deletion packages/w3up-client/src/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const filecoinServiceConnection = client.connect({

/** @type {import('./types.js').ServiceConf} */
export const serviceConf = {
blob: uploadServiceConnection,
access: accessServiceConnection,
upload: uploadServiceConnection,
filecoin: filecoinServiceConnection,
Expand Down
1 change: 0 additions & 1 deletion packages/w3up-client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export type ProofQuery = Record<Resource, Record<Ability, Unit>>
export type Service = AccessService & UploadService & StorefrontService

export interface ServiceConf {
blob: ConnectionView<UploadService>
access: ConnectionView<AccessService>
upload: ConnectionView<UploadService>
filecoin: ConnectionView<StorefrontService>
Expand Down
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
1 change: 0 additions & 1 deletion packages/w3up-client/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const setup = async () => {
Client.create({
store: new StoreMemory(),
serviceConf: {
blob: context.connection,
access: context.connection,
upload: context.connection,
filecoin: context.connection,
Expand Down

0 comments on commit 3d28eb0

Please sign in to comment.