File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
typescript-generator-core/src/test/java/cz/habarta/typescript/generator Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ package cz .habarta .typescript .generator ;
3+
4+ import java .util .*;
5+ import org .junit .Assert ;
6+ import org .junit .Test ;
7+
8+
9+ public class CovariantPropertiesTest {
10+
11+ @ Test
12+ public void test () {
13+ final Settings settings = TestUtils .settings ();
14+ settings .sortDeclarations = true ;
15+ final String output = new TypeScriptGenerator (settings ).generateTypeScript (Input .from (Dog .class ));
16+ final String expected =
17+ "interface Animal {\n " +
18+ " allFood: Food[];\n " +
19+ " todaysFood: Food;\n " +
20+ "}\n " +
21+ "\n " +
22+ "interface Dog extends Animal {\n " +
23+ " allFood: DogFood[];\n " +
24+ " todaysFood: DogFood;\n " +
25+ "}\n " +
26+ "\n " +
27+ "interface DogFood extends Food {\n " +
28+ "}\n " +
29+ "\n " +
30+ "interface Food {\n " +
31+ "}" ;
32+ Assert .assertEquals (expected .replace ('\'' , '"' ), output .trim ());
33+ }
34+
35+ private static abstract class Animal {
36+ public abstract Food getTodaysFood ();
37+ public abstract List <? extends Food > getAllFood ();
38+ }
39+
40+ private static abstract class Dog extends Animal {
41+ @ Override
42+ public abstract DogFood getTodaysFood ();
43+ @ Override
44+ public abstract List <? extends DogFood > getAllFood ();
45+ }
46+
47+ private static abstract class Food {
48+ }
49+
50+ private static abstract class DogFood extends Food {
51+ }
52+
53+ }
You can’t perform that action at this time.
0 commit comments