mirror of
https://github.com/Permissionless-Software-Foundation/x402-base-facilitator.git
synced 2026-09-21 16:52:01 -07:00
fix(logapi): Fixing issues with unit tests
This commit is contained in:
@@ -135,8 +135,10 @@ class LogsApi {
|
|||||||
if (!filename || typeof filename !== 'string') {
|
if (!filename || typeof filename !== 'string') {
|
||||||
throw new Error('filename must be a string')
|
throw new Error('filename must be a string')
|
||||||
}
|
}
|
||||||
// Throw an error if the file does not exist.
|
|
||||||
|
|
||||||
|
console.log('readLines() filename: ', filename)
|
||||||
|
|
||||||
|
// Throw an error if the file does not exist.
|
||||||
if (!_this.fs.existsSync(filename)) {
|
if (!_this.fs.existsSync(filename)) {
|
||||||
throw new Error('file does not exist')
|
throw new Error('file does not exist')
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ describe('#LogsApiLib', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should return log', async () => {
|
it('should return log', async () => {
|
||||||
|
// Mock dependencies
|
||||||
|
sandbox.stub(uut, 'generateFileName').returns(`${__dirname.toString()}/../mocks/adapters/test.log`)
|
||||||
|
|
||||||
const pass = 'test'
|
const pass = 'test'
|
||||||
const result = await uut.getLogs(pass)
|
const result = await uut.getLogs(pass)
|
||||||
// console.log('result', result)
|
// console.log('result', result)
|
||||||
@@ -201,13 +204,15 @@ describe('#LogsApiLib', () => {
|
|||||||
// About yields
|
// About yields
|
||||||
sandbox.stub(uut.lineReader, 'eachLine').yieldsRight({}, true)
|
sandbox.stub(uut.lineReader, 'eachLine').yieldsRight({}, true)
|
||||||
|
|
||||||
const fileName = context.fileName
|
const fileName = `${__dirname.toString()}/../mocks/adapters/test.log`
|
||||||
|
|
||||||
const result = await uut.readLines(fileName)
|
const result = await uut.readLines(fileName)
|
||||||
assert.isArray(result)
|
assert.isArray(result)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should return data', async () => {
|
it('should return data', async () => {
|
||||||
const fileName = context.fileName
|
const fileName = `${__dirname.toString()}/../mocks/adapters/test.log`
|
||||||
|
|
||||||
const result = await uut.readLines(fileName)
|
const result = await uut.readLines(fileName)
|
||||||
|
|
||||||
assert.isArray(result)
|
assert.isArray(result)
|
||||||
|
|||||||
Reference in New Issue
Block a user