File tree Expand file tree Collapse file tree 2 files changed +14
-21
lines changed
x-pack/plugins/canvas/server/routes Expand file tree Collapse file tree 2 files changed +14
-21
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,12 @@ import { serializeProvider } from '../../../../../../src/plugins/expressions/com
99import { RouteInitializerDeps } from '../' ;
1010import { API_ROUTE_FUNCTIONS } from '../../../common/lib/constants' ;
1111
12+ interface FunctionCall {
13+ functionName : string ;
14+ args : Record < string , any > ;
15+ context : Record < string , any > ;
16+ }
17+
1218export function initializeGetFunctionsRoute ( deps : RouteInitializerDeps ) {
1319 const { router, expressions } = deps ;
1420 router . get (
@@ -31,7 +37,7 @@ export function initializeBatchFunctionsRoute(deps: RouteInitializerDeps) {
3137
3238 async function runFunction (
3339 handlers : { environment : string ; elasticsearchClient : LegacyAPICaller } ,
34- fnCall : any
40+ fnCall : FunctionCall
3541 ) {
3642 const { functionName, args, context } = fnCall ;
3743 const { deserialize } = serializeProvider ( expressions . getTypes ( ) ) ;
@@ -51,7 +57,7 @@ export function initializeBatchFunctionsRoute(deps: RouteInitializerDeps) {
5157 */
5258 bfetch . addBatchProcessingRoute ( API_ROUTE_FUNCTIONS , ( request ) => {
5359 return {
54- onBatchItem : async ( fnCall : any ) => {
60+ onBatchItem : async ( fnCall : FunctionCall ) => {
5561 const handlers = {
5662 environment : 'server' ,
5763 elasticsearchClient : elasticsearch . legacy . client . asScoped ( request ) . callAsCurrentUser ,
Original file line number Diff line number Diff line change 66
77import { badRequest } from 'boom' ;
88import { initializeListTemplates } from './list' ;
9- import {
10- IRouter ,
11- kibanaResponseFactory ,
12- RequestHandlerContext ,
13- RequestHandler ,
14- } from 'src/core/server' ;
15- import {
16- savedObjectsClientMock ,
17- httpServiceMock ,
18- httpServerMock ,
19- loggingSystemMock ,
20- } from 'src/core/server/mocks' ;
9+ import { kibanaResponseFactory , RequestHandlerContext , RequestHandler } from 'src/core/server' ;
10+ import { savedObjectsClientMock , httpServerMock } from 'src/core/server/mocks' ;
11+ import { getMockedRouterDeps } from '../test_helpers' ;
2112
2213const mockRouteContext = ( {
2314 core : {
@@ -31,14 +22,10 @@ describe('Find workpad', () => {
3122 let routeHandler : RequestHandler < any , any , any > ;
3223
3324 beforeEach ( ( ) => {
34- const httpService = httpServiceMock . createSetupContract ( ) ;
35- const router = httpService . createRouter ( ) as jest . Mocked < IRouter > ;
36- initializeListTemplates ( {
37- router,
38- logger : loggingSystemMock . create ( ) . get ( ) ,
39- } ) ;
25+ const routerDeps = getMockedRouterDeps ( ) ;
26+ initializeListTemplates ( routerDeps ) ;
4027
41- routeHandler = router . get . mock . calls [ 0 ] [ 1 ] ;
28+ routeHandler = routerDeps . router . get . mock . calls [ 0 ] [ 1 ] ;
4229 } ) ;
4330
4431 it ( `returns 200 with the found templates` , async ( ) => {
You can’t perform that action at this time.
0 commit comments