Skip to content

Commit

Permalink
feat: improve stamp capacity listing (#514)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cafe137 authored Jun 26, 2024
1 parent 55eacab commit cf776ab
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 3 additions & 4 deletions src/service/stamp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@ export function printStamp(
console.log(createKeyValue('Label', stamp.label))
}
console.log(createKeyValue('Usage', richStamp.usageText))
console.log(createKeyValue('Remaining Capacity', richStamp.remainingCapacity.toString()))
console.verbose(
console.log(
createKeyValue(
richStamp.immutableFlag ? 'Total Capacity (immutable)' : 'Total Capacity (mutable)',
richStamp.capacity.toString(),
richStamp.immutableFlag ? 'Capacity (immutable)' : 'Capacity (mutable)',
`${richStamp.remainingCapacity.toString()} remaining out of ${richStamp.capacity.toString()}`,
),
)

Expand Down
8 changes: 4 additions & 4 deletions test/command/stamp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ describeCommand(
({ consoleMessages, getLastMessage, getNthLastMessage, hasMessageContaining }) => {
it('should list stamps', async () => {
await invokeTestCli(['stamp', 'list'])
const pattern = [['Stamp ID'], ['Usage'], ['Remaining Capacity'], ['TTL']]
const pattern = [['Stamp ID'], ['Usage'], ['Capacity'], ['TTL']]
expect(consoleMessages).toMatchLinesInOrder(pattern)
})

it('should show a specific stamp', async () => {
await invokeTestCli(['stamp', 'show', Types.asString(process.env.STAMP)])
const pattern = [['Stamp ID', Types.asString(process.env.STAMP)], ['Usage'], ['Remaining Capacity'], ['TTL']]
const pattern = [['Stamp ID', Types.asString(process.env.STAMP)], ['Usage'], ['Capacity'], ['TTL']]
expect(consoleMessages).toMatchLinesInOrder(pattern)
})

Expand Down Expand Up @@ -57,7 +57,7 @@ describeCommand(

const id = command.postageBatchId
await invokeTestCli(['stamp', 'show', id, '--verbose'])
const pattern = [['Total Capacity (immutable)']]
const pattern = [['Capacity (immutable)']]
expect(consoleMessages).toMatchLinesInOrder(pattern)
await System.sleepMillis(11_000)
})
Expand All @@ -69,7 +69,7 @@ describeCommand(

it('should list with sorting and filter', async () => {
await invokeTestCli(['stamp', 'list', '--min-usage', '0', '--max-usage', '100', '--least-used', '--limit', '1'])
const pattern = [['Stamp ID'], ['Usage'], ['Remaining Capacity'], ['TTL']]
const pattern = [['Stamp ID'], ['Usage'], ['Capacity'], ['TTL']]
expect(consoleMessages).toMatchLinesInOrder(pattern)
})

Expand Down

0 comments on commit cf776ab

Please sign in to comment.