Skip to content

Commit

Permalink
fix: pipe.execute undefined, reexport IClientEventDtoFlp (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
oljekechoro authored Sep 1, 2022
1 parent f6407c4 commit 1824554
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/main/ts/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { IClientEventDto, LogLevel } from '@qiwi/substrate'
import { nanoid } from 'nanoid'

import { IPipeOutput } from './interfaces'
import { createFlpPipeline, eventifyPipe } from './pipes/flp'
import { createTransmittable, createTransmitter } from './transmitter'
import { getCookie, setCookie } from './utils/cookie'
Expand Down Expand Up @@ -66,7 +67,7 @@ const createFrontLogProxyTransmitter = ({
})
}
return acc
}, {} as Record<LogLevel, (data: IClientEventDtoFlp) => Promise<any>>)
}, {} as Record<LogLevel, (data: IClientEventDtoFlp) => Promise<IPipeOutput>>)
}

export {
Expand All @@ -78,3 +79,7 @@ export {
eventifyPipe,
createFrontLogProxyTransmitter,
}

export type {
IClientEventDtoFlp
}
2 changes: 1 addition & 1 deletion src/main/ts/pipes/httpFallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const createHttpPipeFallback = (opts: IHttpPipeOpts[]): IPipe => {
return {
type,
execute(transmittable: ITransmittable): IPromise<IPipeOutput> {
return executeFailproof(transmittable, httpPipes)
return executeFailproof(transmittable, [...httpPipes])
},
}
}
17 changes: 17 additions & 0 deletions src/test/ts/createFrontLogProxyTransmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,21 @@ test('createFrontLogProxyTransmitter correctly call fetch with Error', async ()
}
})

test('createFrontLogProxyTransmitter does not throw an error on several calls', async () => {
const transmitter = createFrontLogProxyTransmitter({
appName: 'testApp',
url: 'https://reqres.in/api/users/2',
})

const callAndCheck = async (message: string) => {
const [err, res] = await transmitter.info({ message })
assert.equal(res.message, message)
assert.equal(err, null)
}

await callAndCheck('foo')
await callAndCheck('bar')
await callAndCheck('baz')
})

test.run()

0 comments on commit 1824554

Please sign in to comment.