Best JavaScript code snippet using ts-auto-mock
ember_computed_test.js
Source:ember_computed_test.js  
1/**2 * Licensed to the Apache Software Foundation (ASF) under one3 * or more contributor license agreements.  See the NOTICE file4 * distributed with this work for additional information5 * regarding copyright ownership.  The ASF licenses this file6 * to you under the Apache License, Version 2.0 (the7 * "License"); you may not use this file except in compliance8 * with the License.  You may obtain a copy of the License at9 *10 *     http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * distributed under the License is distributed on an "AS IS" BASIS,14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15 * See the License for the specific language governing permissions and16 * limitations under the License.17 */18require('utils/ember_computed');19describe('Ember.computed macros', function () {20  beforeEach(function () {21    App.reopen({22      someRandomTestingKey: function () {23        return this.get('someAnotherKey');24      }.property('someAnotherKey'),25      someAnotherKey: '',26      appProp1: 1,27      appProp2: 228    });29  });30  afterEach(function () {31    delete App.someAnotherKey;32    delete App.someRandomTestingKey;33  });34  describe('#equal', function () {35    beforeEach(function () {36      App.setProperties({37        someAnotherKey: '123'38      });39      this.obj = Em.Object.create({40        prop1: '123',41        prop2: Em.computed.equal('prop1', '123'),42        prop3: Em.computed.equal('App.someRandomTestingKey', '123')43      });44    });45    it('`true` if values are equal', function () {46      expect(this.obj.get('prop2')).to.be.true;47    });48    it('`false` if values are not equal', function () {49      this.obj.set('prop1', '321');50      expect(this.obj.get('prop2')).to.be.false;51    });52    it('`prop3` depends on App.* key', function () {53      expect(this.obj.get('prop3')).to.be.true;54      App.set('someAnotherKey', '');55      expect(this.obj.get('prop3')).to.be.false;56    });57    it('prop3 dependent keys are valid', function () {58      expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['App.someRandomTestingKey']);59    });60  });61  describe('#notEqual', function () {62    beforeEach(function () {63      App.setProperties({64        someAnotherKey: '123'65      });66      this.obj = Em.Object.create({67        prop1: '123',68        prop2: Em.computed.notEqual('prop1', '123'),69        prop3: Em.computed.notEqual('App.someRandomTestingKey', '123')70      });71    });72    it('`false` if values are equal', function () {73      expect(this.obj.get('prop2')).to.be.false;74    });75    it('`true` if values are not equal', function () {76      this.obj.set('prop1', '321');77      expect(this.obj.get('prop2')).to.be.true;78    });79    it('`prop3` depends on App.* key', function () {80      expect(this.obj.get('prop3')).to.be.false;81      App.set('someAnotherKey', '');82      expect(this.obj.get('prop3')).to.be.true;83    });84    it('prop3 dependent keys are valid', function () {85      expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['App.someRandomTestingKey']);86    });87  });88  describe('#equalProperties', function () {89    beforeEach(function () {90      App.set('someAnotherKey', '123');91      this.obj = Em.Object.create({92        prop1: '123',93        prop2: '123',94        prop3: Em.computed.equalProperties('prop1', 'prop2'),95        prop4: Em.computed.equalProperties('App.someRandomTestingKey', 'prop2'),96        prop5: Em.computed.equalProperties('prop1', 'App.someRandomTestingKey')97      });98    });99    it('`true` if values are equal', function () {100      expect(this.obj.get('prop3')).to.be.true;101    });102    it('`false` if values are not equal', function () {103      this.obj.set('prop1', '321');104      expect(this.obj.get('prop3')).to.be.false;105    });106    it('prop4 depends on App.* key', function () {107      expect(this.obj.get('prop4')).to.be.true;108      App.set('someAnotherKey', '');109      expect(this.obj.get('prop4')).to.be.false;110    });111    it('prop5 depends on App.* key', function () {112      expect(this.obj.get('prop5')).to.be.true;113      App.set('someAnotherKey', '');114      expect(this.obj.get('prop5')).to.be.false;115    });116    it('prop4 dependent keys are valid', function () {117      expect(Em.meta(this.obj).descs.prop4._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop2']);118    });119    it('prop5 dependent keys are valid', function () {120      expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['prop1', 'App.someRandomTestingKey']);121    });122  });123  describe('#notEqualProperties', function () {124    beforeEach(function () {125      App.set('someAnotherKey', '123');126      this.obj = Em.Object.create({127        prop1: '123',128        prop2: '123',129        prop3: Em.computed.notEqualProperties('prop1', 'prop2'),130        prop4: Em.computed.notEqualProperties('App.someRandomTestingKey', 'prop2'),131        prop5: Em.computed.notEqualProperties('prop1', 'App.someRandomTestingKey')132      });133    });134    it('`false` if values are equal', function () {135      expect(this.obj.get('prop3')).to.be.false;136    });137    it('`true` if values are not equal', function () {138      this.obj.set('prop1', '321');139      expect(this.obj.get('prop3')).to.be.true;140    });141    it('prop4 depends on App.* key', function () {142      expect(this.obj.get('prop4')).to.be.false;143      App.set('someAnotherKey', '');144      expect(this.obj.get('prop4')).to.be.true;145    });146    it('prop5 depends on App.* key', function () {147      expect(this.obj.get('prop5')).to.be.false;148      App.set('someAnotherKey', '');149      expect(this.obj.get('prop5')).to.be.true;150    });151    it('prop4 dependent keys are valid', function () {152      expect(Em.meta(this.obj).descs.prop4._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop2']);153    });154    it('prop5 dependent keys are valid', function () {155      expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['prop1', 'App.someRandomTestingKey']);156    });157  });158  describe('#ifThenElse', function () {159    beforeEach(function () {160      App.set('someAnotherKey', true);161      this.obj = Em.Object.create({162        prop1: true,163        prop2: Em.computed.ifThenElse('prop1', '1', '0'),164        prop3: Em.computed.ifThenElse('App.someRandomTestingKey', '1', '0')165      });166    });167    it('`1` if `prop1` is true', function () {168      expect(this.obj.get('prop2')).to.equal('1');169    });170    it('`0` if `prop1` is false', function () {171      this.obj.set('prop1', false);172      expect(this.obj.get('prop2')).to.equal('0');173    });174    it('prop3 depends on App.* key', function () {175      expect(this.obj.get('prop3')).to.equal('1');176      App.set('someAnotherKey', false);177      expect(this.obj.get('prop3')).to.equal('0');178    });179    it('prop3 dependent keys are valid', function () {180      expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['App.someRandomTestingKey']);181    });182  });183  describe('#ifThenElseByKeys', function () {184    beforeEach(function () {185      App.set('someAnotherKey', true);186      this.obj = Em.Object.create({187        prop1: true,188        prop2: Em.computed.ifThenElseByKeys('prop1', 'prop4', 'prop5'),189        prop3: Em.computed.ifThenElseByKeys('App.someRandomTestingKey', 'App.appProp1', 'App.appProp2'),190        prop4: 1,191        prop5: 2192      });193    });194    it('`1` if `prop1` is true', function () {195      expect(this.obj.get('prop2')).to.equal(1);196    });197    it('`0` if `prop1` is false', function () {198      this.obj.set('prop1', false);199      expect(this.obj.get('prop2')).to.equal(2);200    });201    it('prop2 dependent keys are valid', function () {202      expect(Em.meta(this.obj).descs.prop2._dependentKeys).to.eql(['prop1', 'prop4', 'prop5']);203    });204    it('prop3 depends on App.* key', function () {205      expect(this.obj.get('prop3')).to.equal(1);206      App.set('someAnotherKey', false);207      expect(this.obj.get('prop3')).to.equal(2);208    });209    it('prop3 dependent keys are valid', function () {210      expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['App.someRandomTestingKey', 'App.appProp1', 'App.appProp2']);211    });212  });213  describe('#and', function () {214    beforeEach(function () {215      App.setProperties({216        someAnotherKey: true217      });218      this.obj = Em.Object.create({219        prop1: true,220        prop2: true,221        prop3: true,222        prop4: Em.computed.and('prop1', 'prop2', 'prop3'),223        prop5: Em.computed.and('prop1', '!prop2', '!prop3'),224        prop6: Em.computed.and('App.someRandomTestingKey', 'prop1'),225        prop7: Em.computed.and('!App.someRandomTestingKey', 'prop1')226      });227    });228    it('prop4 `true` if all dependent properties are true', function () {229      expect(this.obj.get('prop4')).to.be.true;230    });231    it('prop4 `false` if at elast one dependent property is false', function () {232      this.obj.set('prop2', false);233      expect(this.obj.get('prop4')).to.be.false;234    });235    it('prop5 dependent keys are valid', function () {236      expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['prop1', 'prop2', 'prop3']);237    });238    it('prop5 `false` if some inverted dependent properties is true', function () {239      expect(this.obj.get('prop5')).to.be.false;240    });241    it('prop5 `false` if some inverted dependent properties is true (2)', function () {242      this.obj.set('prop1', true);243      expect(this.obj.get('prop5')).to.be.false;244    });245    it('prop5 `true` ', function () {246      this.obj.set('prop2', false);247      this.obj.set('prop3', false);248      expect(this.obj.get('prop5')).to.be.true;249    });250    it('`prop6` depends on App.* key', function () {251      expect(this.obj.get('prop6')).to.be.true;252      App.set('someAnotherKey', false);253      expect(this.obj.get('prop6')).to.be.false;254      App.set('someAnotherKey', true);255      expect(this.obj.get('prop6')).to.be.true;256    });257    it('prop6 dependent keys are valid', function () {258      expect(Em.meta(this.obj).descs.prop6._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop1']);259    });260    it('`prop7` depends on inverted App.* key', function () {261      expect(this.obj.get('prop7')).to.be.false;262      App.set('someAnotherKey', false);263      expect(this.obj.get('prop7')).to.be.true;264      App.set('someAnotherKey', true);265      expect(this.obj.get('prop7')).to.be.false;266    });267    it('prop7 dependent keys are valid', function () {268      expect(Em.meta(this.obj).descs.prop7._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop1']);269    });270  });271  describe('#or', function () {272    beforeEach(function () {273      App.setProperties({274        someAnotherKey: true275      });276      this.obj = Em.Object.create({277        prop1: false,278        prop2: false,279        prop3: false,280        prop4: Em.computed.or('prop1', 'prop2', 'prop3'),281        prop5: Em.computed.or('!prop1', '!prop2', '!prop3'),282        prop6: Em.computed.or('App.someRandomTestingKey', 'prop1'),283        prop7: Em.computed.or('!App.someRandomTestingKey', 'prop1')284      });285    });286    it('`false` if all dependent properties are false', function () {287      expect(this.obj.get('prop4')).to.be.false;288    });289    it('`true` if at elast one dependent property is true', function () {290      this.obj.set('prop2', true);291      expect(this.obj.get('prop4')).to.be.true;292    });293    it('prop5 dependent keys are valid', function () {294      expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['prop1', 'prop2', 'prop3']);295    });296    it('prop5 `true` if some inverted dependent properties is true', function () {297      expect(this.obj.get('prop5')).to.be.true;298    });299    it('prop5 `true` if some inverted dependent properties is true (2)', function () {300      this.obj.set('prop1', true);301      expect(this.obj.get('prop5')).to.be.true;302    });303    it('prop5 `false` ', function () {304      this.obj.set('prop1', true);305      this.obj.set('prop2', true);306      this.obj.set('prop3', true);307      expect(this.obj.get('prop5')).to.be.false;308    });309    it('`prop6` depends on App.* key', function () {310      expect(this.obj.get('prop6')).to.be.true;311      App.set('someAnotherKey', false);312      expect(this.obj.get('prop6')).to.be.false;313      App.set('someAnotherKey', true);314      expect(this.obj.get('prop6')).to.be.true;315    });316    it('prop6 dependent keys are valid', function () {317      expect(Em.meta(this.obj).descs.prop6._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop1']);318    });319    it('`prop7` depends on inverted App.* key', function () {320      expect(this.obj.get('prop7')).to.be.false;321      App.set('someAnotherKey', false);322      expect(this.obj.get('prop7')).to.be.true;323      App.set('someAnotherKey', true);324      expect(this.obj.get('prop7')).to.be.false;325    });326    it('prop7 dependent keys are valid', function () {327      expect(Em.meta(this.obj).descs.prop7._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop1']);328    });329  });330  describe('#sumProperties', function () {331    beforeEach(function () {332      App.setProperties({333        someAnotherKey: 5334      });335      this.obj = Em.Object.create({336        prop1: 1,337        prop2: 2,338        prop3: 3,339        prop4: Em.computed.sumProperties('prop1', 'prop2', 'prop3'),340        prop5: Em.computed.sumProperties('prop1', 'prop2', 'App.someRandomTestingKey')341      });342    });343    it('should be sum of dependent values', function () {344      expect(this.obj.get('prop4')).to.equal(6);345    });346    it('should be updated if some dependent value is changed', function () {347      this.obj.set('prop1', 4);348      expect(this.obj.get('prop4')).to.equal(9);349    });350    it('should be updated if some dependent value is string', function () {351      this.obj.set('prop1', '4');352      expect(this.obj.get('prop4')).to.equal(9);353    });354    it('should be updated if some dependent value is string (2)', function () {355      this.obj.set('prop1', '4.5');356      expect(this.obj.get('prop4')).to.equal(9.5);357    });358    it('should be updated if some dependent value is null', function () {359      this.obj.set('prop1', null);360      expect(this.obj.get('prop4')).to.equal(5);361    });362    it('`prop5` depends on App.* key', function () {363      expect(this.obj.get('prop5')).to.equal(8);364      App.set('someAnotherKey', 6);365      expect(this.obj.get('prop5')).to.equal(9);366    });367    it('prop5 dependent keys are valid', function () {368      expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['prop1', 'prop2', 'App.someRandomTestingKey']);369    });370  });371  describe('#gte', function () {372    beforeEach(function () {373      App.set('someAnotherKey', 4);374      this.obj = Em.Object.create({375        prop1: 2,376        prop2: Em.computed.gte('prop1', 3),377        prop3: Em.computed.gte('App.someRandomTestingKey', 3)378      });379    });380    it('`false` if value is less than needed', function () {381      expect(this.obj.get('prop2')).to.be.false;382    });383    it('`true` if value is equal to the needed', function () {384      this.obj.set('prop1', 3);385      expect(this.obj.get('prop2')).to.be.true;386    });387    it('`true` if value is greater than needed', function () {388      this.obj.set('prop1', 4);389      expect(this.obj.get('prop2')).to.be.true;390    });391    it('prop3 depends on App.* key', function () {392      expect(this.obj.get('prop3')).to.be.true;393      App.set('someAnotherKey', 3);394      expect(this.obj.get('prop3')).to.be.true;395      App.set('someAnotherKey', 2);396      expect(this.obj.get('prop3')).to.be.false;397    });398    it('prop3 dependent keys are valid', function () {399      expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['App.someRandomTestingKey']);400    });401  });402  describe('#gteProperties', function () {403    beforeEach(function () {404      App.set('someAnotherKey', 4);405      this.obj = Em.Object.create({406        prop1: 2,407        prop2: 3,408        prop3: Em.computed.gteProperties('prop1', 'prop2'),409        prop4: Em.computed.gteProperties('App.someRandomTestingKey', 'prop2'),410        prop5: Em.computed.gteProperties('prop1', 'App.someRandomTestingKey')411      });412    });413    it('`false` if value is less than needed', function () {414      expect(this.obj.get('prop3')).to.be.false;415    });416    it('`true` if value is equal to the needed', function () {417      this.obj.set('prop1', 3);418      expect(this.obj.get('prop3')).to.be.true;419    });420    it('`true` if value is greater than needed', function () {421      this.obj.set('prop1', 4);422      expect(this.obj.get('prop3')).to.be.true;423    });424    it('prop4 depends on App.* key', function () {425      expect(this.obj.get('prop4')).to.be.true;426      App.set('someAnotherKey', 3);427      expect(this.obj.get('prop4')).to.be.true;428      App.set('someAnotherKey', 2);429      expect(this.obj.get('prop4')).to.be.false;430    });431    it('prop5 depends on App.* key', function () {432      expect(this.obj.get('prop5')).to.be.false;433      App.set('someAnotherKey', 2);434      expect(this.obj.get('prop5')).to.be.true;435      App.set('someAnotherKey', 1);436      expect(this.obj.get('prop5')).to.be.true;437    });438    it('prop4 dependent keys are valid', function () {439      expect(Em.meta(this.obj).descs.prop4._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop2']);440    });441    it('prop5 dependent keys are valid', function () {442      expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['prop1', 'App.someRandomTestingKey']);443    });444  });445  describe('#lte', function () {446    beforeEach(function () {447      App.set('someAnotherKey', 0);448      this.obj = Em.Object.create({449        prop1: 2,450        prop2: Em.computed.lte('prop1', 1),451        prop3: Em.computed.lte('App.someRandomTestingKey', 1)452      });453    });454    it('`false` if value is greater  than needed', function () {455      expect(this.obj.get('prop2')).to.be.false;456    });457    it('`true` if value is equal to the needed', function () {458      this.obj.set('prop1', 1);459      expect(this.obj.get('prop2')).to.be.true;460    });461    it('`true` if value is less than needed', function () {462      this.obj.set('prop1', 0);463      expect(this.obj.get('prop2')).to.be.true;464    });465    it('prop3 depends on App.* key', function () {466      expect(this.obj.get('prop3')).to.be.true;467      App.set('someAnotherKey', 1);468      expect(this.obj.get('prop3')).to.be.true;469      App.set('someAnotherKey', 2);470      expect(this.obj.get('prop3')).to.be.false;471    });472    it('prop3 dependent keys are valid', function () {473      expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['App.someRandomTestingKey']);474    });475  });476  describe('#lteProperties', function () {477    beforeEach(function () {478      App.set('someAnotherKey', 1);479      this.obj = Em.Object.create({480        prop1: 2,481        prop2: 1,482        prop3: Em.computed.lteProperties('prop1', 'prop2'),483        prop4: Em.computed.lteProperties('App.someRandomTestingKey', 'prop2'),484        prop5: Em.computed.lteProperties('prop1', 'App.someRandomTestingKey')485      });486    });487    it('`false` if d1 is greater than d2', function () {488      expect(this.obj.get('prop3')).to.be.false;489    });490    it('`true` if d1 is equal to the d2', function () {491      this.obj.set('prop1', 1);492      expect(this.obj.get('prop3')).to.be.true;493    });494    it('`true` if d1 is less than d2', function () {495      this.obj.set('prop1', 0);496      expect(this.obj.get('prop3')).to.be.true;497    });498    it('prop4 depends on App.* key', function () {499      expect(this.obj.get('prop4')).to.be.true;500      App.set('someAnotherKey', 0);501      expect(this.obj.get('prop4')).to.be.true;502      App.set('someAnotherKey', 2);503      expect(this.obj.get('prop4')).to.be.false;504    });505    it('prop5 depends on App.* key', function () {506      expect(this.obj.get('prop5')).to.be.false;507      App.set('someAnotherKey', 2);508      expect(this.obj.get('prop5')).to.be.true;509      App.set('someAnotherKey', 3);510      expect(this.obj.get('prop5')).to.be.true;511    });512    it('prop4 dependent keys are valid', function () {513      expect(Em.meta(this.obj).descs.prop4._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop2']);514    });515    it('prop5 dependent keys are valid', function () {516      expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['prop1', 'App.someRandomTestingKey']);517    });518  });519  describe('#gt', function () {520    beforeEach(function () {521      App.set('someAnotherKey', 4);522      this.obj = Em.Object.create({523        prop1: 2,524        prop2: Em.computed.gt('prop1', 3),525        prop3: Em.computed.gt('App.someRandomTestingKey', 3)526      });527    });528    it('`false` if value is less than needed', function () {529      expect(this.obj.get('prop2')).to.be.false;530    });531    it('`false` if value is equal to the needed', function () {532      this.obj.set('prop1', 3);533      expect(this.obj.get('prop2')).to.be.false;534    });535    it('`true` if value is greater than needed', function () {536      this.obj.set('prop1', 4);537      expect(this.obj.get('prop2')).to.be.true;538    });539    it('prop3 depends on App.* key', function () {540      expect(this.obj.get('prop3')).to.be.true;541      App.set('someAnotherKey', 3);542      expect(this.obj.get('prop3')).to.be.false;543      App.set('someAnotherKey', 2);544      expect(this.obj.get('prop3')).to.be.false;545    });546    it('prop3 dependent keys are valid', function () {547      expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['App.someRandomTestingKey']);548    });549  });550  describe('#gtProperties', function () {551    beforeEach(function () {552      App.set('someAnotherKey', 4);553      this.obj = Em.Object.create({554        prop1: 2,555        prop2: 3,556        prop3: Em.computed.gtProperties('prop1', 'prop2'),557        prop4: Em.computed.gtProperties('App.someRandomTestingKey', 'prop2'),558        prop5: Em.computed.gtProperties('prop1', 'App.someRandomTestingKey')559      });560    });561    it('`false` if value is less than needed', function () {562      expect(this.obj.get('prop3')).to.be.false;563    });564    it('`false` if value is equal to the needed', function () {565      this.obj.set('prop1', 3);566      expect(this.obj.get('prop3')).to.be.false;567    });568    it('`true` if value is greater than needed', function () {569      this.obj.set('prop1', 4);570      expect(this.obj.get('prop3')).to.be.true;571    });572    it('prop4 depends on App.* key', function () {573      expect(this.obj.get('prop4')).to.be.true;574      App.set('someAnotherKey', 3);575      expect(this.obj.get('prop4')).to.be.false;576      App.set('someAnotherKey', 2);577      expect(this.obj.get('prop4')).to.be.false;578    });579    it('prop5 depends on App.* key', function () {580      expect(this.obj.get('prop5')).to.be.false;581      App.set('someAnotherKey', 2);582      expect(this.obj.get('prop5')).to.be.false;583      App.set('someAnotherKey', 1);584      expect(this.obj.get('prop5')).to.be.true;585    });586    it('prop4 dependent keys are valid', function () {587      expect(Em.meta(this.obj).descs.prop4._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop2']);588    });589    it('prop5 dependent keys are valid', function () {590      expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['prop1', 'App.someRandomTestingKey']);591    });592  });593  describe('#lt', function () {594    beforeEach(function () {595      App.set('someAnotherKey', 0);596      this.obj = Em.Object.create({597        prop1: 2,598        prop2: Em.computed.lt('prop1', 1),599        prop3: Em.computed.lt('App.someRandomTestingKey', 1)600      });601    });602    it('`false` if value is greater  than needed', function () {603      expect(this.obj.get('prop2')).to.be.false;604    });605    it('`false` if value is equal to the needed', function () {606      this.obj.set('prop1', 1);607      expect(this.obj.get('prop2')).to.be.false;608    });609    it('`true` if value is less than needed', function () {610      this.obj.set('prop1', 0);611      expect(this.obj.get('prop2')).to.be.true;612    });613    it('prop3 depends on App.* key', function () {614      expect(this.obj.get('prop3')).to.be.true;615      App.set('someAnotherKey', 1);616      expect(this.obj.get('prop3')).to.be.false;617      App.set('someAnotherKey', 2);618      expect(this.obj.get('prop3')).to.be.false;619    });620    it('prop3 dependent keys are valid', function () {621      expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['App.someRandomTestingKey']);622    });623  });624  describe('#ltProperties', function () {625    beforeEach(function () {626      App.set('someAnotherKey', 1);627      this.obj = Em.Object.create({628        prop1: 2,629        prop2: 1,630        prop3: Em.computed.ltProperties('prop1', 'prop2'),631        prop4: Em.computed.ltProperties('App.someRandomTestingKey', 'prop2'),632        prop5: Em.computed.ltProperties('prop1', 'App.someRandomTestingKey')633      });634    });635    it('`false` if d1 is greater than d2', function () {636      expect(this.obj.get('prop3')).to.be.false;637    });638    it('`false` if d1 is equal to the d2', function () {639      this.obj.set('prop1', 1);640      expect(this.obj.get('prop3')).to.be.false;641    });642    it('`true` if d1 is less than d2', function () {643      this.obj.set('prop1', 0);644      expect(this.obj.get('prop3')).to.be.true;645    });646    it('prop4 depends on App.* key', function () {647      expect(this.obj.get('prop4')).to.be.false;648      App.set('someAnotherKey', 0);649      expect(this.obj.get('prop4')).to.be.true;650      App.set('someAnotherKey', 2);651      expect(this.obj.get('prop4')).to.be.false;652    });653    it('prop5 depends on App.* key', function () {654      expect(this.obj.get('prop5')).to.be.false;655      App.set('someAnotherKey', 2);656      expect(this.obj.get('prop5')).to.be.false;657      App.set('someAnotherKey', 3);658      expect(this.obj.get('prop5')).to.be.true;659    });660    it('prop4 dependent keys are valid', function () {661      expect(Em.meta(this.obj).descs.prop4._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop2']);662    });663    it('prop5 dependent keys are valid', function () {664      expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['prop1', 'App.someRandomTestingKey']);665    });666  });667  describe('#match', function () {668    beforeEach(function () {669      this.obj = Em.Object.create({670        prop1: 'abc',671        prop2: Em.computed.match('prop1', /^ab/)672      })673    });674    it('`true` if value match regexp', function () {675      expect(this.obj.get('prop2')).to.be.true;676    });677    it('`true` if value match regexp (2)', function () {678      this.obj.set('prop1', 'abaaa');679      expect(this.obj.get('prop2')).to.be.true;680    });681    it('`false` if value doesn\'t match regexp', function () {682      this.obj.set('prop1', '!!!!');683      expect(this.obj.get('prop2')).to.be.false;684    });685    it('`prop2` has valid dependent keys', function () {686      expect(Em.meta(this.obj).descs.prop2._dependentKeys).to.eql(['prop1']);687    });688  });689  describe('#someBy', function () {690    beforeEach(function () {691      this.obj = Em.Object.create({692        prop1: [{a: 1}, {a: 2}, {a: 3}],693        prop2: Em.computed.someBy('prop1', 'a', 2)694      });695    });696    it('`true` if some collection item has needed property value', function () {697      expect(this.obj.get('prop2')).to.be.true;698    });699    it('`false` if on one collection item doesn\'t have needed property value', function () {700      this.obj.set('prop1.1.a', 3);701      expect(this.obj.get('prop2')).to.be.false;702    });703    it('`false` for null/undefined collection', function () {704      this.obj.set('prop1', null);705      expect(this.obj.get('prop2')).to.be.false;706    });707    it('`prop2` has valid dependent keys', function () {708      expect(Em.meta(this.obj).descs.prop2._dependentKeys).to.eql(['prop1.@each.a']);709    });710  });711  describe('#someByKey', function () {712    beforeEach(function () {713      App.setProperties({714        someAnotherKey: 2715      });716      this.obj = Em.Object.create({717        prop1: [{a: 1}, {a: 2}, {a: 3}],718        prop2: Em.computed.someByKey('prop1', 'a', 'value1'),719        prop3: Em.computed.someByKey('prop1', 'a', 'App.someRandomTestingKey'),720        value1: 2721      });722    });723    it('`true` if some collection item has needed property value', function () {724      expect(this.obj.get('prop2')).to.be.true;725    });726    it('`false` if on one collection item doesn\'t have needed property value', function () {727      this.obj.set('prop1.1.a', 3);728      expect(this.obj.get('prop2')).to.be.false;729    });730    it('`false` for null/undefined collection', function () {731      this.obj.set('prop1', null);732      expect(this.obj.get('prop2')).to.be.false;733    });734    it('`prop2` has valid dependent keys', function () {735      expect(Em.meta(this.obj).descs.prop2._dependentKeys).to.eql(['prop1.@each.a', 'value1']);736    });737    it('`prop3` has valid dependent keys', function () {738      expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['prop1.@each.a', 'App.someRandomTestingKey']);739    });740    it('`prop3` depends on App.* key', function () {741      expect(this.obj.get('prop3')).to.be.true;742      this.obj.set('prop1.1.a', 3);743      expect(this.obj.get('prop3')).to.be.false;744    });745  });746  describe('#everyBy', function () {747    beforeEach(function () {748      this.obj = Em.Object.create({749        prop1: [{a: 2}, {a: 2}, {a: 2}],750        prop2: Em.computed.everyBy('prop1', 'a', 2)751      });752    });753    it('`true` if all collection items have needed property value', function () {754      expect(this.obj.get('prop2')).to.be.true;755    });756    it('`false` if at least one collection item doesn\'t have needed property value', function () {757      this.obj.set('prop1.1.a', 3);758      expect(this.obj.get('prop2')).to.be.false;759    });760    it('`false` for null/undefined collection', function () {761      this.obj.set('prop1', null);762      expect(this.obj.get('prop2')).to.be.false;763    });764    it('`prop2` has valid dependent keys', function () {765      expect(Em.meta(this.obj).descs.prop2._dependentKeys).to.eql(['prop1.@each.a']);766    });767  });768  describe('#everyByKey', function () {769    beforeEach(function () {770      App.setProperties({771        someAnotherKey: 2772      });773      this.obj = Em.Object.create({774        prop1: [{a: 2}, {a: 2}, {a: 2}],775        prop2: Em.computed.everyByKey('prop1', 'a', 'value1'),776        prop3: Em.computed.everyByKey('prop1', 'a', 'App.someRandomTestingKey'),777        value1: 2778      });779    });780    it('`true` if all collection items have needed property value', function () {781      expect(this.obj.get('prop2')).to.be.true;782    });783    it('`false` if at least one collection item doesn\'t have needed property value', function () {784      this.obj.set('prop1.1.a', 3);785      expect(this.obj.get('prop2')).to.be.false;786    });787    it('`false` for null/undefined collection', function () {788      this.obj.set('prop1', null);789      expect(this.obj.get('prop2')).to.be.false;790    });791    it('`prop2` has valid dependent keys', function () {792      expect(Em.meta(this.obj).descs.prop2._dependentKeys).to.eql(['prop1.@each.a', 'value1']);793    });794    it('`prop3` has valid dependent keys', function () {795      expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['prop1.@each.a', 'App.someRandomTestingKey']);796    });797    it('`prop3` depends on App.* key', function () {798      expect(this.obj.get('prop3')).to.be.true;799      this.obj.set('prop1.1.a', 3);800      expect(this.obj.get('prop3')).to.be.false;801    });802  });803  describe('#mapBy', function () {804    beforeEach(function () {805      this.obj = Em.Object.create({806        prop1: [{a: 1}, {a: 2}, {a: 3}],807        prop2: Em.computed.mapBy('prop1', 'a')808      });809    });810    it('should map dependent property', function () {811      expect(this.obj.get('prop2')).to.eql([1, 2, 3]);812    });813    it('should map dependent property (2)', function () {814      this.obj.get('prop1').push({a: 4});815      expect(this.obj.get('prop2')).to.eql([1, 2, 3, 4]);816    });817    it('`[]` for null/undefined collection', function () {818      this.obj.set('prop1', null);819      expect(this.obj.get('prop2')).to.eql([]);820    });821    it('`prop2` has valid dependent keys', function () {822      expect(Em.meta(this.obj).descs.prop2._dependentKeys).to.eql(['prop1.@each.a']);823    });824  });825  describe('#filterBy', function () {826    beforeEach(function () {827      this.obj = Em.Object.create({828        prop1: [{a: 2}, {a: 2}, {a: 3}],829        prop2: Em.computed.filterBy('prop1', 'a', 2)830      });831    });832    it('should filter dependent property', function () {833      expect(this.obj.get('prop2')).to.eql([{a: 2}, {a: 2}]);834    });835    it('should filter dependent property (2)', function () {836      this.obj.get('prop1').pushObject({a: 2});837      expect(this.obj.get('prop2')).to.eql([{a: 2}, {a: 2}, {a: 2}]);838    });839    it('`[]` for null/undefined collection', function () {840      this.obj.set('prop1', null);841      expect(this.obj.get('prop2')).to.eql([]);842    });843    it('`prop2` has valid dependent keys', function () {844      expect(Em.meta(this.obj).descs.prop2._dependentKeys).to.eql(['prop1.@each.a']);845    });846  });847  describe('#filterByKey', function () {848    beforeEach(function () {849      App.setProperties({850        someAnotherKey: 2851      });852      this.obj = Em.Object.create({853        prop1: [{a: 2}, {a: 2}, {a: 3}],854        prop2: Em.computed.filterByKey('prop1', 'a', 'value1'),855        prop3: Em.computed.filterByKey('prop1', 'a', 'App.someRandomTestingKey'),856        value1: 2857      });858    });859    it('should filter dependent property', function () {860      expect(this.obj.get('prop2')).to.eql([{a: 2}, {a: 2}]);861    });862    it('should filter dependent property (2)', function () {863      this.obj.get('prop1').pushObject({a: 2});864      expect(this.obj.get('prop2')).to.eql([{a: 2}, {a: 2}, {a: 2}]);865    });866    it('`[]` for null/undefined collection', function () {867      this.obj.set('prop1', null);868      expect(this.obj.get('prop2')).to.eql([]);869    });870    it('`prop2` has valid dependent keys', function () {871      expect(Em.meta(this.obj).descs.prop2._dependentKeys).to.eql(['prop1.@each.a', 'value1']);872    });873    it('`prop3` has valid dependent keys', function () {874      expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['prop1.@each.a', 'App.someRandomTestingKey']);875    });876    it('`prop3` depends on App.* key', function () {877      expect(this.obj.get('prop3')).to.eql([{a: 2}, {a: 2}]);878      this.obj.set('prop1.1.a', 3);879      expect(this.obj.get('prop3')).to.eql([{a: 2}]);880    });881  });882  describe('#findBy', function () {883    beforeEach(function () {884      this.obj = Em.Object.create({885        prop1: [{b: 1, a: 2}, {b: 2, a: 2}, {a: 3}],886        prop2: Em.computed.findBy('prop1', 'a', 2)887      });888    });889    it('should filter dependent property', function () {890      expect(this.obj.get('prop2')).to.eql({b:1, a: 2});891    });892    it('should filter dependent property (2)', function () {893      this.obj.get('prop1').pushObject({b: 3, a: 2});894      expect(this.obj.get('prop2')).to.eql({b: 1, a: 2});895    });896    it('`null` for null/undefined collection', function () {897      this.obj.set('prop1', null);898      expect(this.obj.get('prop2')).to.be.null;899    });900    it('`prop2` has valid dependent keys', function () {901      expect(Em.meta(this.obj).descs.prop2._dependentKeys).to.eql(['prop1.@each.a']);902    });903  });904  describe('#findByKey', function () {905    beforeEach(function () {906      App.setProperties({907        someAnotherKey: 2908      });909      this.obj = Em.Object.create({910        prop1: [{b: 1, a: 2}, {b: 2, a: 2}, {a: 3}],911        prop2: Em.computed.findByKey('prop1', 'a', 'value1'),912        prop3: Em.computed.findByKey('prop1', 'a', 'App.someRandomTestingKey'),913        value1: 2914      });915    });916    it('should filter dependent property', function () {917      expect(this.obj.get('prop2')).to.eql({b:1, a: 2});918    });919    it('should filter dependent property (2)', function () {920      this.obj.get('prop1').pushObject({b: 3, a: 2});921      expect(this.obj.get('prop2')).to.eql({b: 1, a: 2});922    });923    it('`null` for null/undefined collection', function () {924      this.obj.set('prop1', null);925      expect(this.obj.get('prop2')).to.be.null;926    });927    it('`prop2` has valid dependent keys', function () {928      expect(Em.meta(this.obj).descs.prop2._dependentKeys).to.eql(['prop1.@each.a', 'value1']);929    });930    it('`prop3` has valid dependent keys', function () {931      expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['prop1.@each.a', 'App.someRandomTestingKey']);932    });933    it('`prop3` depends on App.* key', function () {934      expect(this.obj.get('prop3')).to.eql({b: 1, a: 2});935      this.obj.get('prop1').pushObject({b: 3, a: 2});936      expect(this.obj.get('prop3')).to.eql({b: 1, a: 2});937    });938  });939  describe('#alias', function() {940    beforeEach(function () {941      App.set('someAnotherKey', {a: {b: 1}});942      this.obj = Em.Object.create({943        prop1: {944          a: {945            b: {946              c: 1947            }948          }949        },950        prop2: Em.computed.alias('prop1.a.b.c'),951        prop3: Em.computed.alias('App.someAnotherKey.a.b')952      })953    });954    it('should be equal to dependent property', function () {955      expect(this.obj.get('prop2')).to.equal(1);956    });957    it('should be equal to dependent property (2)', function () {958      this.obj.set('prop1.a.b.c', 2);959      expect(this.obj.get('prop2')).to.equal(2);960    });961    it('prop3 depends on App.* key', function () {962      expect(this.obj.get('prop3')).to.equal(1);963      App.set('someAnotherKey.a.b', 4);964      expect(this.obj.get('prop3')).to.equal(4);965    });966    it('prop3 dependent keys are valid', function () {967      expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['App.someAnotherKey.a.b']);968    });969  });970  describe('#existsIn', function () {971    beforeEach(function () {972      this.obj = Em.Object.create({973        prop1: 'v1',974        prop2: Em.computed.existsIn('prop1', ['v1', 'v2'])975      });976    });977    it('`true` if dependent value is in the array', function () {978      expect(this.obj.get('prop2')).to.be.true;979    });980    it('`true` if dependent value is in the array (2)', function () {981      this.obj.set('prop1', 'v2');982      expect(this.obj.get('prop2')).to.be.true;983    });984    it('`false` if dependent value is not in the array', function () {985      this.obj.set('prop1', 'v3');986      expect(this.obj.get('prop2')).to.be.false;987    });988  });989  describe('#existsInByKey', function () {990    beforeEach(function () {991      this.obj = Em.Object.create({992        prop1: 'v1',993        prop2: Em.computed.existsInByKey('prop1', 'prop3'),994        prop3: ['v1', 'v2']995      });996    });997    it('`true` if dependent value is in the array', function () {998      expect(this.obj.get('prop2')).to.be.true;999    });1000    it('`true` if dependent value is in the array (2)', function () {1001      this.obj.set('prop1', 'v2');1002      expect(this.obj.get('prop2')).to.be.true;1003    });1004    it('`false` if dependent value is not in the array', function () {1005      this.obj.set('prop1', 'v3');1006      expect(this.obj.get('prop2')).to.be.false;1007    });1008    it('`false` if dependent value is not in the array (2)', function () {1009      this.obj.set('prop1', 'v1');1010      this.obj.set('prop3', ['v2', 'v3']);1011      expect(this.obj.get('prop2')).to.be.false;1012    });1013    it('prop2 dependent keys are valid', function () {1014      expect(Em.meta(this.obj).descs.prop2._dependentKeys).to.eql(['prop1', 'prop3.[]']);1015    });1016  });1017  describe('#percents', function () {1018    beforeEach(function () {1019      App.setProperties({1020        p1: 25,1021        p2: 1001022      });1023      this.obj = Em.Object.create({1024        prop1: 10,1025        prop2: 25,1026        prop3: Em.computed.percents('prop1', 'prop2'),1027        prop4: Em.computed.percents('prop1', 'prop2', 2),1028        prop5: Em.computed.percents('App.p1', 'App.p2', 1)1029      });1030    });1031    afterEach(function () {1032      delete App.p1;1033      delete App.p2;1034    });1035    it('should calculate percents', function () {1036      expect(this.obj.get('prop3')).to.equal(40);1037      expect(this.obj.get('prop4')).to.equal(40.00);1038    });1039    it('should calculate percents (2)', function () {1040      this.obj.set('prop2', 35);1041      expect(this.obj.get('prop3')).to.equal(29);1042      expect(this.obj.get('prop4')).to.equal(28.57);1043    });1044    it('should calculate percents (3)', function () {1045      this.obj.set('prop2', '35');1046      expect(this.obj.get('prop3')).to.equal(29);1047      expect(this.obj.get('prop4')).to.equal(28.57);1048    });1049    it('should calculate percents (4)', function () {1050      this.obj.set('prop1', 10.6);1051      this.obj.set('prop2', 100);1052      expect(this.obj.get('prop3')).to.equal(11);1053      expect(this.obj.get('prop4')).to.equal(10.60);1054    });1055    it('should calculate percents (5)', function () {1056      this.obj.set('prop1', '10.6');1057      this.obj.set('prop2', 100);1058      expect(this.obj.get('prop3')).to.equal(11);1059      expect(this.obj.get('prop4')).to.equal(10.60);1060    });1061    it('prop5 depends on App.* keys', function () {1062      expect(this.obj.get('prop5')).to.equal(25.0);1063      App.set('p2', 50);1064      expect(this.obj.get('prop5')).to.equal(50.0);1065      App.set('p1', 10);1066      expect(this.obj.get('prop5')).to.equal(20.0);1067    });1068    it('prop4 dependent keys are valid', function () {1069      expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['App.p1', 'App.p2']);1070    });1071  });1072  describe('#formatRole', function () {1073    beforeEach(function () {1074      this.obj = Em.Object.create({1075        prop1: 'NAMENODE',1076        prop2: false,1077        prop3: Em.computed.formatRole('prop1', 'prop2')1078      });1079      sinon.stub(App.StackServiceComponent, 'find', function () {1080        return [1081          Em.Object.create({id: 'NAMENODE', displayName: 'NameNode'}),1082          Em.Object.create({id: 'SECONDARY_NAMENODE', displayName: 'Secondary NameNode'})1083        ];1084      });1085      sinon.stub(App.StackService, 'find', function () {1086        return [1087          Em.Object.create({id: 'MAPREDUCE2', displayName: 'MapReduce2'}),1088          Em.Object.create({id: 'HIVE', displayName: 'Hive'})1089        ];1090      });1091    });1092    afterEach(function () {1093      App.StackService.find.restore();1094      App.StackServiceComponent.find.restore();1095    });1096    it('should format as role', function () {1097      expect(this.obj.get('prop3')).to.equal('NameNode');1098    });1099    it('should format as role (2)', function () {1100      this.obj.set('prop1', 'HIVE');1101      this.obj.set('prop2', true);1102      expect(this.obj.get('prop3')).to.equal('Hive');1103    });1104  });1105  describe('#sumBy', function () {1106    beforeEach(function () {1107      this.obj = Em.Object.create({1108        prop1: [1109          {a: 1}, {a: 2}, {a: 3}1110        ],1111        prop2: Em.computed.sumBy('prop1', 'a')1112      });1113    });1114    it('should calculate sum', function () {1115      expect(this.obj.get('prop2')).to.equal(6);1116    });1117    it('should calculate sum (2)', function () {1118      this.obj.get('prop1').pushObject({a: 4});1119      expect(this.obj.get('prop2')).to.equal(10);1120    });1121    it('0 for empty collection', function () {1122      this.obj.set('prop1', []);1123      expect(this.obj.get('prop2')).to.equal(0);1124    });1125  });1126  describe('#i18nFormat', function () {1127    beforeEach(function () {1128      App.setProperties({1129        someAnotherKey: 'some value'1130      });1131      sinon.stub(Em.I18n, 't', function (key) {1132        var msgs = {1133          key1: '{0} {1} {2}'1134        };1135        return msgs[key];1136      });1137      this.obj = Em.Object.create({1138        prop1: 'abc',1139        prop2: 'cba',1140        prop3: 'aaa',1141        prop4: Em.computed.i18nFormat('key1', 'prop1', 'prop2', 'prop3'),1142        prop5: Em.computed.i18nFormat('not_existing_key', 'prop1', 'prop2', 'prop3'),1143        prop6: Em.computed.i18nFormat('key1', 'App.someRandomTestingKey', 'prop2', 'prop3')1144      });1145    });1146    afterEach(function () {1147      Em.I18n.t.restore();1148    });1149    it('`prop4` check dependent keys', function () {1150      expect(Em.meta(this.obj).descs.prop4._dependentKeys).to.eql(['prop1', 'prop2', 'prop3']);1151    });1152    it('should format message', function () {1153      expect(this.obj.get('prop4')).to.equal('abc cba aaa');1154    });1155    it('should format message (2)', function () {1156      this.obj.set('prop1', 'aaa');1157      expect(this.obj.get('prop4')).to.equal('aaa cba aaa');1158    });1159    it('empty string for not existing i18-key', function () {1160      expect(this.obj.get('prop5')).to.equal('');1161    });1162    it('`prop6` depends on App.* key', function () {1163      expect(this.obj.get('prop6')).to.equal('some value cba aaa');1164      App.set('someAnotherKey', '');1165      expect(this.obj.get('prop6')).to.equal(' cba aaa');1166    });1167    it('prop6 dependent keys are valid', function () {1168      expect(Em.meta(this.obj).descs.prop6._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop2', 'prop3']);1169    });1170  });1171  describe('#concat', function () {1172    beforeEach(function () {1173      App.setProperties({1174        someAnotherKey: 'some value'1175      });1176      this.obj = Em.Object.create({1177        prop1: 'abc',1178        prop2: 'cba',1179        prop3: 'aaa',1180        prop4: Em.computed.concat(' ', 'prop1', 'prop2', 'prop3'),1181        prop5: Em.computed.concat(' ', 'App.someRandomTestingKey', 'prop2', 'prop3'),1182        prop6: Em.computed.concat(' ')1183      });1184    });1185    it('should concat dependent values', function () {1186      expect(this.obj.get('prop4')).to.equal('abc cba aaa');1187    });1188    it('should concat dependent values (2)', function () {1189      this.obj.set('prop1', 'aaa');1190      expect(this.obj.get('prop4')).to.equal('aaa cba aaa');1191    });1192    it('`prop5` depends on App.* key', function () {1193      expect(this.obj.get('prop5')).to.equal('some value cba aaa');1194      App.set('someAnotherKey', '');1195      expect(this.obj.get('prop5')).to.equal(' cba aaa');1196    });1197    it('prop5 dependent keys are valid', function () {1198      expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop2', 'prop3']);1199    });1200    it('prop6 without dependent keys', function () {1201      expect(this.obj.get('prop6')).to.equal('');1202    });1203  });1204  describe('#notExistsIn', function () {1205    beforeEach(function () {1206      this.obj = Em.Object.create({1207        prop1: 'v1',1208        prop2: Em.computed.notExistsIn('prop1', ['v1', 'v2'])1209      });1210    });1211    it('`false` if dependent value is in the array', function () {1212      expect(this.obj.get('prop2')).to.be.false;1213    });1214    it('`false` if dependent value is in the array (2)', function () {1215      this.obj.set('prop1', 'v2');1216      expect(this.obj.get('prop2')).to.be.false;1217    });1218    it('`true` if dependent value is not in the array', function () {1219      this.obj.set('prop1', 'v3');1220      expect(this.obj.get('prop2')).to.be.true;1221    });1222  });1223  describe('#notExistsInByKey', function () {1224    beforeEach(function () {1225      this.obj = Em.Object.create({1226        prop1: 'v1',1227        prop2: Em.computed.notExistsInByKey('prop1', 'prop3'),1228        prop3: ['v1', 'v2']1229      });1230    });1231    it('`false` if dependent value is in the array', function () {1232      expect(this.obj.get('prop2')).to.be.false;1233    });1234    it('`false` if dependent value is in the array (2)', function () {1235      this.obj.set('prop1', 'v2');1236      expect(this.obj.get('prop2')).to.be.false;1237    });1238    it('`true` if dependent value is not in the array', function () {1239      this.obj.set('prop1', 'v3');1240      expect(this.obj.get('prop2')).to.be.true;1241    });1242    it('`true` if dependent value is not in the array (2)', function () {1243      this.obj.set('prop1', 'v1');1244      this.obj.set('prop3', ['v2', 'v3']);1245      expect(this.obj.get('prop2')).to.be.true;1246    });1247    it('prop2 dependent keys are valid', function () {1248      expect(Em.meta(this.obj).descs.prop2._dependentKeys).to.eql(['prop1', 'prop3.[]']);1249    });1250  });1251  describe('#firstNotBlank', function () {1252    beforeEach(function () {1253      App.setProperties({1254        someAnotherKey: 'NOT-EMPTY-STRING'1255      });1256      this.obj = Em.Object.create({1257        prop1: '',1258        prop2: null,1259        prop3: '1234',1260        prop4: Em.computed.firstNotBlank('prop1', 'prop2', 'prop3'),1261        prop5: Em.computed.firstNotBlank('prop1', 'App.someRandomTestingKey', 'prop3'),1262        prop6: Em.computed.firstNotBlank('prop1', 'prop2')1263      })1264    });1265    it('`prop4` check dependent keys', function () {1266      expect(Em.meta(this.obj).descs.prop4._dependentKeys).to.eql(['prop1', 'prop2', 'prop3']);1267    });1268    it('should returns prop3', function () {1269      expect(this.obj.get('prop4')).to.equal('1234');1270    });1271    it('should returns prop2', function () {1272      this.obj.set('prop2', 'not empty string');1273      expect(this.obj.get('prop4')).to.equal('not empty string');1274    });1275    it('should returns prop1', function () {1276      this.obj.set('prop2', 'not empty string');1277      this.obj.set('prop1', 'prop1 is used');1278      expect(this.obj.get('prop4')).to.equal('prop1 is used');1279    });1280    it('`prop5` depends on App.* key', function () {1281      expect(this.obj.get('prop5')).to.equal('NOT-EMPTY-STRING');1282      App.set('someAnotherKey', '!!!!!!!');1283      expect(this.obj.get('prop5')).to.equal('!!!!!!!');1284      App.set('someAnotherKey', null);1285      expect(this.obj.get('prop5')).to.equal('1234');1286    });1287    it('prop5 dependent keys are valid', function () {1288      expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['prop1', 'App.someRandomTestingKey', 'prop3']);1289    });1290    it('prop6 depends on blank values', function () {1291      expect(this.obj.get('prop6')).to.be.null;1292    });1293  });1294  describe('#format', function () {1295    beforeEach(function () {1296      App.setProperties({1297        someAnotherKey: 'some value'1298      });1299      this.obj = Em.Object.create({1300        prop1: 'abc',1301        prop2: 'cba',1302        prop3: 'aaa',1303        prop4: Em.computed.format('{0} {1} {2}', 'prop1', 'prop2', 'prop3'),1304        prop5: Em.computed.format(null, 'prop1', 'prop2', 'prop3'),1305        prop6: Em.computed.format('{0} {1} {2}', 'App.someRandomTestingKey', 'prop2', 'prop3')1306      });1307    });1308    it('`prop4` check dependent keys', function () {1309      expect(Em.meta(this.obj).descs.prop4._dependentKeys).to.eql(['prop1', 'prop2', 'prop3']);1310    });1311    it('should format message', function () {1312      expect(this.obj.get('prop4')).to.equal('abc cba aaa');1313    });1314    it('should format message (2)', function () {1315      this.obj.set('prop1', 'aaa');1316      expect(this.obj.get('prop4')).to.equal('aaa cba aaa');1317    });1318    it('empty string for not existing i18-key', function () {1319      expect(this.obj.get('prop5')).to.equal('');1320    });1321    it('`prop6` depends on App.* key', function () {1322      expect(this.obj.get('prop6')).to.equal('some value cba aaa');1323      App.set('someAnotherKey', '');1324      expect(this.obj.get('prop6')).to.equal(' cba aaa');1325    });1326    it('prop6 dependent keys are valid', function () {1327      expect(Em.meta(this.obj).descs.prop6._dependentKeys).to.eql(['App.someRandomTestingKey', 'prop2', 'prop3']);1328    });1329  });1330  describe('#formatUnavailable', function () {1331    beforeEach(function () {1332      App.setProperties({1333        someAnotherKey: 11334      });1335      this.obj = Em.Object.create({1336        prop1: 1,1337        prop2: Em.computed.formatUnavailable('prop1'),1338        prop3: Em.computed.formatUnavailable('App.someRandomTestingKey')1339      });1340    });1341    it('`value` is 1', function () {1342      expect(this.obj.get('prop2')).to.equal(1);1343      expect(this.obj.get('prop3')).to.equal(1);1344    });1345    it('`value` is 0', function () {1346      App.set('someAnotherKey', 0);1347      this.obj.set('prop1', 0);1348      expect(this.obj.get('prop2')).to.equal(0);1349      expect(this.obj.get('prop3')).to.equal(0);1350    });1351    it('`value` is `0`', function () {1352      App.set('someAnotherKey', '0');1353      this.obj.set('prop1', '0');1354      expect(this.obj.get('prop2')).to.equal('0');1355      expect(this.obj.get('prop3')).to.equal('0');1356    });1357    it('`value` is not numeric', function () {1358      App.set('someAnotherKey', null);1359      this.obj.set('prop1', null);1360      expect(this.obj.get('prop2')).to.equal('n/a');1361      expect(this.obj.get('prop3')).to.equal('n/a');1362    });1363    it('prop3 dependent keys are valid', function () {1364      expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['App.someRandomTestingKey']);1365    });1366  });1367  describe('#countBasedMessage', function () {1368    var msg0 = 'msg0';1369    var msg1 = 'msg1';1370    var msgM = 'msgM';1371    beforeEach(function () {1372      App.setProperties({1373        someAnotherKey: 11374      });1375      this.obj = Em.Object.create({1376        prop1: 1,1377        prop2: Em.computed.countBasedMessage('prop1', msg0, msg1, msgM),1378        prop3: Em.computed.countBasedMessage('App.someRandomTestingKey', msg0, msg1, msgM)1379      });1380    });1381    it('`value` is 1', function () {1382      expect(this.obj.get('prop2')).to.equal(msg1);1383      expect(this.obj.get('prop3')).to.equal(msg1);1384    });1385    it('`value` is 0', function () {1386      App.set('someAnotherKey', 0);1387      this.obj.set('prop1', 0);1388      expect(this.obj.get('prop2')).to.equal(msg0);1389      expect(this.obj.get('prop3')).to.equal(msg0);1390    });1391    it('`value` is greater than 1', function () {1392      App.set('someAnotherKey', 3);1393      this.obj.set('prop1', 3);1394      expect(this.obj.get('prop2')).to.equal(msgM);1395      expect(this.obj.get('prop3')).to.equal(msgM);1396    });1397    it('prop3 dependent keys are valid', function () {1398      expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['App.someRandomTestingKey']);1399    });1400  });1401  describe('#getByKey', function () {1402    beforeEach(function () {1403      this.obj = Em.Object.create({1404        prop1: {a: 1, b: 2, c: 3},1405        prop2: 'a',1406        prop3: Em.computed.getByKey('prop1', 'prop2'),1407        prop4: Em.computed.getByKey('prop1', 'App.someRandomTestingKey'),1408        prop5: Em.computed.getByKey('prop1', 'prop2', 100500) // with default value1409      });1410      App.set('someAnotherKey', 'a');1411    });1412    it('prop3 dependent keys are valid', function () {1413      expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.eql(['prop1', 'prop2']);1414    });1415    it('prop4 dependent keys are valid', function () {1416      expect(Em.meta(this.obj).descs.prop4._dependentKeys).to.eql(['prop1', 'App.someRandomTestingKey']);1417    });1418    it('prop5 dependent keys are valid', function () {1419      expect(Em.meta(this.obj).descs.prop5._dependentKeys).to.eql(['prop1', 'prop2']);1420    });1421    it('prop3 value is 1', function () {1422      expect(this.obj.get('prop3')).to.be.equal(1);1423    });1424    it('prop3 value is 2', function () {1425      this.obj.set('prop2', 'b');1426      expect(this.obj.get('prop3')).to.be.equal(2);1427    });1428    it('prop3 value is 3', function () {1429      this.obj.set('prop2', 'c');1430      expect(this.obj.get('prop3')).to.be.equal(3);1431    });1432    it('prop3 value is 4', function () {1433      this.obj.set('prop1.c', 4);1434      this.obj.set('prop2', 'c');1435      expect(this.obj.get('prop3')).to.be.equal(4);1436    });1437    it('prop4 values is 1', function () {1438      expect(this.obj.get('prop4')).to.be.equal(1);1439    });1440    it('prop4 values is 2', function () {1441      App.set('someAnotherKey', 'b');1442      expect(this.obj.get('prop4')).to.be.equal(2);1443    });1444    it('prop4 values is 3', function () {1445      App.set('someAnotherKey', 'c');1446      expect(this.obj.get('prop4')).to.be.equal(3);1447    });1448    it('prop5 value is set to the default value', function () {1449      this.obj.set('prop2', 'd');1450      expect(this.obj.get('prop5')).to.be.equal(100500);1451    });1452  });1453  describe('#truncate', function () {1454    beforeEach(function () {1455      this.obj = Em.Object.create({1456        prop1: '123456789',1457        prop2: Em.computed.truncate('prop1', 8, 5),1458        prop3: Em.computed.truncate('App.someRandomTestingKey', 8, 5),1459        prop4: Em.computed.truncate('prop1', 8, 5, '###')1460      });1461      App.set('someAnotherKey', 'abcdefghi');1462    });1463    it('prop2 dependent keys are valid', function () {1464      expect(Em.meta(this.obj).descs.prop2._dependentKeys).to.be.eql(['prop1']);1465    });1466    it('prop3 dependent keys are valid', function () {1467      expect(Em.meta(this.obj).descs.prop3._dependentKeys).to.be.eql(['App.someRandomTestingKey']);1468    });1469    it('prop4 dependent keys are valid', function () {1470      expect(Em.meta(this.obj).descs.prop4._dependentKeys).to.be.eql(['prop1']);1471    });1472    it('prop2 value is 12345...', function () {1473      expect(this.obj.get('prop2')).to.be.equal('12345...');1474    });1475    it('prop2 value is 54321...', function () {1476      this.obj.set('prop1', '543216789');1477      expect(this.obj.get('prop2')).to.be.equal('54321...');1478    });1479    it('prop2 value is 1234', function () {1480      this.obj.set('prop1', '1234');1481      expect(this.obj.get('prop2')).to.be.equal('1234');1482    });1483    it('prop2 value is ""', function () {1484      this.obj.set('prop1', null);1485      expect(this.obj.get('prop2')).to.be.equal('');1486    });1487    it('prop3 value is abcde...', function () {1488      expect(this.obj.get('prop3')).to.be.equal('abcde...');1489    });1490    it('prop3 value is edcba...', function () {1491      App.set('someAnotherKey', 'edcbafghi');1492      expect(this.obj.get('prop3')).to.be.equal('edcba...');1493    });1494    it('prop3 value is abcd', function () {1495      App.set('someAnotherKey', 'abcd');1496      expect(this.obj.get('prop3')).to.be.equal('abcd');1497    });1498    it('prop4 value is 12345###', function () {1499      expect(this.obj.get('prop4')).to.be.equal('12345###');1500    });1501    it('prop4 value is 54321###', function () {1502      this.obj.set('prop1', '543216789');1503      expect(this.obj.get('prop4')).to.be.equal('54321###');1504    });1505    it('prop4 value is 12345', function () {1506      this.obj.set('prop1', '12345');1507      expect(this.obj.get('prop4')).to.be.equal('12345');1508    });1509  });...matchers.typetest.ts
Source:matchers.typetest.ts  
1import { IsUnknown } from '@internal/tsHelpers'2import { AnyAction } from 'redux'3import {4  createAction,5  createAsyncThunk,6  isAllOf,7  isAnyOf,8  isAsyncThunkAction,9  isFulfilled,10  isPending,11  isRejected,12  isRejectedWithValue,13  SerializedError14} from '../../src'15/* isAnyOf */16/*17 * Test: isAnyOf correctly narrows types when used with action creators18 */19function isAnyOfActionTest(action: AnyAction) {20  const actionA = createAction('a', () => {21    return {22      payload: {23        prop1: 1,24        prop3: 225      }26    }27  })28  const actionB = createAction('b', () => {29    return {30      payload: {31        prop1: 1,32        prop2: 233      }34    }35  })36  if (isAnyOf(actionA, actionB)(action)) {37    return {38      prop1: action.payload.prop1,39      // @ts-expect-error40      prop2: action.payload.prop2,41      // @ts-expect-error42      prop3: action.payload.prop343    }44  }45}46/*47 * Test: isAnyOf correctly narrows types when used with async thunks48 */49function isAnyOfThunkTest(action: AnyAction) {50  const asyncThunk1 = createAsyncThunk<{ prop1: number; prop3: number }>(51    'asyncThunk1',52    async () => {53      return {54        prop1: 1,55        prop3: 356      }57    }58  )59  const asyncThunk2 = createAsyncThunk<{ prop1: number; prop2: number }>(60    'asyncThunk2',61    async () => {62      return {63        prop1: 1,64        prop2: 265      }66    }67  )68  if (isAnyOf(asyncThunk1.fulfilled, asyncThunk2.fulfilled)(action)) {69    return {70      prop1: action.payload.prop1,71      // @ts-expect-error72      prop2: action.payload.prop2,73      // @ts-expect-error74      prop3: action.payload.prop375    }76  }77}78/*79 * Test: isAnyOf correctly narrows types when used with type guards80 */81function isAnyOfTypeGuardTest(action: AnyAction) {82  interface ActionA {83    type: 'a'84    payload: {85      prop1: 186      prop3: 287    }88  }89  interface ActionB {90    type: 'b'91    payload: {92      prop1: 193      prop2: 294    }95  }96  const guardA = (v: any): v is ActionA => {97    return v.type === 'a'98  }99  const guardB = (v: any): v is ActionB => {100    return v.type === 'b'101  }102  if (isAnyOf(guardA, guardB)(action)) {103    return {104      prop1: action.payload.prop1,105      // @ts-expect-error106      prop2: action.payload.prop2,107      // @ts-expect-error108      prop3: action.payload.prop3109    }110  }111}112/* isAllOf */113interface SpecialAction {114  payload: {115    special: boolean116  }117}118const isSpecialAction = (v: any): v is SpecialAction => {119  return v.meta.isSpecial120}121/*122 * Test: isAllOf correctly narrows types when used with action creators123 *       and type guards124 */125function isAllOfActionTest(action: AnyAction) {126  const actionA = createAction('a', () => {127    return {128      payload: {129        prop1: 1,130        prop3: 2131      }132    }133  })134  if (isAllOf(actionA, isSpecialAction)(action)) {135    return {136      prop1: action.payload.prop1,137      // @ts-expect-error138      prop2: action.payload.prop2,139      prop3: action.payload.prop3,140      special: action.payload.special141    }142  }143}144/*145 * Test: isAllOf correctly narrows types when used with async thunks146 *       and type guards147 */148function isAllOfThunkTest(action: AnyAction) {149  const asyncThunk1 = createAsyncThunk<{ prop1: number; prop3: number }>(150    'asyncThunk1',151    async () => {152      return {153        prop1: 1,154        prop3: 3155      }156    }157  )158  if (isAllOf(asyncThunk1.fulfilled, isSpecialAction)(action)) {159    return {160      prop1: action.payload.prop1,161      // @ts-expect-error162      prop2: action.payload.prop2,163      prop3: action.payload.prop3,164      special: action.payload.special165    }166  }167}168/*169 * Test: isAnyOf correctly narrows types when used with type guards170 */171function isAllOfTypeGuardTest(action: AnyAction) {172  interface ActionA {173    type: 'a'174    payload: {175      prop1: 1176      prop3: 2177    }178  }179  const guardA = (v: any): v is ActionA => {180    return v.type === 'a'181  }182  if (isAllOf(guardA, isSpecialAction)(action)) {183    return {184      prop1: action.payload.prop1,185      // @ts-expect-error186      prop2: action.payload.prop2,187      prop3: action.payload.prop3,188      special: action.payload.special189    }190  }191}192/*193 * Test: isPending correctly narrows types194 */195function isPendingTest(action: AnyAction) {196  if (isPending(action)) {197    expectExactType<undefined>(action.payload)198    // @ts-expect-error199    action.error200  }201  const thunk = createAsyncThunk<string>('a', () => 'result')202  if (isPending(thunk)(action)) {203    expectExactType<undefined>(action.payload)204    // @ts-expect-error205    action.error206  }207}208/*209 * Test: isRejected correctly narrows types210 */211function isRejectedTest(action: AnyAction) {212  if (isRejected(action)) {213    // might be there if rejected with payload214    expectUnknown(action.payload)215    expectExactType<SerializedError>(action.error)216  }217  const thunk = createAsyncThunk<string>('a', () => 'result')218  if (isRejected(thunk)(action)) {219    // might be there if rejected with payload220    expectUnknown(action.payload)221    expectExactType<SerializedError>(action.error)222  }223}224/*225 * Test: isFulfilled correctly narrows types226 */227function isFulfilledTest(action: AnyAction) {228  if (isFulfilled(action)) {229    expectUnknown(action.payload)230    // @ts-expect-error231    action.error232  }233  const thunk = createAsyncThunk<string>('a', () => 'result')234  if (isFulfilled(thunk)(action)) {235    expectExactType('' as string)(action.payload)236    // @ts-expect-error237    action.error238  }239}240/*241 * Test: isAsyncThunkAction correctly narrows types242 */243function isAsyncThunkActionTest(action: AnyAction) {244  if (isAsyncThunkAction(action)) {245    expectUnknown(action.payload)246    // do not expect an error property because pending/fulfilled lack it247    // @ts-expect-error248    action.error249  }250  const thunk = createAsyncThunk<string>('a', () => 'result')251  if (isAsyncThunkAction(thunk)(action)) {252    // we should expect the payload to be available, but of unknown type because the action may be pending/rejected253    expectUnknown(action.payload)254    // do not expect an error property because pending/fulfilled lack it255    // @ts-expect-error256    action.error257  }258}259/*260 * Test: isRejectedWithValue correctly narrows types261 */262function isRejectedWithValueTest(action: AnyAction) {263  if (isRejectedWithValue(action)) {264    expectUnknown(action.payload)265    expectExactType<SerializedError>(action.error)266  }267  const thunk = createAsyncThunk<268    string,269    void,270    { rejectValue: { message: string } }271  >('a', () => 'result')272  if (isRejectedWithValue(thunk)(action)) {273    expectExactType({ message: '' as string })(action.payload)274    expectExactType<SerializedError>(action.error)275  }276}...Using AI Code Generation
1import {prop3} from 'ts-auto-mock/prop3';2import {prop4} from 'ts-auto-mock/prop4';3import {prop5} from 'ts-auto-mock/prop5';4import {prop6} from 'ts-auto-mock/prop6';5import {prop7} from 'ts-auto-mock/prop7';6import {prop8} from 'ts-auto-mock/prop8';7import {prop9} from 'ts-auto-mock/prop9';8import {prop10} from 'ts-auto-mock/prop10';9import {prop11} from 'ts-auto-mock/prop11';10import {prop12} from 'ts-auto-mock/prop12';11import {prop13} from 'ts-auto-mock/prop13';12import {prop14} from 'ts-auto-mock/prop14';13import {prop15} from 'ts-auto-mock/prop15';14import {prop16} from 'ts-auto-mock/prop16';15import {prop17} from 'ts-auto-mock/prop17';16import {prop18} from 'ts-auto-mock/prop18';17import {prop19} from 'ts-auto-mock/prop19';18import {prop20} from 'ts-auto-mock/prop20';Using AI Code Generation
1import { prop3 } from 'ts-auto-mock/prop3';2import { prop3 } from 'ts-auto-mock/prop3';3import { prop3 } from 'ts-auto-mock/prop3';4import { prop3 } from 'ts-auto-mock/prop3';5import { prop3 } from 'ts-auto-mock/prop3';6import { prop3 } from 'ts-auto-mock/prop3';7import { prop3 } from 'ts-auto-mock/prop3';8import { prop3 } from 'ts-auto-mock/prop3';9import { prop3 } from 'ts-auto-mock/prop3';10import { prop3 } from 'ts-auto-mock/prop3';11import { prop3 } from 'ts-auto-mock/prop3';12import { prop3 } from 'ts-auto-mock/prop3';13import { prop3 } from 'ts-auto-mock/prop3';14import { prop3 } from 'ts-auto-mock/prop3';15import { prop3 } from 'ts-auto-mock/prop3';16import { prop3 } from 'ts-auto-mock/prop3';Using AI Code Generation
1import {prop3} from 'ts-auto-mock';2import {prop3} from 'ts-auto-mock';3describe('prop3', () => {4    it('should return the third property of the object', () => {5        const result: string = prop3({a: 'a', b: 'b', c: 'c'});6        expect(result).toBe('c');7    });8});9import {prop4} from 'ts-auto-mock';10import {prop4} from 'ts-auto-mock';11describe('prop4', () => {12    it('should return the fourth property of the object', () => {13        const result: string = prop4({a: 'a', b: 'b', c: 'c', d: 'd'});14        expect(result).toBe('d');15    });16});17import {prop5} from 'ts-auto-mock';18import {prop5} from 'ts-auto-mock';19describe('prop5', () => {20    it('should return the fifth property of the object', () => {21        const result: string = prop5({a: 'a', b: 'b', c: 'c', d: 'd', e: 'e'});22        expect(result).toBe('e');23    });24});25import {prop6} from 'ts-auto-mock';26import {prop6} from 'ts-auto-mock';27describe('prop6', () => {28    it('should return the sixth property of the object', () => {29        const result: string = prop6({30        });Using AI Code Generation
1const prop3 = require('ts-auto-mock/prop3');2const prop3 = require('ts-auto-mock/prop3');3import { prop4 } from 'ts-auto-mock/prop4';4import { prop4 } from 'ts-auto-mock/prop4';5const prop4 = require('ts-auto-mock/prop4');6const prop4 = require('ts-auto-mock/prop4');7import { prop5 } from 'ts-auto-mock/prop5';8import { prop5 } from 'ts-auto-mock/prop5';Using AI Code Generation
1import { prop3 } from 'ts-auto-mock/prop3';2const myMock = prop3<TestClass>(TestClass);3import { prop3 } from 'ts-auto-mock/prop3';4const myMock = prop3<TestClass>(TestClass);5import { prop3 } from 'ts-auto-mock/prop3';6const myMock = prop3<TestClass>(TestClass);7import { prop3 } from 'ts-auto-mock/prop3';8const myMock = prop3<TestClass>(TestClass);9import { prop3 } from 'ts-auto-mock/prop3';10const myMock = prop3<TestClass>(TestClass);11import { prop3 } from 'ts-auto-mock/prop3';12const myMock = prop3<TestClass>(TestClass);13import { prop3 } from 'ts-auto-mock/prop3';14const myMock = prop3<TestClass>(TestClass);15import { prop3 } from 'ts-auto-mock/prop3';16const myMock = prop3<TestClass>(TestClass);17import { prop3 } from 'ts-auto-mock/prop3';Using AI Code Generation
1import { prop3 } from "ts-auto-mock";2const result = prop3("test1", "prop3");3export class Test1 {4  public prop4: string;5}6import { prop4 } from "ts-auto-mock";7const result = prop4("test1", "prop4");8export class Test1 {9  public prop5: string;10}11import { prop5 } from "ts-auto-mock";12const result = prop5("test1", "prop5");13export class Test1 {14  public prop6: string;15}16import { prop6 } from "ts-auto-mock";17const result = prop6("test1", "prop6");18export class Test1 {19  public prop7: string;20}21import { prop7 } from "ts-auto-mock";22const result = prop7("test1", "prop7");23export class Test1 {24  public prop8: string;25}26import { prop8 } from "ts-auto-mock";27const result = prop8("test1", "prop8");28export class Test1 {29  public prop9: string;30}Using AI Code Generation
1import { createMock } from 'ts-auto-mock';2const mock = createMock<test1>();3console.log(mock.prop3());4import { createMock } from 'ts-auto-mock';5const mock = createMock<test2>();6console.log(mock.prop3());7import { createMock } from 'ts-auto-mock';8const mock = createMock<test3>();9console.log(mock.prop3());10import { createMock } from 'ts-auto-mock';11const mock = createMock<test4>();12console.log(mock.prop3());13import { createMock } from 'ts-auto-mock';14const mock = createMock<test5>();15console.log(mock.prop3());16import { createMock } from 'ts-auto-mock';17const mock = createMock<test6>();18console.log(mock.prop3());19import { createMock } from 'ts-auto-mock';20const mock = createMock<test7>();21console.log(mock.prop3());22import { createMock } from 'ts-auto-mock';23const mock = createMock<test8>();24console.log(mock.prop3());25import { createMock } from 'ts-auto-mock';26const mock = createMock<test9>();27console.log(mock.prop3Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
