1
1
const test = require ( 'ava' )
2
2
3
- const { builderFunction } = require ( '../src/lib/builder_functions ' )
3
+ const { builder } = require ( '../src/lib/builder ' )
4
4
5
5
const { invokeLambda } = require ( './helpers/main' )
6
6
@@ -20,7 +20,7 @@ test('Injects the metadata object into an asynchronous handler', async (t) => {
20
20
21
21
return originalResponse
22
22
}
23
- const response = await invokeLambda ( builderFunction ( myHandler ) )
23
+ const response = await invokeLambda ( builder ( myHandler ) )
24
24
25
25
t . deepEqual ( response , { ...originalResponse , ...METADATA_OBJECT } )
26
26
} )
@@ -33,7 +33,7 @@ test('Injects the metadata object into a synchronous handler', async (t) => {
33
33
const myHandler = ( event , context , callback ) => {
34
34
callback ( null , originalResponse )
35
35
}
36
- const response = await invokeLambda ( builderFunction ( myHandler ) )
36
+ const response = await invokeLambda ( builder ( myHandler ) )
37
37
38
38
t . deepEqual ( response , { ...originalResponse , ...METADATA_OBJECT } )
39
39
} )
@@ -52,7 +52,7 @@ test('Does not inject the metadata object for non-200 responses', async (t) => {
52
52
53
53
return originalResponse
54
54
}
55
- const response = await invokeLambda ( builderFunction ( myHandler ) )
55
+ const response = await invokeLambda ( builder ( myHandler ) )
56
56
57
57
t . deepEqual ( response , originalResponse )
58
58
} )
@@ -71,7 +71,7 @@ test('Returns a 405 error for requests using the POST method', async (t) => {
71
71
72
72
return originalResponse
73
73
}
74
- const response = await invokeLambda ( builderFunction ( myHandler ) , { method : 'POST' } )
74
+ const response = await invokeLambda ( builder ( myHandler ) , { method : 'POST' } )
75
75
76
76
t . deepEqual ( response , { body : 'Method Not Allowed' , statusCode : 405 } )
77
77
} )
@@ -90,7 +90,7 @@ test('Returns a 405 error for requests using the PUT method', async (t) => {
90
90
91
91
return originalResponse
92
92
}
93
- const response = await invokeLambda ( builderFunction ( myHandler ) , { method : 'PUT' } )
93
+ const response = await invokeLambda ( builder ( myHandler ) , { method : 'PUT' } )
94
94
95
95
t . deepEqual ( response , { body : 'Method Not Allowed' , statusCode : 405 } )
96
96
} )
@@ -109,7 +109,7 @@ test('Returns a 405 error for requests using the DELETE method', async (t) => {
109
109
110
110
return originalResponse
111
111
}
112
- const response = await invokeLambda ( builderFunction ( myHandler ) , { method : 'DELETE' } )
112
+ const response = await invokeLambda ( builder ( myHandler ) , { method : 'DELETE' } )
113
113
114
114
t . deepEqual ( response , { body : 'Method Not Allowed' , statusCode : 405 } )
115
115
} )
@@ -128,7 +128,7 @@ test('Returns a 405 error for requests using the PATCH method', async (t) => {
128
128
129
129
return originalResponse
130
130
}
131
- const response = await invokeLambda ( builderFunction ( myHandler ) , { method : 'PATCH' } )
131
+ const response = await invokeLambda ( builder ( myHandler ) , { method : 'PATCH' } )
132
132
133
133
t . deepEqual ( response , { body : 'Method Not Allowed' , statusCode : 405 } )
134
134
} )
@@ -148,7 +148,7 @@ test('Preserves errors thrown inside the wrapped handler', async (t) => {
148
148
throw error
149
149
}
150
150
151
- await t . throwsAsync ( invokeLambda ( builderFunction ( myHandler ) ) , { is : error } )
151
+ await t . throwsAsync ( invokeLambda ( builder ( myHandler ) ) , { is : error } )
152
152
} )
153
153
154
154
test ( 'Does not pass query parameters to the wrapped handler' , async ( t ) => {
@@ -165,7 +165,7 @@ test('Does not pass query parameters to the wrapped handler', async (t) => {
165
165
}
166
166
const multiValueQueryStringParameters = { foo : [ 'bar' ] , bar : [ 'baz' ] }
167
167
const queryStringParameters = { foo : 'bar' , bar : 'baz' }
168
- const response = await invokeLambda ( builderFunction ( myHandler ) , {
168
+ const response = await invokeLambda ( builder ( myHandler ) , {
169
169
multiValueQueryStringParameters,
170
170
queryStringParameters,
171
171
} )
0 commit comments