How to use prop2 method in ts-auto-mock

Best JavaScript code snippet using ts-auto-mock

ember_computed_test.js

Source:ember_computed_test.js Github

copy

Full Screen

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 });...

Full Screen

Full Screen

sort.service.ts

Source:sort.service.ts Github

copy

Full Screen

1import { Injectable } from '@angular/core';2@Injectable()3export class SortService {4 constructor() { }5 GetSortOrderNames(prop: string) {6 return function (a, b) {7 if (a[prop].indexOf('case-') != -1 && b[prop].indexOf('case-') != -1) {8 var resa = a[prop].split("case-");9 var resb = b[prop].split("case-");10 if (parseInt(resa[1]) < parseInt(resb[1])) {11 return -1;12 } else if (parseInt(resa[1]) > parseInt(resb[1])) {13 return 1;14 }15 return 0;16 } else {17 if (a[prop].toLowerCase() > b[prop].toLowerCase()) {18 return 1;19 } else if (a[prop].toLowerCase() < b[prop].toLowerCase()) {20 return -1;21 }22 return 0;23 }24 }25 }26 GetSortOrder(prop: string) {27 return function (a, b) {28 if (a[prop] > b[prop]) {29 return 1;30 } else if (a[prop] < b[prop]) {31 return -1;32 }33 return 0;34 }35 }36 GetSortOrderNumber(prop: string) {37 return function (a, b) {38 if (parseInt(a[prop]) < parseInt(b[prop])) {39 return 1;40 } else if (parseInt(a[prop]) > parseInt(b[prop])) {41 return -1;42 }43 return 0;44 }45 }46 GetSortOrderNumberPriority(prop1: string, prop2: string, prop3: string) {47 return function (a, b) {48 if (parseInt(a[prop1]) < parseInt(b[prop1])) {49 return 1;50 } else if (parseInt(a[prop1]) > parseInt(b[prop1])) {51 return -1;52 } else {53 if (parseInt(a[prop2]) < parseInt(b[prop2])) {54 return 1;55 } else if (parseInt(a[prop2]) > parseInt(b[prop2])) {56 return -1;57 } else {58 if (parseInt(a[prop3]) < parseInt(b[prop3])) {59 return 1;60 } else if (parseInt(a[prop3]) > parseInt(b[prop3])) {61 return -1;62 }63 return 0;64 }65 }66 }67 }68 GetSortOrderNumberLength(prop: string) {69 return function (a, b) {70 if (parseInt(a[prop].length) < parseInt(b[prop].length)) {71 return 1;72 } else if (parseInt(a[prop].length) > parseInt(b[prop].length)) {73 return -1;74 }75 return 0;76 }77 }78 GetSortOrderNumberInverse(prop: string) {79 return function (a, b) {80 if (parseInt(a[prop]) > parseInt(b[prop])) {81 return 1;82 } else if (parseInt(a[prop]) < parseInt(b[prop])) {83 return -1;84 }85 return 0;86 }87 }88 GetSortOrderInverse(prop: string) {89 return function (a, b) {90 if (a[prop] < b[prop]) {91 return 1;92 } else if (a[prop] > b[prop]) {93 return -1;94 }95 return 0;96 }97 }98 DateSort(prop: string) {99 return function (a, b) {100 if (new Date(b[prop]).getTime() > new Date(a[prop]).getTime()) {101 return 1;102 } else if (new Date(b[prop]).getTime() < new Date(a[prop]).getTime()) {103 return -1;104 }105 return 0;106 }107 }108 DateSortInver(prop: string) {109 return function (a, b) {110 if (new Date(b[prop]).getTime() < new Date(a[prop]).getTime()) {111 return 1;112 } else if (new Date(b[prop]).getTime() > new Date(a[prop]).getTime()) {113 return -1;114 }115 return 0;116 }117 }118 GetSortSymptoms() {119 var prop1 = "frequencyId";120 var prop2_1 = "myCase";121 var prop2_2 = "referenceCase";122 var prop3 = "name";123 return function (a, b) {124 if ((a[prop1]) > (b[prop1])) {125 return 1;126 } else if ((a[prop1]) < (b[prop1])) {127 return -1;128 } else {129 if (a[prop2_1] && a[prop2_2]) {130 return -1;131 } else if (!a[prop2_1] || !a[prop2_2]) {132 return 1;133 } else {134 if ((a[prop3]) > (b[prop3])) {135 return 1;136 } else if ((a[prop3]) < (b[prop3])) {137 return -1;138 }139 return 0;140 }141 }142 }143 }144 GetSortSymptoms2() {145 var prop1 = "frequencyId";146 var prop2_1 = "myCase";147 var prop2_2 = "referenceCase";148 var prop3 = "name";149 return function (a, b) {150 if ((a[prop1]) == (b[prop1])) {151 if ((a[prop2_1] && a[prop2_2]) && (b[prop2_1] && b[prop2_2])) {152 if ((a[prop3]).toLowerCase() > (b[prop3]).toLowerCase()) {153 return 1;154 } else if ((a[prop3]).toLowerCase() < (b[prop3]).toLowerCase()) {155 return -1;156 } else {157 return 0;158 }159 } else {160 return 0;161 }162 } else {163 return 0;164 }165 }166 }167 GetSortTwoElements(prop1: string, prop2: string) {168 return function (a, b) {169 if (a[prop1] < b[prop1]) {170 return 1;171 } else if (a[prop1] > b[prop1]) {172 return -1;173 } else {174 if (a[prop2] < b[prop2]) {175 return 1;176 } else if (a[prop2] > b[prop2]) {177 return -1;178 } else {179 return 0;180 }181 }182 }183 }184 GetSortFilesNcrType(prop: string) {185 return function (a, b) {186 if (a.ncrResults[prop] > b.ncrResults[prop]) {187 return 1;188 } else if (a.ncrResults[prop] < b.ncrResults[prop]) {189 return -1;190 }191 return 0;192 }193 }194 GetSortFilesNcrName(prop: string, lang: string) {195 return function (a, b) {196 if (a.origenFile[prop] == 'textanaresult.json') {197 if (lang == 'es') {198 a.origenFile[prop] = 'Free Text'199 } else {200 a.origenFile[prop] = 'Texto libre'201 }202 }203 if (a.origenFile[prop] > b.origenFile[prop]) {204 return 1;205 } else if (a.origenFile[prop] < b.origenFile[prop]) {206 return -1;207 }208 return 0;209 }210 }211 GetSortOtherFiles(prop: string) {212 return function (a, b) {213 if (a.origenFile[prop] > b.origenFile[prop]) {214 return 1;215 } else if (a.origenFile[prop] < b.origenFile[prop]) {216 return -1;217 }218 return 0;219 }220 }221 DateSortFiles(prop: string) {222 return function (a, b) {223 if (new Date(b.origenFile[prop]).getTime() > new Date(a.origenFile[prop]).getTime()) {224 return 1;225 } else if (new Date(b.origenFile[prop]).getTime() < new Date(a.origenFile[prop]).getTime()) {226 return -1;227 }228 return 0;229 }230 }231 GetSortTwoElementsLand(prop1: string, prop2: string) {232 return function (a, b) {233 if (a[prop1].id < b[prop1].id) {234 return -1;235 } else if (a[prop1].id > b[prop1].id) {236 return 1;237 } else {238 if (a[prop2] < b[prop2]) {239 return -1;240 } else if (a[prop2] > b[prop2]) {241 return 1;242 } else {243 return 0;244 }245 }246 }247 }248 GetSortSymptomsLand() {249 var prop1 = "frequency";250 var prop2_1 = "hasDisease";251 var prop2_2 = "hasPatient";252 var prop3 = "name";253 return function (a, b) {254 if ((a[prop1].id) > (b[prop1].id)) {255 return 1;256 } else if ((a[prop1].id) < (b[prop1].id)) {257 return -1;258 } else {259 if (a[prop2_1] && a[prop2_2]) {260 return -1;261 } else if (!a[prop2_1] || !a[prop2_2]) {262 return 1;263 } else {264 if ((a[prop3]) > (b[prop3])) {265 return 1;266 } else if ((a[prop3]) < (b[prop3])) {267 return -1;268 }269 return 0;270 }271 }272 }273 }274 GetSortSymptoms2Land() {275 var prop1 = "frequency";276 var prop2_1 = "hasDisease";277 var prop2_2 = "hasPatient";278 var prop3 = "name";279 return function (a, b) {280 if ((a[prop1].id) == (b[prop1].id)) {281 if ((a[prop2_1] && a[prop2_2]) && (b[prop2_1] && b[prop2_2])) {282 if ((a[prop3]).toLowerCase() > (b[prop3]).toLowerCase()) {283 return 1;284 } else if ((a[prop3]).toLowerCase() < (b[prop3]).toLowerCase()) {285 return -1;286 } else {287 return 0;288 }289 } else {290 return 0;291 }292 } else {293 return 0;294 }295 }296 }...

Full Screen

Full Screen

attic.service.spec.js

Source:attic.service.spec.js Github

copy

Full Screen

1/*2 * Copyright (C) 2020 Inera AB (http://www.inera.se)3 *4 * This file is part of sklintyg (https://github.com/sklintyg).5 *6 * sklintyg is free software: you can redistribute it and/or modify7 * it under the terms of the GNU General Public License as published by8 * the Free Software Foundation, either version 3 of the License, or9 * (at your option) any later version.10 *11 * sklintyg is distributed in the hope that it will be useful,12 * but WITHOUT ANY WARRANTY; without even the implied warranty of13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14 * GNU General Public License for more details.15 *16 * You should have received a copy of the GNU General Public License17 * along with this program. If not, see <http://www.gnu.org/licenses/>.18 */19describe('common.domain.AtticService', function() {20 'use strict';21 var attic;22 beforeEach(angular.mock.module('common'));23 // Get references to the object we want to test from the context.24 beforeEach(angular.mock.inject([25 'common.domain.AtticService',26 function( _attic_) {27 attic = _attic_;28 }]));29 describe('#attic service', function() {30 beforeEach(function(){31 });32 it('can add to attic and get', function(){33 var model = {name:'testModel1',pop1:'prop1', prop2:'prop2'};34 attic.addNewAtticModel(model);35 var atticModel = attic.getAtticModel(model.name);36 expect(atticModel).not.toBe(null);37 expect(atticModel.atticModel.name).toBe(model.name);38 var model2 = {name:'testModel2',pop1:'prop1', prop2:'prop2', prop:'prop3'};39 attic.addNewAtticModel(model2);40 var atticModel2 = attic.getAtticModel(model2.name);41 expect(atticModel2).not.toBe(null);42 expect(atticModel2.atticModel.name).toBe(model2.name);43 });44 it('can update and restore from attic', function(){45 var model = {name:'testModel1',prop1:'original prop1', prop2:'original prop2', properties : ['prop1', 'prop2'] };46 attic.addNewAtticModel(model);47 var atticModel = attic.getAtticModel(model.name);48 expect(atticModel).not.toBe(null);49 expect(atticModel.atticModel.prop1).toBe('original prop1');50 // restore51 model.prop1 = 'new value';52 atticModel.restore(model, ['prop1']);53 expect(model.prop1).toBe('original prop1');54 // update55 model.prop1 = 'new value';56 atticModel.update(model, ['prop1']);57 expect(model.prop1).toBe('new value');58 // restore, should restore the last updated value59 atticModel.restore(model, ['prop1']);60 expect(model.prop1).toBe('new value');61 // restore62 model.prop1 = 'another new value';63 atticModel.restore(model, ['prop1']);64 expect(model.prop1).toBe('new value');65 expect(model.prop2).toBe('original prop2');66 });67 it('can update and restore from attic with all properties', function(){68 var model = {name:'testModel1',prop1:'original prop1', prop2:'original prop2', properties : ['prop1', 'prop2'] };69 attic.addNewAtticModel(model);70 var atticModel = attic.getAtticModel(model.name);71 expect(atticModel).not.toBe(null);72 expect(atticModel.atticModel.prop1).toBe('original prop1');73 // test without properties, this should just take all the properties74 // restore75 model.prop1 = 'prop1 new value';76 model.prop2 = 'prop2 new value';77 atticModel.restore(model);78 expect(model.prop1).toBe('original prop1');79 expect(model.prop2).toBe('original prop2');80 // update81 model.prop1 = 'new value';82 atticModel.update(model);83 expect(model.prop1).toBe('new value');84 });85 it('can update and restore from attic with all properties as function', function(){86 var model = {name:'testModel1',prop1:'original prop1', prop2:'original prop2', properties : function(){ return ['prop1', 'prop2']; } };87 attic.addNewAtticModel(model);88 var atticModel = attic.getAtticModel(model.name);89 expect(atticModel).not.toBe(null);90 expect(atticModel.atticModel.prop1).toBe('original prop1');91 // test without properties, this should just take all the properties92 // restore93 model.prop1 = 'prop1 new value';94 model.prop2 = 'prop2 new value';95 atticModel.restore(model);96 expect(model.prop1).toBe('original prop1');97 expect(model.prop2).toBe('original prop2');98 // update99 model.prop1 = 'new value';100 atticModel.update(model);101 expect(model.prop1).toBe('new value');102 });103 it('can update and restore from attic with two different models', function(){104 var model = {name:'testModel1',prop1:'original prop1', prop2:'original prop2', properties : ['prop1', 'prop2'] };105 var model2 = {name:'testModel2',prop1:'2 original prop1', prop2:'2 original prop2', properties : ['prop1', 'prop2'] };106 attic.addNewAtticModel(model);107 attic.addNewAtticModel(model2);108 var atticModel = attic.getAtticModel(model.name);109 // model2110 // restore111 model.prop1 = 'prop1 new value';112 model.prop2 = 'prop2 new value';113 atticModel.restore(model);114 expect(model.prop1).toBe('original prop1');115 expect(model.prop2).toBe('original prop2');116 // update117 model.prop1 = 'new value';118 atticModel.update(model);119 expect(model.prop1).toBe('new value');120 // model2121 // restore122 var atticModel2 = attic.getAtticModel(model2.name);123 model.prop1 = 'prop1 new value';124 model.prop2 = 'prop2 new value';125 atticModel2.restore(model);126 expect(model.prop1).toBe('2 original prop1');127 expect(model.prop2).toBe('2 original prop2');128 // update129 model.prop1 = '2 new value';130 atticModel2.update(model);131 expect(model.prop1).toBe('2 new value');132 });133 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import {prop2} from 'ts-auto-mock/prop2';2import {prop3} from 'ts-auto-mock/prop3';3import {prop4} from 'ts-auto-mock/prop4';4import {prop2} from 'ts-auto-mock/prop2';5import {prop3} from 'ts-auto-mock/prop3';6import {prop4} from 'ts-auto-mock/prop4';7import {prop2} from 'ts-auto-mock/prop2';8import {prop3} from 'ts-auto-mock/prop3';9import {prop4} from 'ts-auto-mock/prop4';

Full Screen

Using AI Code Generation

copy

Full Screen

1import {prop2} from 'ts-auto-mock';2import {prop1} from 'ts-auto-mock';3import {prop3} from 'ts-auto-mock';4import {prop4} from 'ts-auto-mock';5import {prop5} from 'ts-auto-mock';6import {prop6} from 'ts-auto-mock';7import {prop7} from 'ts-auto-mock';8import {prop8} from 'ts-auto-mock';9import {prop9} from 'ts-auto-mock';10import {prop10} from 'ts-auto-mock';11import {prop11} from 'ts-auto-mock';12import {prop12} from 'ts-auto-mock';13import {prop13} from 'ts-auto-mock';14import {prop14} from 'ts-auto-mock';15import {prop15} from 'ts-auto-mock';16import {prop16} from 'ts-auto-mock';17import {prop17} from 'ts-auto-mock';18import {prop18} from 'ts-auto-mock';19import {prop19} from 'ts-auto-mock';20import {prop20} from 'ts-auto-mock';

Full Screen

Using AI Code Generation

copy

Full Screen

1import {prop2} from 'ts-auto-mock/prop2';2import {prop3} from 'ts-auto-mock/prop3';3import {prop4} from 'ts-auto-mock/prop4';4import {prop5} from 'ts-auto-mock/prop5';5import {prop6} from 'ts-auto-mock/prop6';6import {prop7} from 'ts-auto-mock/prop7';7import {prop8} from 'ts-auto-mock/prop8';8import {prop9} from 'ts-auto-mock/prop9';9import {prop10} from 'ts-auto-mock/prop10';10import {prop11} from 'ts-auto-mock/prop11';11import {prop12} from 'ts-auto-mock/prop12';12import {prop13} from 'ts-auto-mock/prop13';13import {prop14} from 'ts-auto-mock/prop14';14import {prop15} from 'ts-auto-mock/prop15';15import {prop16} from 'ts-auto-mock/prop16';16import {prop17} from 'ts-auto-mock/prop17';17import {prop18} from 'ts-auto-mock/prop18';18import {prop19} from 'ts-auto-mock/prop19';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { prop2 } from "ts-auto-mock/prop2";2import { prop2 } from "ts-auto-mock/prop2";3import { prop2 } from "ts-auto-mock/prop2";4import { prop2 } from "ts-auto-mock/prop2";5import { prop2 } from "ts-auto-mock/prop2";6import { prop2 } from "ts-auto-mock/prop2";7import { prop2 } from "ts-auto-mock/prop2";8import { prop2 } from "ts-auto-mock/prop2";9import { prop2 } from "ts-auto-mock/prop2";10import { prop2 } from "ts-auto-mock/prop2";11import { prop2 } from "ts-auto-mock/prop2";12import { prop2 } from "ts-auto-mock/prop2";13import { prop2 } from "ts-auto-mock/prop2";14import { prop2 } from "ts-auto-mock/prop2";15import { prop2 } from "ts-auto-mock/prop2";16import { prop2 } from "ts-auto-mock/prop2";

Full Screen

Using AI Code Generation

copy

Full Screen

1const prop2 = require('ts-auto-mock/prop2');2const prop = require('ts-auto-mock/prop');3const mock = require('ts-auto-mock/mock');4const mockArray = require('ts-auto-mock/mockArray');5const mockType = require('ts-auto-mock/mockType');6const mockTypeArray = require('ts-auto-mock/mockTypeArray');7const mockFunction = require('ts-auto-mock/mockFunction');8import { prop2 } from 'ts-auto-mock/prop2';9import { prop } from 'ts-auto-mock/prop';10import { mock } from 'ts-auto-mock/mock';11import { mockArray } from 'ts-auto-mock/mockArray';12import { mockType } from 'ts-auto-mock/mockType';13import { mockTypeArray } from 'ts-auto-mock/mockTypeArray';14import { mockFunction } from 'ts-auto-mock/mockFunction';15import { mock } from 'ts-auto-mock';16interface User { name: string; age: number; }17const mockedUser: User = mock<User>();18class User { name: string; age: number; }19const mockedUser: User = mock<User>();

Full Screen

Using AI Code Generation

copy

Full Screen

1import { prop2 } from 'ts-auto-mock/prop2';2import { test2 } from './test2';3export const test1 = prop2(test2);4import { prop2 } from 'ts-auto-mock/prop2';5export const test2 = prop2({6});7import { prop2 } from 'ts-auto-mock/prop2';8export const test3 = prop2({9});10import { prop2 } from 'ts-auto-mock/prop2';11export const test4 = prop2({12});13import { prop2 } from 'ts-auto-mock/prop2';14export const test5 = prop2({15});16import { prop2 } from 'ts-auto-mock/prop2';17export const test6 = prop2({18});19import { prop2 } from 'ts-auto-mock/prop2';20export const test7 = prop2({21});22import { prop2 } from 'ts-auto-mock/prop2';23export const test8 = prop2({

Full Screen

Using AI Code Generation

copy

Full Screen

1import {prop2} from 'ts-auto-mock/prop2';2import {prop} from 'ts-auto-mock/prop';3describe('test1', () => {4 it('test1', () => {5 const obj = prop2({6 prop2: prop<string>()7 });8 console.log(obj);9 });10});11import {prop2} from 'ts-auto-mock/prop2';12import {prop} from 'ts-auto-mock/prop';13describe('test2', () => {14 it('test2', () => {15 const obj = prop2({16 prop2: prop<string>()17 });18 console.log(obj);19 });20});21import {prop2} from 'ts-auto-mock/prop2';22import {prop} from 'ts-auto-mock/prop';23describe('test3', () => {24 it('test3', () => {25 const obj = prop2({26 prop2: prop<string>()27 });28 console.log(obj);29 });30});31 at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)32 at Function.Module._load (internal/modules/cjs/loader.js:562:25)33 at Module.require (internal/modules/cjs/loader.js:692:17)34 at require (internal/modules/cjs/helpers.js:25:18)35 at Object.<anonymous> (test1.js:1:38)36 at Module._compile (internal/modules/cjs/loader.js:778:30)37 at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)38 at Module.load (internal/modules/cjs/loader.js:653:32)39 at tryModuleLoad (internal/modules/cjs/loader.js:593:12)40 at Function.Module._load (internal/modules/cjs/loader.js:585:3)41"moduleNameMapper": {

Full Screen

Using AI Code Generation

copy

Full Screen

1import { prop2 } from 'ts-auto-mock/prop2';2import { test2 } from './test2';3export const test1 = prop2(test2);4import { prop2 } from 'ts-auto-mock/prop2';5export const test2 = prop2({6});7import { prop2 } from 'ts-auto-mock/prop2';8export const test3 = prop2({9});10import { prop2 } from 'ts-auto-mock/prop2';11export const test4 = prop2({12});13import { prop2 } from 'ts-auto-mock/prop2';14export const test5 = prop2({15});16import { prop2 } from 'ts-auto-mock/prop2';17export const test6 = prop2({18});19import { prop2 } from 'ts-auto-mock/prop2';20export const test7 = prop2({21});22import { prop2 } from 'ts-auto-mock/prop2';23export const test8 = prop2({

Full Screen

Automation Testing Tutorials

Learn 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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ts-auto-mock automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful