21 lines
872 B
JavaScript
21 lines
872 B
JavaScript
import { test } from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { formatImportSummary } from '#import-recipes/cli/formatImportSummary.js'
|
|
|
|
test('counts what made it through', () => {
|
|
assert.equal(formatImportSummary({ importedCount: 3, failures: [] }), '3 recipes imported, 0 failed.')
|
|
assert.equal(formatImportSummary({ importedCount: 1, failures: [] }), '1 recipe imported, 0 failed.')
|
|
})
|
|
|
|
test('lists every failure with its reason', () => {
|
|
const summary = formatImportSummary({
|
|
importedCount: 2,
|
|
failures: [
|
|
{ fileName: 'Tarte.odt', reason: 'unreadable file' },
|
|
{ fileName: 'Soupe.odt', reason: 'answer cut off at max_tokens' }
|
|
]
|
|
})
|
|
assert.match(summary, /^2 recipes imported, 2 failed\./)
|
|
assert.match(summary, /Tarte\.odt - unreadable file/)
|
|
assert.match(summary, /Soupe\.odt - answer cut off at max_tokens/)
|
|
})
|