1
1
describe ( "Tests extended classes " , function ( ) {
2
2
3
- it ( "Instance_with_no_extension_shouldnt_use_previously_defined_implementation_object " , function ( ) {
3
+ it ( "Instance with no extension shouldn't use previously defined implementation object " , function ( ) {
4
4
var MyButton = com . tns . tests . Button1 . extend ( {
5
5
toString : function ( ) {
6
6
return "overriden toString method of chronometer instance" ;
@@ -21,8 +21,56 @@ describe("Tests extended classes ", function () {
21
21
expect ( labelToString ) . not . toBe ( labelToString1 ) ;
22
22
expect ( labelgetIMAGE_ID_PROP ) . not . toBe ( labelgetIMAGE_ID_PROP1 ) ;
23
23
} ) ;
24
+
25
+ it ( "Having a class with static method named 'extend' and overriding it in a child class shouldn't crash the app" , function ( ) {
26
+
27
+ /* JS below the comment is generated from the following TS code
28
+
29
+ class Base{
30
+ static extend(){
31
+ return "expectedValue";
32
+ }
33
+ }
34
+
35
+ class Child extends Base{}
36
+
37
+ const superProto = Object.getPrototypeOf(Child.prototype)
38
+ const Super = superProto.constructor;
39
+ Super.extend();
40
+
41
+ var child = Object.create(Child);
42
+ child.extend();
43
+ Child.extend();
44
+
45
+ */
46
+
47
+ var Base = /** @class */ ( function ( ) {
48
+ function Base ( ) {
49
+ }
50
+ Base . extend = function ( ) {
51
+ return "expectedValue" ;
52
+ } ;
53
+ return Base ;
54
+ } ( ) ) ;
55
+ var Child = /** @class */ ( function ( _super ) {
56
+ __extends ( Child , _super ) ;
57
+ function Child ( ) {
58
+ return _super !== null && _super . apply ( this , arguments ) || this ;
59
+ }
60
+ return Child ;
61
+ } ( Base ) ) ;
62
+
63
+ var superProto = Object . getPrototypeOf ( Child . prototype ) ;
64
+ var Super = superProto . constructor ;
65
+ expect ( Super . extend ( ) ) . toBe ( "expectedValue" ) ;
66
+
67
+ var child = Object . create ( Child ) ;
68
+ expect ( child . extend ( ) ) . toBe ( "expectedValue" ) ;
69
+
70
+ expect ( Child . extend ( ) ) . toBe ( "expectedValue" ) ;
71
+ } ) ;
24
72
25
- it ( "Instance_with_extension_shouldnt_use_previously_defined_implementation_object " , function ( ) {
73
+ it ( "Instance with extension shouldn't use previously defined implementation object " , function ( ) {
26
74
27
75
var MyButton = com . tns . tests . Button1 . extend ( {
28
76
toString : function ( ) {
@@ -53,7 +101,7 @@ describe("Tests extended classes ", function () {
53
101
expect ( labelgetIMAGE_ID_PROP ) . not . toBe ( labelgetIMAGE_ID_PROP1 ) ;
54
102
} ) ;
55
103
56
- it ( "Newly_created_instances_should_behave_the_same_and_not_use_previously_defined_implementation_objects " , function ( ) {
104
+ it ( "Newly created instances should behave the same and not use previously defined implementation objects " , function ( ) {
57
105
58
106
var button1 = new com . tns . tests . Button1 ( ) ;
59
107
var labelgetIMAGE_ID_PROP1 = button1 . getIMAGE_ID_PROP ( ) ;
@@ -74,7 +122,7 @@ describe("Tests extended classes ", function () {
74
122
expect ( labelgetIMAGE_ID_PROP1 ) . toBe ( labelgetIMAGE_ID_PROP2 ) ;
75
123
} ) ;
76
124
77
- it ( "should not crash with no exception when incorrectly calling extended class constructor" , function ( ) {
125
+ it ( "Should not crash with no exception when incorrectly calling extended class constructor" , function ( ) {
78
126
let MyObj = java . lang . Object . extend ( {
79
127
toString : ( ) => { return "It's MyObj" }
80
128
} ) ;
0 commit comments