11describe ( "Tests extended classes " , function ( ) {
22
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 ( ) {
44 var MyButton = com . tns . tests . Button1 . extend ( {
55 toString : function ( ) {
66 return "overriden toString method of chronometer instance" ;
@@ -21,8 +21,56 @@ describe("Tests extended classes ", function () {
2121 expect ( labelToString ) . not . toBe ( labelToString1 ) ;
2222 expect ( labelgetIMAGE_ID_PROP ) . not . toBe ( labelgetIMAGE_ID_PROP1 ) ;
2323 } ) ;
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+ } ) ;
2472
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 ( ) {
2674
2775 var MyButton = com . tns . tests . Button1 . extend ( {
2876 toString : function ( ) {
@@ -53,7 +101,7 @@ describe("Tests extended classes ", function () {
53101 expect ( labelgetIMAGE_ID_PROP ) . not . toBe ( labelgetIMAGE_ID_PROP1 ) ;
54102 } ) ;
55103
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 ( ) {
57105
58106 var button1 = new com . tns . tests . Button1 ( ) ;
59107 var labelgetIMAGE_ID_PROP1 = button1 . getIMAGE_ID_PROP ( ) ;
@@ -74,7 +122,7 @@ describe("Tests extended classes ", function () {
74122 expect ( labelgetIMAGE_ID_PROP1 ) . toBe ( labelgetIMAGE_ID_PROP2 ) ;
75123 } ) ;
76124
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 ( ) {
78126 let MyObj = java . lang . Object . extend ( {
79127 toString : ( ) => { return "It's MyObj" }
80128 } ) ;
0 commit comments