8000 web: add one more test case · brpapa/recursion-tree-visualizer@bdcfc98 · GitHub
[go: up one dir, main page]

Skip to content

Commit bdcfc98

Browse files
committed
web: add one more test case
1 parent 94f5756 commit bdcfc98

File tree

7 files changed

+30
-9
lines changed

7 files changed

+30
-9
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ The deployment of the Lambda function is automatized by the workflow `cd-lambda-
6767

6868
- ECR repository to store your Docker images
6969

70-
2. Store an IAM user access key in GitHub Actions secrets named `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`.
70+
- IAM user with the proper permissions
71+
72+
2. Store the IAM user access key in GitHub Actions secrets named `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`.
7173

7274
3. Change the workflow file `github/workflows/cd-lambda-function.yml`:
7375

packages/lambda/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
"author": "Bruno Papa <bruno.papa@hotmail.com>",
55
"private": true,
66
"license": "MIT",
7+
"engines": {
8+
"node": "14"
9+
},
710
"scripts": {
811
"build": "npx tsc",
912
"test": "DEBUG='app:*,test:*' npx jest --config jest.config.js",

packages/lambda/src/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ export const handler: APIGatewayProxyHandler = async (event) => {
1010
log('Event received: %O', event)
1111

1212
const validatedEvent = validateAPIGatewayProxyEvent(event)
13-
if (validatedEvent.isError())
14-
return badRequest(validatedEvent.value)
15-
13+
if (validatedEvent.isError()) return badRequest(validatedEvent.value)
14+
1615
const body = validatedEvent.value
1716

1817
try {

packages/lambda/src/utils/safe-json.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { debug } from 'debug'
2+
23
const log = debug('app:utils:safe-json')
34

4-
/* FIXME: code shared between (ESSA EH A FONTE DA VERDADE)
5+
/* FIXME: this code is duplicated in: (CONSIDERAR SEMPRE ESSA COMO A FONTE DA VERDADE)
56
- lambda/src/utils/safe-json.ts
67
- lambda/src/runner/operations/get-full-source-code.ts
78
- web/src/utils/safe-json.ts

packages/lambda/tests/utils/object-map.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { describe, it, expect } from '@jest/globals'
22
import { objectMap } from '../../src/utils/object-map'
33

44
describe('Object map', () => {
5-
test('Should be handle with string key', () => {
5+
it('Should be handle with string key', () => {
66
const obj = { a: 1, b: 2 }
77

88
const mapped1 = objectMap(obj, (v) => 2 * v)
@@ -12,7 +12,7 @@ describe('Object map', () => {
1212
const mapped2 = objectMap(obj, (v, k) => v + k)
1313
expect(mapped2).toEqual({ a: '1a', b: '2b' })
1414
})
15-
// test('should be handle with number key', () => {
15+
// it('should be handle with number key', () => {
1616
// expect(objectMap({ 0: 1, 1: 2 }, (v) => 2 * v)).toEqual({ 0: 2, 1: 4 })
1717
// })
1818
})

packages/web/src/components/function-form/template-handler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export const buildFnCodeDecomposer = (lang: Language) => {
5757
switch (lang) {
5858
case 'node':
5959
return (fnCode: string) => ({
60-
// todo: usar mesma logica do extractContentInsideFirstParentesis mas com {}
6160
body: fnCode.substring(
6261
fnCode.indexOf('{') + 2,
6362
fnCode.lastIndexOf('}')

packages/web/tests/template-handler.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,31 @@ describe('template handler', () => {
117117
fnCall: 'fn(1)',
118118
},
119119
expected: {
120-
body: 'return 1 ',
120+
body: 'return 1',
121121
params: [
122122
{ name: 'a', initialValue: '1' },
123123
{ name: 'b', initialValue: '[0,1]' },
124124
],
125125
},
126126
},
127127
],
128+
[
129+
{
130+
args: {
131+
lang: 'node',
132+
fnCode: `
133+
function fn() {
134+
function f() { return 1 }; return f();
135+
}
136+
`,
137+
fnCall: 'fn()',
138+
},
139+
expected: {
140+
body: 'function f() { return 1 }; return f();',
141+
params: [],
142+
},
143+
},
144+
],
128145
])(
129146
'composeFnData, case %#',
130147
({ args: { fnCode, fnCall, lang }, expected }: any) => {

0 commit comments

Comments
 (0)
0