fix(helia): Manually porting @achingbrian PR to v5 branch

This commit is contained in:
Chris Troutner
2025-02-20 20:51:09 -07:00
parent e5cdf28e34
commit 4d9e948e30
5 changed files with 471 additions and 832 deletions
+28 -28
View File
@@ -203,40 +203,40 @@ describe('#IPFS-adapter', () => {
})
})
// describe('#getSeed', () => {
// it('should read the seed from the JSON file', async () => {
// // Mock dependencies and force desired code path
// sandbox.stub(uut.jsonFiles, 'readJSON').resolves('12345678')
describe('#getSeed', () => {
it('should read the seed from the JSON file', async () => {
// Mock dependencies and force desired code path
sandbox.stub(uut.jsonFiles, 'readJSON').resolves('12345678')
// const result = await uut.getSeed()
// // console.log('result: ', result)
const result = await uut.getSeed()
// console.log('result: ', result)
// assert.isString(result)
// })
assert.isString(result)
})
// it('should generate a new seed if the JSON file is not found', async () => {
// // Mock dependencies and force desired code path
// sandbox.stub(uut.jsonFiles, 'readJSON').rejects(new Error('test error'))
// sandbox.stub(uut.jsonFiles, 'writeJSON').resolves()
it('should generate a new seed if the JSON file is not found', async () => {
// Mock dependencies and force desired code path
sandbox.stub(uut.jsonFiles, 'readJSON').rejects(new Error('test error'))
sandbox.stub(uut.jsonFiles, 'writeJSON').resolves()
// const result = await uut.getSeed()
// // console.log('result: ', result)
const result = await uut.getSeed()
// console.log('result: ', result)
// assert.isString(result)
// })
assert.isString(result)
})
// it('should catch, report, and throw errors', async () => {
// try {
// // Force an error
// sandbox.stub(uut.jsonFiles, 'readJSON').rejects(new Error('test error'))
// sandbox.stub(uut.jsonFiles, 'writeJSON').rejects(new Error('test error'))
it('should catch, report, and throw errors', async () => {
try {
// Force an error
sandbox.stub(uut.jsonFiles, 'readJSON').rejects(new Error('test error'))
sandbox.stub(uut.jsonFiles, 'writeJSON').rejects(new Error('test error'))
// await uut.getSeed()
await uut.getSeed()
// assert.fail('Unexpected code path')
// } catch (err) {
// assert.include(err.message, 'test error')
// }
// })
// })
assert.fail('Unexpected code path')
} catch (err) {
assert.include(err.message, 'test error')
}
})
})
})