Skip to content

Commit

Permalink
fix: update tests, fix some bugs I found
Browse files Browse the repository at this point in the history
also improve JSDocs for new lib.js functions

I'm not entirely sure the bin test mocks are done properly - would love careful review there
  • Loading branch information
travis committed Feb 14, 2023
1 parent 5441b90 commit a27f71b
Show file tree
Hide file tree
Showing 6 changed files with 371 additions and 812 deletions.
2 changes: 1 addition & 1 deletion can.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export async function storeList (opts = {}) {
}

const spinner = ora('Listing CARs').start()
const res = await client.capability.store.list()
const res = await client.capability.store.list(listOptions)
spinner.stop()
console.log(storeListResponseToString(res, opts))
}
Expand Down
16 changes: 16 additions & 0 deletions lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import { CarReader } from '@ipld/car'

/**
* @typedef {import('@web3-storage/w3up-client/types').FileLike & { size: number }} FileLike
* @typedef {import('@web3-storage/w3up-client/src/types').ListResponse} ListResponse
* @typedef {import('@web3-storage/w3up-client/src/types').StoreListResult} StoreListResult
* @typedef {import('@web3-storage/w3up-client/src/types').UploadListResult} UploadListResult
*/

export function getPkg () {
Expand Down Expand Up @@ -195,6 +198,13 @@ async function * filesFromDir (dir, filter) {
}
}

/**
* @param {ListResponse<UploadListResult>} res
* @param {boolean} [opts.raw]
* @param {boolean} [opts.json]
* @param {boolean} [opts.shards]
* @returns {string}
*/
export function uploadListResponseToString (res, opts = {}) {
if (opts.raw) {
return JSON.stringify(res)
Expand All @@ -216,6 +226,12 @@ export function uploadListResponseToString (res, opts = {}) {
}
}

/**
* @param {ListResponse<StoreListResult>} res
* @param {boolean} [opts.raw]
* @param {boolean} [opts.json]
* @returns {string}
*/
export function storeListResponseToString (res, opts = {}) {
if (opts.raw) {
return JSON.stringify(res)
Expand Down
Loading

0 comments on commit a27f71b

Please sign in to comment.