How to use TARGET2 method in ng-mocks

Best JavaScript code snippet using ng-mocks

group-constructors.js

Source:group-constructors.js Github

copy

Full Screen

1suite('group-constructors', function() {2 function simpleGroupEffect() {3 return new SequenceEffect([4 new KeyframeEffect(document.body, [], 2000),5 new GroupEffect([6 new KeyframeEffect(document.body, [], 2000),7 new KeyframeEffect(document.body, [], 1000)8 ])9 ]);10 }11 test('associated animations for children in groups are correct', function() {12 var anim = document.timeline.play(simpleGroupEffect());13 tick(0);14 assert.equal(anim.effect._animation, anim);15 assert.equal(anim._childAnimations[0].effect._animation, anim);16 assert.equal(anim._childAnimations[1].effect._animation, anim);17 tick(2100);18 assert.equal(anim._childAnimations[1]._childAnimations[0].effect._animation, anim);19 assert.equal(anim._childAnimations[1]._childAnimations[1].effect._animation, anim);20 });21 test('firstChild and lastChild getters work', function() {22 var child1 = new KeyframeEffect(null, [], 100);23 var child2 = new GroupEffect([]);24 var seqParent = new SequenceEffect([child1, child2]);25 assert.equal(seqParent.firstChild, child1, 'first child of a SequenceEffect');26 assert.equal(seqParent.lastChild, child2, 'last child of a SequenceEffect');27 var emptySeqParent = new SequenceEffect([]);28 assert.equal(emptySeqParent.firstChild, null, 'first child of an empty SequenceEffect');29 assert.equal(emptySeqParent.lastChild, null, 'last child of an empty SequenceEffect');30 var groupParent = new GroupEffect([child1, child2]);31 assert.equal(groupParent.firstChild, child1, 'first child of a GroupEffect');32 assert.equal(groupParent.lastChild, child2, 'last child of a GroupEffect');33 var emptyGroupParent = new GroupEffect([]);34 assert.equal(emptyGroupParent.firstChild, null, 'first child of an empty GroupEffect');35 assert.equal(emptyGroupParent.lastChild, null, 'last child of an empty GroupEffect');36 });37 test('Cloning a SequenceEffect works', function() {38 var target1 = document.createElement('div');39 document.body.appendChild(target1);40 var keyframeEffect1 = new KeyframeEffect(target1, [{opacity: 1}, {opacity: 0}], {duration: 100, fill: 'none'});41 var keyframeEffect2 = keyframeEffect1.clone();42 var sequenceEffect1 = new SequenceEffect([keyframeEffect1, keyframeEffect2]);43 var sequenceEffect2 = sequenceEffect1.clone();44 var sequenceEffectParent = new SequenceEffect([sequenceEffect1, sequenceEffect2]);45 assert.equal(sequenceEffectParent.activeDuration, 400);46 var animation = document.timeline.play(sequenceEffectParent);47 tick(0);48 tick(25);49 assert.equal(getComputedStyle(target1).opacity, 0.75);50 tick(75);51 assert.equal(getComputedStyle(target1).opacity, 0.25);52 tick(125);53 assert.equal(getComputedStyle(target1).opacity, 0.75);54 tick(175);55 assert.equal(getComputedStyle(target1).opacity, 0.25);56 tick(225);57 assert.equal(getComputedStyle(target1).opacity, 0.75);58 tick(275);59 assert.equal(getComputedStyle(target1).opacity, 0.25);60 tick(325);61 assert.equal(getComputedStyle(target1).opacity, 0.75);62 tick(375);63 assert.equal(getComputedStyle(target1).opacity, 0.25);64 tick(400);65 assert.equal(getComputedStyle(target1).opacity, 1);66 animation.cancel();67 });68 test('append and prepend work', function() {69 var child1 = new KeyframeEffect(null, [], 100);70 var child2 = new GroupEffect([]);71 var seqParentAp = new SequenceEffect([child1]);72 seqParentAp.append(child2);73 assert.equal(seqParentAp.firstChild, child1, 'first child of a SequenceEffect after appending 1 child');74 assert.equal(seqParentAp.lastChild, child2, 'last child of a SequenceEffect after appending 1 child');75 var emptyGroupParentAp = new GroupEffect([]);76 emptyGroupParentAp.append(child2, child1);77 assert.equal(emptyGroupParentAp.firstChild, child2, 'first child of a GroupEffect after appending 2 children');78 assert.equal(emptyGroupParentAp.lastChild, child1, 'last child of a GroupEffect after appending 2 children');79 var groupParentPre = new GroupEffect([child1]);80 groupParentPre.prepend(child2);81 assert.equal(groupParentPre.firstChild, child2, 'first child of a GroupEffect after prepending 1 child');82 assert.equal(groupParentPre.lastChild, child1, 'last child of a GroupEffect after prepending 1 child');83 var emptySeqParentPre = new SequenceEffect([]);84 emptySeqParentPre.prepend(child2, child1);85 assert.equal(emptySeqParentPre.firstChild, child1, 'first child of a SequenceEffect after prepending 2 children');86 assert.equal(emptySeqParentPre.lastChild, child2, 'last child of a SequenceEffect after prepending 2 children');87 var group = new GroupEffect([child1, child2]);88 var seqParent = new SequenceEffect([group]);89 var ex;90 try {91 group.append(seqParent);92 } catch (e) {93 ex = e;94 }95 assert.equal(ex.name, 'HierarchyRequestError', 'Appending an ancestor throws a HierarchyRequestError');96 var groupParent = new GroupEffect([]);97 ex = undefined;98 try {99 groupParent.prepend(groupParent);100 } catch (e) {101 ex = e;102 }103 assert.equal(ex.name, 'HierarchyRequestError', 'Prepending an self throws a HierarchyRequestError');104 });105 test('Playing a child reparents it.', function() {106 var target1 = document.createElement('div');107 var target2 = document.createElement('div');108 document.body.appendChild(target1);109 document.body.appendChild(target2);110 var effect1 = new KeyframeEffect(111 target1,112 [113 {opacity: 0},114 {opacity: 1}115 ],116 {duration: 8, fill: 'both'});117 var effect2 = new KeyframeEffect(118 target2,119 [120 {opacity: 0},121 {opacity: 1}122 ],123 {duration: 8, fill: 'both'});124 var group = new GroupEffect([effect1, effect2]);125 var groupAnimation = document.timeline.play(group);126 tick(0);127 assert.equal(getComputedStyle(target1).opacity, 0);128 assert.equal(getComputedStyle(target2).opacity, 0);129 var animation = document.timeline.play(effect1);130 assert.equal(group.children.length, 1);131 assert.equal(effect1._animation, animation);132 assert.equal(effect2._animation, groupAnimation);133 assert.equal(animation.effect, effect1);134 tick(1);135 assert.equal(getComputedStyle(target1).opacity, 0);136 assert.equal(getComputedStyle(target2).opacity, 0.125);137 tick(2);138 assert.equal(getComputedStyle(target1).opacity, 0.125);139 assert.equal(getComputedStyle(target2).opacity, 0.25);140 groupAnimation.cancel();141 tick(3);142 assert.equal(getComputedStyle(target1).opacity, 0.25);143 assert.equal(getComputedStyle(target2).opacity, 1);144 animation.cancel();145 tick(4);146 assert.equal(getComputedStyle(target1).opacity, 1);147 assert.equal(getComputedStyle(target2).opacity, 1);148 });149 test('Remove KeyframeEffect from SequenceEffect parent', function() {150 var target1 = document.createElement('div');151 var target2 = document.createElement('div');152 document.body.appendChild(target1);153 document.body.appendChild(target2);154 var effect1 = new KeyframeEffect(155 target1,156 [157 {opacity: 0},158 {opacity: 1}159 ],160 {duration: 2, fill: 'both'});161 var effect2 = new KeyframeEffect(162 target2,163 [164 {opacity: 0},165 {opacity: 1}166 ],167 {duration: 2, fill: 'both'});168 var sequence = new SequenceEffect([effect1, effect2]);169 var animation = document.timeline.play(sequence);170 tick(0);171 assert.equal(getComputedStyle(target1).opacity, 0);172 assert.equal(getComputedStyle(target2).opacity, 0);173 effect1.remove();174 tick(1);175 assert.equal(getComputedStyle(target1).opacity, 1);176 assert.equal(getComputedStyle(target2).opacity, 0.5);177 assert.equal(sequence.children.length, 1);178 assert.equal(sequence._animation, animation);179 assert.equal(effect1._animation, undefined);180 assert.equal(effect2._animation, animation);181 assert.equal(animation.effect, sequence);182 animation.cancel();183 tick(2);184 animation.play();185 tick(3);186 assert.equal(getComputedStyle(target1).opacity, 1);187 assert.equal(getComputedStyle(target2).opacity, 0);188 animation.cancel();189 tick(4);190 });191 test('Remove SequenceEffect from directly associated animation', function() {192 var target1 = document.createElement('div');193 document.body.appendChild(target1);194 var effect1 = new KeyframeEffect(195 target1,196 [197 {opacity: 0},198 {opacity: 1}199 ],200 {duration: 2, fill: 'both'});201 var sequence = new SequenceEffect([effect1]);202 var animation = document.timeline.play(sequence);203 tick(0);204 assert.equal(getComputedStyle(target1).opacity, 0);205 sequence.remove();206 tick(1);207 assert.equal(getComputedStyle(target1).opacity, 1);208 assert.equal(sequence.children.length, 1);209 assert.equal(sequence._animation, undefined);210 assert.equal(effect1._animation, undefined);211 assert.notEqual(animation.effect, sequence);212 animation.play();213 tick(2);214 assert.equal(getComputedStyle(target1).opacity, 1);215 animation.cancel();216 tick(3);217 });218 test('Remove SequenceEffect from GroupEffect parent', function() {219 var target1 = document.createElement('div');220 document.body.appendChild(target1);221 var effect1 = new KeyframeEffect(222 target1,223 [224 {opacity: 0},225 {opacity: 1}226 ],227 {duration: 2, fill: 'both'});228 var sequence = new SequenceEffect([effect1]);229 var group = new GroupEffect([sequence]);230 var animation = document.timeline.play(group);231 tick(0);232 assert.equal(getComputedStyle(target1).opacity, 0);233 assert.equal(group.children.length, 1);234 assert.equal(group._animation, animation);235 assert.equal(sequence._animation, animation);236 assert.equal(animation.effect, group);237 sequence.remove();238 tick(1);239 assert.equal(getComputedStyle(target1).opacity, 1);240 assert.equal(sequence.children.length, 1);241 assert.equal(group.children.length, 0);242 assert.equal(group._animation, animation);243 assert.equal(sequence._animation, undefined);244 assert.equal(effect1._animation, undefined);245 assert.equal(animation.effect, group);246 animation.cancel();247 tick(2);248 animation.play();249 tick(3);250 assert.equal(getComputedStyle(target1).opacity, 1);251 animation.cancel();252 tick(4);253 });254 test('Calling remove on reparented effect removes it from directly associated animation', function() {255 var target1 = document.createElement('div');256 document.body.appendChild(target1);257 var effect1 = new KeyframeEffect(258 target1,259 [260 {opacity: 0},261 {opacity: 1}262 ],263 {duration: 2, fill: 'both'});264 var group = new GroupEffect([effect1]);265 var animation = document.timeline.play(effect1);266 tick(0);267 assert.equal(getComputedStyle(target1).opacity, 0);268 effect1.remove();269 tick(1);270 assert.equal(getComputedStyle(target1).opacity, 1);271 assert.equal(effect1._animation, undefined);272 assert.notEqual(animation.effect, effect1);273 animation.cancel();274 tick(2);275 });276 test('Setting delay on child KeyframeEffect timing', function() {277 var target1 = document.createElement('div');278 document.body.appendChild(target1);279 var target2 = document.createElement('div');280 document.body.appendChild(target2);281 var child1 = new KeyframeEffect(282 target1,283 [284 {opacity: 0},285 {opacity: 1}286 ],287 {duration: 100});288 var child2 = new KeyframeEffect(289 target2,290 [291 {opacity: 0},292 {opacity: 1}293 ],294 {duration: 100});295 var sequence = new SequenceEffect([child1, child2]);296 var animation = document.timeline.play(sequence);297 tick(0);298 tick(150);299 assert.closeTo(Number(getComputedStyle(target2).opacity), 0.5, 0.001, 't=150 before setting delay');300 child1.timing.delay = 20;301 assert.closeTo(Number(getComputedStyle(target2).opacity), 0.3, 0.001, 't=150 after setting delay');302 });303 test('Setting endDelay on child KeyframeEffect timing', function() {304 var target1 = document.createElement('div');305 document.body.appendChild(target1);306 var target2 = document.createElement('div');307 document.body.appendChild(target2);308 var child1 = new KeyframeEffect(309 target1,310 [311 {opacity: 0},312 {opacity: 1}313 ],314 {duration: 100});315 var child2 = new KeyframeEffect(316 target2,317 [318 {opacity: 0},319 {opacity: 1}320 ],321 {duration: 100});322 var sequence = new SequenceEffect([child1, child2]);323 var animation = document.timeline.play(sequence);324 tick(0);325 tick(150);326 assert.closeTo(Number(getComputedStyle(target2).opacity), 0.5, 0.001, 't=150 before setting endDelay');327 child1.timing.endDelay = 20;328 assert.closeTo(Number(getComputedStyle(target2).opacity), 0.3, 0.001, 't=150 after setting endDelay');329 });330 test('Setting duration on child KeyframeEffect timing', function() {331 var target1 = document.createElement('div');332 document.body.appendChild(target1);333 var target2 = document.createElement('div');334 document.body.appendChild(target2);335 var child1 = new KeyframeEffect(336 target1,337 [338 {opacity: 0},339 {opacity: 1}340 ],341 {duration: 100, fill: 'both'});342 var child2 = new KeyframeEffect(343 target2,344 [345 {opacity: 0},346 {opacity: 1}347 ],348 {duration: 100, fill: 'both'});349 var sequence = new SequenceEffect([child1, child2]);350 var animation = document.timeline.play(sequence);351 tick(0);352 tick(125);353 assert.closeTo(Number(getComputedStyle(target1).opacity), 1, 0.001, 'target1 at t=125 before setting duration');354 assert.closeTo(Number(getComputedStyle(target2).opacity), 0.25, 0.001, 'target2 at t=125 before setting duration');355 child1.timing.duration = 50;356 assert.closeTo(Number(getComputedStyle(target1).opacity), 1, 0.001, 'target1 at t=125 after setting duration');357 assert.closeTo(Number(getComputedStyle(target2).opacity), 0.75, 0.001, 'target2 at t=125 after setting duration');358 });359 test('Setting iterations on child KeyframeEffect timing', function() {360 var target1 = document.createElement('div');361 document.body.appendChild(target1);362 var target2 = document.createElement('div');363 document.body.appendChild(target2);364 var child1 = new KeyframeEffect(365 target1,366 [367 {opacity: 0},368 {opacity: 1}369 ],370 {duration: 100, fill: 'both'});371 var child2 = new KeyframeEffect(372 target2,373 [374 {opacity: 0},375 {opacity: 1}376 ],377 {duration: 100, fill: 'both'});378 var sequence = new SequenceEffect([child1, child2]);379 var animation = document.timeline.play(sequence);380 tick(0);381 tick(125);382 assert.closeTo(Number(getComputedStyle(target1).opacity), 1, 0.001, 'target1 at t=125 before setting iterations');383 assert.closeTo(Number(getComputedStyle(target2).opacity), 0.25, 0.001, 'target2 at t=125 before setting iterations');384 child1.timing.iterations = 2;385 assert.closeTo(Number(getComputedStyle(target1).opacity), 0.25, 0.001, 'target1 at t=125 after setting iterations');386 assert.closeTo(Number(getComputedStyle(target2).opacity), 0, 0.001, 'target2 at t=125 after setting iterations');387 });388 test('Setting fill on SequenceEffect timing', function() {389 var target1 = document.createElement('div');390 document.body.appendChild(target1);391 var target2 = document.createElement('div');392 document.body.appendChild(target2);393 var child1 = new KeyframeEffect(394 target1,395 [396 {opacity: 1},397 {opacity: 0}398 ],399 {duration: 100, fill: 'both'});400 var child2 = new KeyframeEffect(401 target2,402 [403 {opacity: 1},404 {opacity: 0}405 ],406 {duration: 100, fill: 'both'});407 var sequence = new SequenceEffect([child1, child2], {fill: 'none'});408 var animation = document.timeline.play(sequence);409 tick(0);410 tick(250);411 assert.equal(Number(getComputedStyle(target1).opacity), 1, 'target1 at t=250 before setting fill');412 assert.equal(Number(getComputedStyle(target2).opacity), 1, 'target2 at t=250 before setting fill');413 sequence.timing.fill = 'both';414 assert.equal(Number(getComputedStyle(target1).opacity), 0, 'target1 at t=250 after setting fill');415 assert.equal(Number(getComputedStyle(target2).opacity), 0, 'target2 at t=250 after setting fill');416 });...

Full Screen

Full Screen

namespace.spec.ts

Source:namespace.spec.ts Github

copy

Full Screen

1import { expect } from 'chai';2import 'mocha';3import { DefaultOptions, Environment, Namespace } from '../src/lib';4describe('Namespace', function() {5 let env: Environment;6 let root: Namespace;7 beforeEach(function() {8 env = new Environment(DefaultOptions());9 root = Namespace.getRoot(env);10 });11 describe('#getRoot', function() {12 it('should return a namespace with no path or arguments', function() {13 const ns = Namespace.getRoot(env);14 expect(ns.names).to.be.eql([]);15 expect(ns.args).to.be.eql([]);16 });17 });18 describe('#parent', function() {19 it('should return itself if it is the root', function() {20 expect(root.parent).to.be.equal(root);21 });22 it('should return the next namespace up', function() {23 expect(root.resolve('target1').parent.toString()).to.be.equal(root.toString());24 expect(root.resolve('target1:target2').parent.toString())25 .to.be.equal(root.resolve('target1').toString());26 expect(root.resolve('target1:target2:target3').parent.toString())27 .to.be.equal(root.resolve('target1:target2').toString());28 expect(root.resolve('target1:target2:target3:target4').parent.toString())29 .to.be.equal(root.resolve('target1:target2:target3').toString());30 });31 });32 describe('#isRoot', function() {33 it('should return true for root namespace', function() {34 expect(root.isRoot).to.be.true;35 });36 it('should return false for non-root namespace', function() {37 expect(root.resolve('target1').isRoot).to.be.false;38 expect(root.resolve('target1:target2').isRoot).to.be.false;39 expect(root.resolve('target1:target2:target3').isRoot).to.be.false;40 });41 });42 describe('#names', function() {43 it('should return an empty list for root', function() {44 expect(root.names).to.be.eql([]);45 });46 it('should return a list of names', function() {47 expect(root.resolve('target1').names).to.be.eql(['target1']);48 expect(root.resolve('target1:target2').names).to.be.eql(['target1', 'target2']);49 expect(root.resolve('target1:target2:target3').names).to.be.eql(['target1', 'target2', 'target3']);50 });51 it('should not include the arguments in any item', function() {52 expect(root.resolve('target1[a]').names).to.be.eql(['target1']);53 expect(root.resolve('target1:target2[a,b]').names).to.be.eql(['target1', 'target2']);54 expect(root.resolve('target1:target2:target3[a,b,c]').names).to.be.eql(['target1', 'target2', 'target3']);55 });56 });57 describe('#resolve', function() {58 it('should chain', function() {59 expect(root.resolve('target1').resolve('target2').toString())60 .to.be.equal(':target1:target2');61 expect(root.resolve('target1').resolve('target2').resolve('target3').toString())62 .to.be.equal(':target1:target2:target3');63 expect(root.resolve('target1').resolve('target2').resolve('target3').resolve('target4').toString())64 .to.be.equal(':target1:target2:target3:target4');65 });66 it('should resolve to itself if empty string passed in', function() {67 expect(root.resolve('').toString()).to.be.equal(':');68 expect(root.resolve('target1').resolve('').toString()).to.be.equal(':target1');69 expect(root.resolve('target1:target2').resolve('').toString()).to.be.equal(':target1:target2');70 expect(root.resolve('target1:target2:target3').resolve('').toString()).to.be.equal(':target1:target2:target3');71 });72 it('should use given working namespace', function() {73 const ns = root.resolve('ns');74 expect(root.resolve('target1', ns).toString()).to.be.equal(':ns:target1');75 expect(root.resolve('target1:target2', ns).toString()).to.be.equal(':ns:target1:target2');76 expect(root.resolve('target1:target2:target3', ns).toString()).to.be.equal(':ns:target1:target2:target3');77 });78 it('should respect absolute namespaces', function() {79 expect(root.resolve(':target1').toString()).to.be.equal(':target1');80 expect(root.resolve(':target1:target2').toString()).to.be.equal(':target1:target2');81 expect(root.resolve(':target1:target2:target3').toString()).to.be.equal(':target1:target2:target3');82 const ns = root.resolve('ns');83 expect(root.resolve(':target1', ns).toString()).to.be.equal(':target1');84 expect(root.resolve(':target1:target2', ns).toString()).to.be.equal(':target1:target2');85 expect(root.resolve(':target1:target2:target3', ns).toString()).to.be.equal(':target1:target2:target3');86 });87 it('should resolve parent directives', function() {88 expect(root.resolve('target1:^').toString()).to.be.equal(':');89 expect(root.resolve('target1:target2:^').toString()).to.be.equal(':target1');90 expect(root.resolve('target1:^:target2').toString()).to.be.equal(':target2');91 expect(root.resolve('target1:target2:^:^').toString()).to.be.equal(':');92 expect(root.resolve('target1:target2:^:^:target3').toString()).to.be.equal(':target3');93 expect(root.resolve('target1:target2:^:^:target3:^').toString()).to.be.equal(':');94 });95 it('should return the root if a parent directive resolves to above', function() {96 expect(root.resolve('^').toString()).to.be.equal(':');97 expect(root.resolve('^:^').toString()).to.be.equal(':');98 expect(root.resolve('^:^:^').toString()).to.be.equal(':');99 expect(root.resolve('target1:^:^').toString()).to.be.equal(':');100 expect(root.resolve('target1:target2:^:^:^').toString()).to.be.equal(':');101 expect(root.resolve('target1:^:target2:target3:^:^:^').toString()).to.be.equal(':');102 });103 it('should throw an error on invalid target names', function() {104 expect(() => root.resolve('target1:target \n 2')).to.throw();105 });106 });107 describe('#resolve', function() {108 it('should respect alternate namespace separators', function() {109 env.options.namespaceSeparator = '/';110 expect(root.resolve('target1').resolve('target2').toString())111 .to.be.equal('/target1/target2');112 expect(root.resolve('target1').resolve('target2').resolve('target3').toString())113 .to.be.equal('/target1/target2/target3');114 expect(root.resolve('target1').resolve('target2').resolve('target3').resolve('target4').toString())115 .to.be.equal('/target1/target2/target3/target4');116 expect(root.resolve('target1').toString()).to.be.equal('/target1');117 expect(root.resolve('target1/target2').toString()).to.be.equal('/target1/target2');118 expect(root.resolve('target1/target2/target3').toString()).to.be.equal('/target1/target2/target3');119 expect(root.resolve('target1/target2:target3').toString()).to.be.equal('/target1/target2:target3');120 env.options.namespaceSeparator = '-';121 expect(root.resolve('target1').resolve('target2').toString())122 .to.be.equal('-target1-target2');123 expect(root.resolve('target1').resolve('target2').resolve('target3').toString())124 .to.be.equal('-target1-target2-target3');125 expect(root.resolve('target1').resolve('target2').resolve('target3').resolve('target4').toString())126 .to.be.equal('-target1-target2-target3-target4');127 expect(root.resolve('target1').toString()).to.be.equal('-target1');128 expect(root.resolve('target1-target2').toString()).to.be.equal('-target1-target2');129 expect(root.resolve('target1-target2-target3').toString()).to.be.equal('-target1-target2-target3');130 expect(root.resolve('target1-target2:target3').toString()).to.be.equal('-target1-target2:target3');131 });132 it('should respect alternate parent directives', function() {133 env.options.namespaceParent = '..';134 expect(root.resolve('target1:..').toString()).to.be.equal(':');135 expect(root.resolve('target1:target2:..').toString()).to.be.equal(':target1');136 expect(root.resolve('target1:..:target2').toString()).to.be.equal(':target2');137 expect(root.resolve('target1:target2:..:..').toString()).to.be.equal(':');138 expect(root.resolve('target1:target2:..:..:target3').toString()).to.be.equal(':target3');139 expect(root.resolve('target1:target2:..:..:target3:..').toString()).to.be.equal(':');140 env.options.namespaceParent = '|';141 expect(root.resolve('target1:|').toString()).to.be.equal(':');142 expect(root.resolve('target1:target2:|').toString()).to.be.equal(':target1');143 expect(root.resolve('target1:|:target2').toString()).to.be.equal(':target2');144 expect(root.resolve('target1:target2:|:|').toString()).to.be.equal(':');145 expect(root.resolve('target1:target2:|:|:target3').toString()).to.be.equal(':target3');146 expect(root.resolve('target1:target2:|:|:target3:|').toString()).to.be.equal(':');147 });148 });149 describe('#format', function() {150 it('should leave namespaces with no tags in unchanged', function() {151 expect(root.resolve('').format(['a', 'b']).toString())152 .to.be.equal(':');153 expect(root.resolve('target1').format(['a', 'b']).toString())154 .to.be.equal(':target1');155 expect(root.resolve('target1:target2').format(['a', 'b']).toString())156 .to.be.equal(':target1:target2');157 expect(root.resolve('target1:target2:target3').format(['a', 'b']).toString())158 .to.be.equal(':target1:target2:target3');159 });160 it('should format the tags in correctly', function() {161 expect(root.resolve('target$0').format(['a', 'b']).toString())162 .to.be.equal(':targeta');163 expect(root.resolve('target$0:target$1').format(['a', 'b']).toString())164 .to.be.equal(':targeta:targetb');165 expect(root.resolve('target$1:target$3:target$2').format(['a', 'b', 'c', 'd']).toString())166 .to.be.equal(':targetb:targetd:targetc');167 expect(root.resolve('$1target$1:$2target$1:target$2').format(['a', 'b', 'c', 'd']).toString())168 .to.be.equal(':btargetb:ctargetb:targetc');169 });170 it('should leave tags unchanged if there isn\'t a matching list item', function() {171 expect(root.resolve('target$0').format([]).toString())172 .to.be.equal(':target$0');173 expect(root.resolve('target$1').format(['a']).toString())174 .to.be.equal(':target$1');175 expect(root.resolve('target$2').format(['a', 'b']).toString())176 .to.be.equal(':target$2');177 expect(root.resolve('target$5:target$2').format(['a', 'b']).toString())178 .to.be.equal(':target$5:target$2');179 expect(root.resolve('target$3:target$4:target$5').format(['a', 'b', 'c']).toString())180 .to.be.equal(':target$3:target$4:target$5');181 });182 });183 describe('#equalTo', function() {184 it('should return true for equal namespaces', function() {185 expect(root.equalTo(root)).to.be.true;186 expect(root.resolve('target1').equalTo(root.resolve('target1'))).to.be.true;187 expect(root.resolve('target1:target2').equalTo(root.resolve('target1:target2'))).to.be.true;188 expect(root.resolve('target1:target2:target3').equalTo(root.resolve('target1:target2:target3'))).to.be.true;189 });190 it('should return false for non-equal namespaces', function() {191 expect(root.resolve('target1').equalTo(root.resolve('target2'))).to.be.false;192 expect(root.resolve('target1:target3').equalTo(root.resolve('target1:target2'))).to.be.false;193 expect(root.resolve('target1:target5:target3').equalTo(root.resolve('target1:target2:target3'))).to.be.false;194 });195 });196 describe('#toString', function() {197 it('should return a full qualified namespace string', function() {198 expect(root.toString()).to.be.equal(':');199 expect(root.resolve('target1').toString()).to.be.equal(':target1');200 expect(root.resolve('target2').toString()).to.be.equal(':target2');201 expect(root.resolve('target3').toString()).to.be.equal(':target3');202 expect(root.resolve('target1:target2').toString()).to.be.equal(':target1:target2');203 expect(root.resolve('target2:target3').toString()).to.be.equal(':target2:target3');204 expect(root.resolve('target3:target4').toString()).to.be.equal(':target3:target4');205 expect(root.resolve('target1:target2:target3').toString()).to.be.equal(':target1:target2:target3');206 expect(root.resolve('target2:target3:target4').toString()).to.be.equal(':target2:target3:target4');207 expect(root.resolve('target3:target4:target5').toString()).to.be.equal(':target3:target4:target5');208 });209 it('should return a full qualified namespace string with arguments', function() {210 expect(root.resolve('target1').toString(true)).to.be.equal(':target1');211 expect(root.resolve('target2[]').toString(true)).to.be.equal(':target2[]');212 expect(root.resolve('target3[a]').toString(true)).to.be.equal(':target3[a]');213 expect(root.resolve('target1[a,b]').toString(true)).to.be.equal(':target1[a,b]');214 expect(root.resolve('target2[a,b,c]').toString(true)).to.be.equal(':target2[a,b,c]');215 expect(root.resolve('target3[a,b, c]').toString(true)).to.be.equal(':target3[a,b, c]');216 expect(root.resolve('target1:target2').toString(true)).to.be.equal(':target1:target2');217 expect(root.resolve('target2:target3[]').toString(true)).to.be.equal(':target2:target3[]');218 expect(root.resolve('target3:target4[a]').toString(true)).to.be.equal(':target3:target4[a]');219 expect(root.resolve('target1:target2[a,b]').toString(true)).to.be.equal(':target1:target2[a,b]');220 expect(root.resolve('target2:target3[a,b,c]').toString(true)).to.be.equal(':target2:target3[a,b,c]');221 expect(root.resolve('target3:target4[a,b, c]').toString(true)).to.be.equal(':target3:target4[a,b, c]');222 });223 });...

Full Screen

Full Screen

myLib.js

Source:myLib.js Github

copy

Full Screen

1function isTouching(target1, target2) {2 if (target1.x - target2.x < (target1.width + target2.width) / 2 &&3 target2.x - target1.x < (target1.width + target2.width) / 2 &&4 target1.y - target2.y < (target1.height + target2.height) / 2 &&5 target2.y - target1.y < (target1.height + target2.height) / 2) {6 return true;7 }8 else {9 return false;10 }11}12function bounce(target1, target2) {13 if (target1.x - target2.x < (target1.width + target2.width) / 2 &&14 target2.x - target1.x < (target1.width + target2.width) / 2) {15 target1.velocityX *= (-1);16 target2.velocityX *= (-1);17 }18 if (target1.y - target2.y < (target1.height + target2.height) / 2 &&19 target2.y - target1.y < (target1.height + target2.height) / 2) {20 target1.velocityY *= (-1);21 target2.velocityY *= (-1);22 }23}24function bounceOff(target1, target2) {25 if (target1.x - target2.x < (target1.width + target2.width) / 2 &&26 target2.x - target1.x < (target1.width + target2.width) / 2) {27 target1.velocityX *= (-1);28 }29 if (target1.y - target2.y < (target1.height + target2.height) / 2 &&30 target2.y - target1.y < (target1.height + target2.height) / 2) {31 target1.velocityY *= (-1);32 }33}34function collide(target1, target2) {35 if (target1.x - target2.x < (target1.width + target2.width) / 2 &&36 target2.x - target1.x < (target1.width + target2.width) / 2) {37 target1.setVelocity(0, 0);38 }39 if (target1.y - target2.y < (target1.height + target2.height) / 2 &&40 target2.y - target1.y < (target1.height + target2.height) / 2) {41 target1.setVelocity(0, 0);42 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';2import { Target2Component } from './target2.component';3describe('Target2Component', () => {4 beforeEach(() => MockBuilder(Target2Component));5 it('should create', () => {6 const fixture = MockRender(Target2Component);7 expect(ngMocks.formatText(fixture)).toEqual('Target2Component');8 });9});10import { Component, OnInit } from '@angular/core';11@Component({12})13export class Target2Component implements OnInit {14 constructor() { }15 ngOnInit() {16 }17}18import { async, ComponentFixture, TestBed } from '@angular/core/testing';19import { Target2Component } from './target2.component';20describe('Target2Component', () => {21 let component: Target2Component;22 let fixture: ComponentFixture<Target2Component>;23 beforeEach(async(() => {24 TestBed.configureTestingModule({25 })26 .compileComponents();27 }));28 beforeEach(() => {29 fixture = TestBed.createComponent(Target2Component);30 component = fixture.componentInstance;31 fixture.detectChanges();32 });33 it('should create', () => {34 expect(component).toBeTruthy();35 });36});37p {38 color: blue;39}40p {41 color: blue;42}43p {44 color: blue;45}46p {47 color: blue;48}49p {50 color: blue;51}52p {53 color: blue;54}55p {56 color: blue;

Full Screen

Using AI Code Generation

copy

Full Screen

1import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';2import { Target1Component } from './target1.component';3import { Target2Component } from './target2.component';4describe('Target2Component', () => {5 beforeEach(() => MockBuilder(Target2Component));6 it('should create', () => {7 const fixture = MockRender(Target2Component);8 const component = ngMocks.find(Target2Component);9 expect(component).toBeTruthy();10 });11});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { TARGET2 } from 'ng-mocks';2import { TARGET2 } from '@ngneat/spectator/jest';3describe('Test', () => {4 it('should be true', () => {5 const component = TARGET2(TestComponent, {6 props: {7 },8 });9 expect(component).toBeTruthy();10 });11});12import { Component, Input } from '@angular/core';13@Component({14})15export class TestComponent {16 @Input() test: string;17}18import { createComponentFactory, Spectator } from '@ngneat/spectator/jest';19import { TestComponent } from './test.component';20describe('TestComponent', () => {21 let spectator: Spectator<TestComponent>;22 const createComponent = createComponentFactory(TestComponent);23 it('should create', () => {24 spectator = createComponent();25 expect(spectator.component).toBeTruthy();26 });27});28import { createComponentFactory, Spectator } from '@ngneat/spectator/jest';29import { TestComponent } from './test.component';30describe('TestComponent', () => {31 let spectator: Spectator<TestComponent>;32 const createComponent = createComponentFactory(TestComponent);33 it('should create', () => {34 spectator = createComponent();35 expect(spectator.component).toBeTruthy();36 });37});38import { createComponentFactory, Spectator } from '@ngneat/spectator/jest';39import { TestComponent } from './test.component';40describe('TestComponent', () => {41 let spectator: Spectator<TestComponent>;42 const createComponent = createComponentFactory(TestComponent);43 it('should create', () => {44 spectator = createComponent();45 expect(spectator.component).toBeTruthy();46 });47});48import { createComponentFactory, Spectator } from '@ngneat/spectator/jest';49import { TestComponent } from './test

Full Screen

Using AI Code Generation

copy

Full Screen

1import { TARGET2 } from 'ng-mocks';2import { TARGET } from 'ng-mocks';3const myMock = TARGET2.get(MyComponent);4const myMock = TARGET.get(MyComponent);5const myMock = TARGET.get(MyComponent);6const myMock = TARGET.get(MyComponent);7const myMock = TARGET2.get(MyComponent);8const myMock = TARGET.get(MyComponent);9const myMock = TARGET.get(MyComponent);10const myMock = TARGET.get(MyComponent);11const myMock = TARGET2.get(MyComponent);12const myMock = TARGET.get(MyComponent);13const myMock = TARGET.get(MyComponent);14const myMock = TARGET.get(MyComponent);15const myMock = TARGET2.get(MyComponent);16const myMock = TARGET.get(MyComponent);17const myMock = TARGET.get(MyComponent);18const myMock = TARGET.get(MyComponent);19const myMock = TARGET2.get(MyComponent);20const myMock = TARGET.get(MyComponent);21const myMock = TARGET.get(MyComponent);22const myMock = TARGET.get(MyComponent);23const myMock = TARGET2.get(MyComponent);24const myMock = TARGET.get(MyComponent);

Full Screen

Using AI Code Generation

copy

Full Screen

1const mock = require('ng-mocks');2const { TARGET2 } = mock;3const { TestBed } = TARGET2;4const mock = require('ng-mocks');5const { TARGET2 } = mock;6const { TestBed } = TARGET2;7const mock = require('ng-mocks');8const { TARGET2 } = mock;9const { TestBed } = TARGET2;10const mock = require('ng-mocks');11const { TARGET2 } = mock;12const { TestBed } = TARGET2;13const mock = require('ng-mocks');14const { TARGET2 } = mock;15const { TestBed } = TARGET2;16const mock = require('ng-mocks');17const { TARGET2 } = mock;18const { TestBed } = TARGET2;19const mock = require('ng-mocks');20const { TARGET2 } = mock;21const { TestBed } = TARGET2;22const mock = require('ng-mocks');23const { TARGET2 } = mock;24const { TestBed } = TARGET2;25const mock = require('ng-mocks');26const { TARGET2 } = mock;27const { TestBed } = TARGET2;28const mock = require('ng-mocks');29const { TARGET2 } = mock;30const { TestBed } = TARGET2;31const mock = require('ng-mocks');32const { TARGET2 } = mock;33const { TestBed } = TARGET2;34const mock = require('ng-mocks');35const { TARGET2 } = mock;36const { TestBed } = TARGET2;

Full Screen

Using AI Code Generation

copy

Full Screen

1import { TARGET2 } from 'ng-mocks';2const target = TARGET2({3 {4 useValue: {5 mockMethod: () => {6 return 'mock';7 },8 },9 },10});11import { TARGET } from 'ng-mocks';12const target = TARGET({13 {14 useValue: {15 mockMethod: () => {16 return 'mock';17 },18 },19 },20});21import { MockBuilder } from 'ng-mocks';22MockBuilder(MyComponent, MyModule)23 .mock(MockService, {24 mockMethod: () => {25 return 'mock';26 },27 })28 .keep(MyService);29import { MockRender } from 'ng-mocks';30const fixture = MockRender(MyComponent);31import { MockInstance } from 'ng-mocks';32const mockService = MockInstance(MockService);33import { MockBuilder, MockInstance } from 'ng-mocks';34MockBuilder(MyComponent, MyModule).mock(MockService);35const mockService = MockInstance(MockService);36import { MockRender } from 'ng-mocks';37const fixture = MockRender(MyComponent);38import { MockService } from 'ng-mocks';39const mockService = MockService(MockService);40import { MockType } from 'ng-mocks';41const mockType = MockType(MyType);

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('test', () => {2 it('should test', () => {3 const fixture = MockRender(TestComponent, { target: Target2 });4 const component = fixture.point.componentInstance;5 expect(component).toBeDefined();6 });7});8describe('test', () => {9 it('should test', () => {10 const fixture = MockRender(TestComponent, { target: Target2 });11 const component = fixture.point.componentInstance;12 expect(component).toBeDefined();13 });14});15describe('test', () => {16 it('should test', () => {17 const fixture = MockRender(TestComponent, { target: Target2 });18 const component = fixture.point.componentInstance;19 expect(component).toBeDefined();20 });21});22describe('test', () => {23 it('should test', () => {24 const fixture = MockRender(TestComponent, { target: Target2 });25 const component = fixture.point.componentInstance;26 expect(component).toBeDefined();27 });28});29describe('test', () => {30 it('should test', () => {31 const fixture = MockRender(TestComponent, { target: Target2 });32 const component = fixture.point.componentInstance;33 expect(component).toBeDefined();34 });35});36describe('test', () => {37 it('should test', () => {38 const fixture = MockRender(TestComponent, { target: Target2 });39 const component = fixture.point.componentInstance;40 expect(component).toBeDefined();41 });42});43describe('test', () => {44 it('should test', () => {45 const fixture = MockRender(TestComponent, { target: Target2 });46 const component = fixture.point.componentInstance;47 expect(component).toBeDefined();48 });49});50describe('test', () => {51 it('should test', () => {52 const fixture = MockRender(TestComponent, { target: Target2

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 ng-mocks 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