Skip to content

Commit ef4989a

Browse files
Modify unit tests for typescript-fetch, issue 21259 to check for closing parens & fix a typo in TypeScriptFetchModelTest
1 parent 2f70572 commit ef4989a

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientCodegenTest.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -356,19 +356,21 @@ public void givenSchemaIsOneOfAndComposedSchemasArePrimitiveThenReturnStatements
356356

357357
Path exampleModelPath = Paths.get(outputPath + "/models/MyCustomSpeed.ts");
358358
//FromJSON
359-
TestUtils.assertFileContains(exampleModelPath, "typeof json === 'number'");
360-
TestUtils.assertFileContains(exampleModelPath, "typeof json === 'string'");
361-
TestUtils.assertFileContains(exampleModelPath, "json === 'fixed-value-a' || json === 'fixed-value-b' || json === 'fixed-value-c'");
362-
TestUtils.assertFileContains(exampleModelPath, "isNaN(new Date(json).getTime())");
363-
TestUtils.assertFileContains(exampleModelPath, "json.every(item => typeof item === 'number'");
364-
TestUtils.assertFileContains(exampleModelPath, "json.every(item => typeof item === 'string' && (item === 'oneof-array-enum-a' || item === 'oneof-array-enum-b' || item === 'oneof-array-enum-c')");
359+
TestUtils.assertFileContains(exampleModelPath, "(typeof json !== 'object')");
360+
TestUtils.assertFileContains(exampleModelPath, "(instanceOfMyNumericValue(json))");
361+
TestUtils.assertFileContains(exampleModelPath, "(typeof json === 'number' && (json === 10 || json === 20 || json === 30))");
362+
TestUtils.assertFileContains(exampleModelPath, "(typeof json === 'string' && (json === 'fixed-value-a' || json === 'fixed-value-b' || json === 'fixed-value-c'))");
363+
TestUtils.assertFileContains(exampleModelPath, "(isNaN(new Date(json).getTime())");
364+
TestUtils.assertFileContains(exampleModelPath, "(json.every(item => typeof item === 'number'))");
365+
TestUtils.assertFileContains(exampleModelPath, "(json.every(item => typeof item === 'string' && (item === 'oneof-array-enum-a' || item === 'oneof-array-enum-b' || item === 'oneof-array-enum-c')))");
365366
//ToJSON
366-
TestUtils.assertFileContains(exampleModelPath, "typeof value === 'number'");
367-
TestUtils.assertFileContains(exampleModelPath, "typeof value === 'string'");
368-
TestUtils.assertFileContains(exampleModelPath, "value === 'fixed-value-a' || value === 'fixed-value-b' || value === 'fixed-value-c'");
369-
TestUtils.assertFileContains(exampleModelPath, "value instanceof Date");
370-
TestUtils.assertFileContains(exampleModelPath, "value.every(item => typeof item === 'number'");
371-
TestUtils.assertFileContains(exampleModelPath, "value.every(item => typeof item === 'string' && (item === 'oneof-array-enum-a' || item === 'oneof-array-enum-b' || item === 'oneof-array-enum-c')");
367+
TestUtils.assertFileContains(exampleModelPath, "(typeof value !== 'object')");
368+
TestUtils.assertFileContains(exampleModelPath, "(instanceOfMyNumericValue(value))");
369+
TestUtils.assertFileContains(exampleModelPath, "(typeof value === 'number' && (value === 10 || value === 20 || value === 30))");
370+
TestUtils.assertFileContains(exampleModelPath, "(typeof value === 'string' && (value === 'fixed-value-a' || value === 'fixed-value-b' || value === 'fixed-value-c'))");
371+
TestUtils.assertFileContains(exampleModelPath, "(value instanceof Date)");
372+
TestUtils.assertFileContains(exampleModelPath, "(value.every(item => typeof item === 'number'))");
373+
TestUtils.assertFileContains(exampleModelPath, "(value.every(item => typeof item === 'string' && (item === 'oneof-array-enum-a' || item === 'oneof-array-enum-b' || item === 'oneof-array-enum-c')))");
372374
}
373375

374376
/**

modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchModelTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
@SuppressWarnings("static-method")
4848
public class TypeScriptFetchModelTest {
4949

50-
@Test(description = "convert a simple TypeScript Angular model")
50+
@Test(description = "convert a simple TypeScript Fetch model")
5151
public void simpleModelTest() {
5252
final Schema model = new Schema()
5353
.description("a sample model")

0 commit comments

Comments
 (0)