@trayio/tray-openapi 4.2.0 → 4.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -48,11 +48,11 @@ const getDefaultValue = (prop) => O.fold(() => `'test_value'`, (type) => {
48
48
  })(prop.type);
49
49
  // TODO: make handleInput and handleOutput accept an option and do the fold inside, will make the code cleaner in the template and switch case
50
50
  const handleInput = (inputs) => {
51
- const populatedTestInputs = Object.entries(inputs).map(([key, prop]) => `${key}: ${getDefaultValue(prop)}`);
51
+ const populatedTestInputs = Object.entries(inputs).map(([key, prop]) => `'${key}': ${getDefaultValue(prop)}`);
52
52
  return `{ ${populatedTestInputs.join(', ')} }`;
53
53
  };
54
54
  const handleOutput = (outputs) => {
55
- const expectations = Object.entries(outputs).map(([key, prop]) => `expect(outputValue.${key}).toEqual(${getDefaultValue(prop)});`);
55
+ const expectations = Object.entries(outputs).map(([key, prop]) => `expect(outputValue['${key}']).toEqual(${getDefaultValue(prop)});`);
56
56
  return expectations.join('\n');
57
57
  };
58
58
  const generateHandlerTest = ({ operationNameCamelCase, input, output, }) => E.tryCatch(() => `import { OperationHandlerTestSetup } from '@trayio/cdk-dsl/connector/operation/OperationHandlerTest';
@@ -124,13 +124,13 @@ describe('GenerateHandlerTest', () => {
124
124
  .testCase('should ${input.operationNameCamelCase}', (testCase) =>
125
125
  testCase
126
126
  .givenNothing()
127
- .when(() => ({ id: 2, name: 'test' }))
127
+ .when(() => ({ 'id': 2, 'name': 'test' }))
128
128
  .then(({ output }) => {
129
129
  // console.log(output);
130
130
  const outputValue =
131
131
  OperationHandlerResult.getSuccessfulValueOrFail(output);
132
- expect(outputValue.id).toEqual(2);
133
- expect(outputValue.name).toEqual('test');
132
+ expect(outputValue['id']).toEqual(2);
133
+ expect(outputValue['name']).toEqual('test');
134
134
  })
135
135
  .finallyDoNothing()
136
136
  )
@@ -200,7 +200,7 @@ describe('GenerateHandlerTest', () => {
200
200
  // console.log(output);
201
201
  const outputValue =
202
202
  OperationHandlerResult.getSuccessfulValueOrFail(output);
203
- expect(outputValue.success).toEqual(true);
203
+ expect(outputValue['success']).toEqual(true);
204
204
  })
205
205
  .finallyDoNothing()
206
206
  )
@@ -316,12 +316,12 @@ describe('GenerateHandlerTest', () => {
316
316
  .testCase('should ${input.operationNameCamelCase}', (testCase) =>
317
317
  testCase
318
318
  .givenNothing()
319
- .when(() => ({ metadata: { name: 'test', age: 2 }}))
319
+ .when(() => ({ 'metadata': { 'name': 'test', 'age': 2 }}))
320
320
  .then(({ output }) => {
321
321
  // console.log(output);
322
322
  const outputValue =
323
323
  OperationHandlerResult.getSuccessfulValueOrFail(output);
324
- expect(outputValue.parents).toEqual({child: 'test'});
324
+ expect(outputValue['parents']).toEqual({'child': 'test'});
325
325
  })
326
326
  .finallyDoNothing()
327
327
  )
@@ -423,12 +423,12 @@ describe('GenerateHandlerTest', () => {
423
423
  .testCase('should ${input.operationNameCamelCase}', (testCase) =>
424
424
  testCase
425
425
  .givenNothing()
426
- .when(() => ({ ids: [2] }))
426
+ .when(() => ({ 'ids': [2] }))
427
427
  .then(({ output }) => {
428
428
  // console.log(output);
429
429
  const outputValue =
430
430
  OperationHandlerResult.getSuccessfulValueOrFail(output);
431
- expect(outputValue.parents).toEqual(['test']);
431
+ expect(outputValue['parents']).toEqual(['test']);
432
432
  })
433
433
  .finallyDoNothing()
434
434
  )
@@ -535,7 +535,7 @@ describe('GenerateHandlerTest', () => {
535
535
  // console.log(output);
536
536
  const outputValue =
537
537
  OperationHandlerResult.getSuccessfulValueOrFail(output);
538
- expect(outputValue.parents).toEqual({child: 'test', valueList: ['test']});
538
+ expect(outputValue['parents']).toEqual({'child': 'test', 'valueList': ['test']});
539
539
  })
540
540
  .finallyDoNothing()
541
541
  )
@@ -630,7 +630,7 @@ describe('GenerateHandlerTest', () => {
630
630
  // console.log(output);
631
631
  const outputValue =
632
632
  OperationHandlerResult.getSuccessfulValueOrFail(output);
633
- expect(outputValue.parents).toEqual([{child: 'test'}]);
633
+ expect(outputValue['parents']).toEqual([{'child': 'test'}]);
634
634
  })
635
635
  .finallyDoNothing()
636
636
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trayio/tray-openapi",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
4
4
  "description": "Creating CDK Projects from OpenAPI 3.0 Schemas",
5
5
  "exports": {
6
6
  "./*": "./dist/*.js"