How to use isNode method in Karma

Best JavaScript code snippet using karma

collection-algorithms.js

Source:collection-algorithms.js Github

copy

Full Screen

...44 });45 function ele2id(ele){46 return ele.id();47 }48 function isNode(ele){49 return ele.isNode();50 }51 function eles(){52 var col = cy.collection();53 for( var i = 0; i < arguments.length; i++ ){54 var ele = arguments[i];55 col = col.add(ele);56 }57 return col;58 }59 it('eles.bfs() undirected from `a`', function(){60 var expectedDepths = {61 a: 0,62 b: 1,63 e: 1,64 c: 2,65 d: 266 };67 var depths = {};68 var bfs = cy.elements().bfs({69 roots: a,70 visit: function(v, e, u, i, depth){71 depths[ v.id() ] = depth;72 }73 });74 expect( depths ).to.deep.equal( expectedDepths );75 expect( bfs.path.nodes().same( cy.nodes() ) ).to.be.true;76 expect( bfs.path.edges().length ).to.equal( 4 );77 for( var i = 0; i < bfs.path.length; i++ ){78 if( i % 2 === 0 ){79 expect( bfs.path[i].isNode() ).to.be.true;80 } else {81 expect( bfs.path[i].isEdge() ).to.be.true;82 }83 }84 });85 it('eles.bfs() directed from `a`', function(){86 var expectedDepths = {87 a: 0,88 b: 1,89 e: 1,90 c: 2,91 d: 392 };93 var depths = {};94 var bfs = cy.elements().bfs({95 roots: a,96 visit: function(v, e, u, i, depth){97 depths[ v.id() ] = depth;98 },99 directed: true100 });101 expect( depths ).to.deep.equal( expectedDepths );102 expect( bfs.path.nodes().same( cy.nodes() ) ).to.be.true;103 expect( bfs.path.edges().length ).to.equal( 4 );104 for( var i = 0; i < bfs.path.length; i++ ){105 if( i % 2 === 0 ){106 expect( bfs.path[i].isNode() ).to.be.true;107 } else {108 expect( bfs.path[i].isEdge() ).to.be.true;109 }110 }111 });112 it('eles.dfs() undirected from `a`', function(){113 var dfs = cy.elements().dfs({114 roots: a115 });116 expect( dfs.path.nodes().same( cy.nodes() ) ).to.be.true;117 expect( dfs.path.edges().length ).to.equal( 4 );118 for( var i = 0; i < dfs.path.length; i++ ){119 if( i % 2 === 0 ){120 expect( dfs.path[i].isNode() ).to.be.true;121 } else {122 expect( dfs.path[i].isEdge() ).to.be.true;123 }124 }125 });126 it('eles.dfs() directed from `a`', function(){127 var dfs = cy.elements().dfs({ roots: a, directed: true });128 expect( dfs.path.nodes().same( cy.nodes() ) ).to.be.true;129 expect( dfs.path.edges().length ).to.equal( 4 );130 for( var i = 0; i < dfs.path.length; i++ ){131 if( i % 2 === 0 ){132 expect( dfs.path[i].isNode() ).to.be.true;133 } else {134 expect( dfs.path[i].isEdge() ).to.be.true;135 }136 }137 });138 it('eles.dijkstra() undirected', function(){139 var di = cy.elements().dijkstra({140 root: a,141 weight: function( ele ){142 return ele.data('weight');143 }144 });145 expect( di.distanceTo(b) ).to.equal(3);146 expect( di.pathTo(b).same( eles(a, ab, b) ) ).to.be.true;147 expect( di.distanceTo(e) ).to.equal(1);148 expect( di.pathTo(e).same( eles(a, ae, e) ) ).to.be.true;149 expect( di.distanceTo(c) ).to.equal(7);150 expect( di.pathTo(c).same( eles(a, ae, e, ce, c) ) ).to.be.true;151 expect( di.distanceTo(d) ).to.equal(8);152 expect( di.pathTo(d).same( eles(a, ae, e, de, d) ) ).to.be.true;153 var adPath = di.pathTo(d);154 for( var i = 0; i < adPath.length; i++ ){155 if( i % 2 === 0 ){156 expect( adPath[i].isNode() ).to.be.true;157 } else {158 expect( adPath[i].isEdge() ).to.be.true;159 }160 }161 });162 it('eles.dijkstra() disconnected infinity', function(){163 var cy = cytoscape({164 elements: [165 {166 group: 'nodes',167 data: { id: 'a' }168 },169 {170 group: 'nodes',171 data: { id: 'b' }172 }173 ],174 headless: true175 });176 var di = cy.elements().dijkstra({177 root: '#a',178 weight: function( ele ){179 return ele.data('weight');180 }181 });182 expect( di.distanceTo('#b') ).to.equal(Infinity);183 });184 it('eles.dijkstra() directed', function(){185 var di = cy.elements().dijkstra({186 root: a,187 weight: function( ele ){188 return ele.data('weight');189 },190 directed: true191 });192 expect( di.distanceTo(b) ).to.equal(3);193 expect( di.pathTo(b).same( eles(a, ab, b) ) ).to.be.true;194 expect( di.distanceTo(e) ).to.equal(1);195 expect( di.pathTo(e).same( eles(a, ae, e) ) ).to.be.true;196 expect( di.distanceTo(c) ).to.equal(8);197 expect( di.pathTo(c).same( eles(a, ab, b, bc, c) ) ).to.be.true;198 expect( di.distanceTo(d) ).to.equal(10);199 expect( di.pathTo(d).same( eles(a, ab, b, bc, c, cd, d) ) ).to.be.true;200 var adPath = di.pathTo(d);201 for( var i = 0; i < adPath.length; i++ ){202 if( i % 2 === 0 ){203 expect( adPath[i].isNode() ).to.be.true;204 } else {205 expect( adPath[i].isEdge() ).to.be.true;206 }207 }208 });209 it('eles.kruskal()', function(){210 var kruskal = cy.elements().kruskal( function( ele ){211 return ele.data('weight');212 } );213 expect( kruskal.same( eles(a, b, c, d, e, ae, cd, ab, bc) ) );214 });215 it('eles.aStar(): undirected, null heuristic, unweighted', function(){216 var options = {root: a,217 goal: b,...

Full Screen

Full Screen

viz-isnode.js

Source:viz-isnode.js Github

copy

Full Screen

1/*2* JBoss, Home of Professional Open Source3* Copyright 2011 Red Hat Inc. and/or its affiliates and other4* contributors as indicated by the @author tags. All rights reserved.5* See the copyright.txt in the distribution for a full listing of6* individual contributors.7*8* This is free software; you can redistribute it and/or modify it9* under the terms of the GNU Lesser General Public License as10* published by the Free Software Foundation; either version 2.1 of11* the License, or (at your option) any later version.12*13* This software is distributed in the hope that it will be useful,14* but WITHOUT ANY WARRANTY; without even the implied warranty of15* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU16* Lesser General Public License for more details.17*18* You should have received a copy of the GNU Lesser General Public19* License along with this software; if not, write to the Free20* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA21* 02110-1301 USA, or see the FSF site: http://www.fsf.org.22* 23* @author Andrew Sacamano<andrew.sacamano@amentra.com>24* @author <a href="mailto:rtsang@redhat.com">Ray Tsang</a>25*/26/* Utility function */27function round2(x) {28 return Math.round(x * 100) / 100;29}30/*31 * What size dots to use in each range32 */33ISNode.prototype.rangeDotSize = new Array();34ISNode.prototype.rangeDotSize[0] = 3;35ISNode.prototype.rangeDotSize[1] = 7;36ISNode.prototype.rangeDotSize[2] = 12;37/*38 * What orbit for each range39 */40ISNode.prototype.rangeOrbit = new Array();41ISNode.prototype.rangeOrbit[0] = 27;42ISNode.prototype.rangeOrbit[1] = 40;43ISNode.prototype.rangeOrbit[2] = 60;44ISNode.prototype.coreRadius = 20;45/**46 * Build the HTML for a node47 */48ISNode.prototype.buildNodeHTML = function(nodeInfo) {49 return "\n"50 + '<div id="' + nodeInfo.id + '" class="node" '51 /*52 + 'onmouseover="$(\'#title-' + nodeInfo.id + '\').show();" '53 + 'onmouseout="$(\'#title-' + nodeInfo.id + '\').hide();"'54 */55 + '>'56 + '<canvas class="nodecanvas" width="150" height="150"/>'57 + '<div class="nodetitle" id="title-' + nodeInfo.id + '">' + nodeInfo.name + ' [<span class="count">0</span>]</div>'58 + '</div>';59}60/**61 * A node object, representing a node in Infinispan62 */63function ISNode(idIn,colorIn,hilightColorIn,phaseIn) {64 // Record the ID65 this.id = idIn;66 // Its location relative to it's 'ideal' position67 this.x = 0;68 this.y = 0;69 // Its velocity70 this.dx = 0;71 this.dy = 0;72 // Its phase - used to calculate its 'ideal' position73 this.phase = phaseIn;74 // The color75 this.color = colorIn;76 this.hilightColor = hilightColorIn;77 // The count78 this.count = 0;79 80 // The core81 this.core = new Dot(75 - this.coreRadius,75 - this.coreRadius,this.coreRadius,this.color,this.hilightColor,null);82 // The dots to draw83 this.dots = Array();84 // Now set it up to the dom elements85 this.attach();86}87// Attach the node to the elements88ISNode.prototype.attach = function() {89 // The jquery array representing this node90 this.jq = $('#' + this.id);91 // The dom object for this node92 this.dom = this.jq.get()[0];93 // The canvas object contained in this node94 this.canvas = $('#' + this.id + ' canvas').get()[0];95 this.core.attach(this.canvas.getContext('2d'));96 this.core.draw();97 for (var i = 0; i < this.dots.length; i++) {98 this.dots[i].attach(this.canvas.getContext('2d'));99 this.dots[i].draw();100 }101// this.jq.click(function() {102// deleteNode(this.id);103// });104}105// Basic geometry used to position the node106ISNode.prototype.stageCenterWidth = 0;107ISNode.prototype.stageCenterHeight = 0;108ISNode.prototype.orbit = 0;109// Basics of the wobble and wiggle110ISNode.prototype.attractiveForce = 0;111ISNode.prototype.drag = 0;112/**113 * Initialize and show a node114 */115ISNode.prototype.init = function(phaseShift) {116 this.setPosition(phaseShift)117 this.jq.show();118}119/**120 * Kicks a node with a random motion121 */122ISNode.prototype.perturb = function(perturbation) {123 this.dx = (Math.random() * 2 * perturbation) - perturbation;124 this.dy = (Math.random() * 2 * perturbation) - perturbation;125}126ISNode.prototype.desiredPosition = function(phase) {127 var x = 0;128 var y = 0;129 var p = 0;130 p = phase;131 x = this.orbit * Math.sin(p) + this.stageCenterWidth;132 y = this.orbit * -Math.cos(p) + this.stageCenterHeight;133 // $('#title-' + this.id).html(this.name + ' : ' + (Math.round(phase * 100) / 100));134 var result = new Object();135 result.x = x;136 result.y = y;137 return result;138}139/**140 * set it's position given a particular phaseShift141 */142ISNode.prototype.setPosition = function(phaseShift) {143 var desired = this.desiredPosition(this.phase + phaseShift);144 this.dom.style.left = Math.round(desired.x + this.x) + "px";145 this.dom.style.top = Math.round(desired.y + this.y) + "px";146}147/**148 * Called start moveing a node to a new phase149 */150ISNode.prototype.setPhase = function(newPhase, runRadians) {151 // $('#title-' + this.id).html(round2(this.phase) + ' -> ' + round2(newPhase));152 var oldDesired = this.desiredPosition(this.phase + runRadians);153 var newDesired = this.desiredPosition(newPhase + runRadians);154 this.x += oldDesired.x - newDesired.x;155 this.y += oldDesired.y - newDesired.y;156 this.phase = newPhase;157}158/**159 * set it's position given a particular phaseShift160 */161ISNode.prototype.animate = function(phaseShift,timeFactor) {162 // What forces are operating on it163 var deltaVX = ((this.attractiveForce * this.x) + (this.drag * this.dx)) * timeFactor;164 var deltaVY = ((this.attractiveForce * this.y) + (this.drag * this.dy)) * timeFactor;165 this.dx += deltaVX;166 this.dy += deltaVY;167 // TODO - Clamp if deltaV gets to be too big?168 this.x += this.dx * timeFactor;169 this.y += this.dy * timeFactor;170 this.setPosition(phaseShift);171}172ISNode.prototype.debug = function() {173 this.jq.html(Math.round(desiredX + this.x) + "," + Math.round(desiredY + this.y) + '</br>'174 + Math.round(desiredX) + "," + Math.round(desiredY) + '</br>'175 + Math.round(this.x) + "," + Math.round(this.y) + '</br>'176 + (Math.round(this.phase * 100) / 100) + ' : ' + (Math.round(phaseShift * 100) / 100)177 );178}179ISNode.prototype.addDot = function(x,y,r) {180 var dot = new Dot(x,y,r,this.color,this.hilightColor,this.canvas.getContext('2d'));181 this.dots.push(dot);182 dot.draw();183}184ISNode.prototype.setCount = function(countIn) {185 if (countIn == this.count) {186 return;187 }188 this.count = countIn;189 var dotsInRange = new Array();190 // OK, 0 - 10, you get one little dot each191 // 11-100 - you get one big dot for every 10192 // 101 - 1000 - you one igger dot got every 100193 if (this.count == 0) {194 // do nothing195 } else if (this.count <= 10) {196 dotsInRange.push(this.count);197 } else if (this.count <= 100) {198 dotsInRange.push(10);199 dotsInRange.push(Math.floor(this.count / 10));200 } else if (this.count <= 1000) {201 dotsInRange.push(10);202 dotsInRange.push(10);203 dotsInRange.push(Math.floor(this.count / 100));204 } else {205 dotsInRange.push(10);206 dotsInRange.push(10);207 dotsInRange.push(Math.floor(this.count / 100));208 }209 this.erase();210 this.core.draw();211 this.dots = new Array();212 var range;213 for (range = 0; range < 3; range++) {214 if (range >= dotsInRange.length) {215 break;216 }217 var i;218 for (i = 0; i < dotsInRange[range]; i++) {219 var r = this.rangeDotSize[range];220 var phase = (Math.PI * 2 * ((i / 10) + (range / 20)));221 var x = 75 - r + (Math.sin(phase) * this.rangeOrbit[range]);222 var y = 75 - r + (Math.cos(phase) * this.rangeOrbit[range]);223 var dot = new Dot(x,y,r,this.color,this.hilightColor,this.canvas.getContext('2d'));224 this.dots.push(dot);225 dot.draw();226 }227 }228 229 var countSpan = this.jq.find("#title-" + this.id + " span.count");230 countSpan.html(countIn);231}232ISNode.prototype.erase = function() {233 this.canvas.getContext('2d').clearRect(0,0,150,150);...

Full Screen

Full Screen

simple-checker.js

Source:simple-checker.js Github

copy

Full Screen

...153 (x && x.isIndexNode === true && x.constructor.prototype.isNode === true) ||154 false155 );156}157export function isNode(x) {158 return (159 (x && x.isNode === true && x.constructor.prototype.isNode === true) || false160 );161}162export function isObjectNode(x) {163 return (164 (x && x.isObjectNode === true && x.constructor.prototype.isNode === true) ||165 false166 );167}168export function isOperatorNode(x) {169 return (170 (x &&171 x.isOperatorNode === true &&172 x.constructor.prototype.isNode === true) ||173 false174 );175}176export function isParenthesisNode(x) {177 return (178 (x &&179 x.isParenthesisNode === true &&180 x.constructor.prototype.isNode === true) ||181 false182 );183}184export function isRangeNode(x) {185 return (186 (x && x.isRangeNode === true && x.constructor.prototype.isNode === true) ||187 false188 );189}190export function isSymbolNode(x) {191 return (192 (x && x.isSymbolNode === true && x.constructor.prototype.isNode === true) ||193 false194 );195}196export function isChain(x) {197 return (x && x.constructor.prototype.isChain === true) || false;198}199export function typeOf(x) {200 const t = typeof x;201 if (t === "object") {202 // JavaScript types203 if (x === null) return "null";204 if (Array.isArray(x)) return "Array";205 if (x instanceof Date) return "Date";206 if (x instanceof RegExp) return "RegExp";207 // math.js types208 if (isBigNumber(x)) return "BigNumber";209 if (isComplex(x)) return "Complex";210 if (isFraction(x)) return "Fraction";211 if (isMatrix(x)) return "Matrix";212 if (isUnit(x)) return "Unit";213 if (isIndex(x)) return "Index";214 if (isRange(x)) return "Range";215 if (isResultSet(x)) return "ResultSet";216 if (isNode(x)) return x.type;217 if (isChain(x)) return "Chain";218 if (isHelp(x)) return "Help";219 return "Object";220 }221 if (t === "function") return "Function";222 return t; // can be 'string', 'number', 'boolean', ......

Full Screen

Full Screen

isnode.test.js

Source:isnode.test.js Github

copy

Full Screen

1import { isNode } from "../dist/ch";2test("sends null to isNode", () => {3 expect(isNode(null)).toBe(false);4});5test("sends undefined to isNode", () => {6 expect(isNode(undefined)).toBe(false);7});8const s1 = Symbol();9test("sends symbol to isNode", () => {10 expect(isNode(s1)).toBe(false);11});12test("sends true to isNode", () => {13 expect(isNode(true)).toBe(false);14});15test("sends false to isNode", () => {16 expect(isNode(false)).toBe(false);17});18test("sends string to isNode", () => {19 expect(isNode("string")).toBe(false);20});21test("sends positive even integer to isNode", () => {22 expect(isNode(2)).toBe(false);23});24test("sends positive odd integer to isNode", () => {25 expect(isNode(1)).toBe(false);26});27test("sends zero to isNode", () => {28 expect(isNode(0)).toBe(false);29});30test("sends positive float to isNode", () => {31 expect(isNode(1.1)).toBe(false);32});33test("sends negative odd integer to isNode", () => {34 expect(isNode(-1)).toBe(false);35});36test("sends negative even integer to isNode", () => {37 expect(isNode(-2)).toBe(false);38});39test("sends negative float to isNode", () => {40 expect(isNode(-1.1)).toBe(false);41});42test("sends object to isNode", () => {43 expect(isNode({})).toBe(false);44});45test("sends empty array to isNode", () => {46 expect(isNode([])).toBe(false);47});48test("sends array to isNode", () => {49 expect(isNode(["white", "grey", "black"])).toBe(false);50});51var json = `{52 "actor": {53 "name": "Tom Cruise",54 "age": 56,55 "Born At": "Syracuse, NY",56 "Birthdate": "July 3 1962",57 "photo": "https://jsonformatter.org/img/tom-cruise.jpg"58 }59}`;60test("sends json to isNode", () => {61 expect(isNode(json)).toBe(false);62});63var invalidjson = `{64 "actor: {65 "name": "Tom Cruise",66 "age": 5667 "Born At": "Syracuse, NY",68 "Birthdate": "July 3 1962",69 "photo": "https://jsonformatter.org/img/tom-cruise.jpg"70 }71}`;72test("sends invalid json to isNode", () => {73 expect(isNode(invalidjson)).toBe(false);74});75function testFunction() {76 console.log("function");77}78test("sends function to isNode", () => {79 expect(isNode(testFunction)).toBe(false);80});81var para = document.createElement("p");82test("sends htmlElement to isNode", () => {83 expect(isNode(para)).toBe(true);84});85var node = document.createTextNode("new node");86test("sends node to isNode", () => {87 expect(isNode(node)).toBe(true);88});89test("sends regex to isNode", () => {90 expect(isNode(/ab+c/i)).toBe(false);...

Full Screen

Full Screen

isNode-test.js

Source:isNode-test.js Github

copy

Full Screen

...9var isNode = require('isNode');10describe('isNode', () => {11 it('should reject undefined', () => {12 var UNDEFINED;13 expect(isNode()).toBe(false);14 expect(isNode(UNDEFINED)).toBe(false);15 });16 it('should reject null', () => {17 expect(isNode(null)).toBe(false);18 });19 it('should reject primitives', () => {20 expect(isNode(false)).toBe(false);21 expect(isNode(true)).toBe(false);22 expect(isNode(0)).toBe(false);23 expect(isNode(1)).toBe(false);24 });25 it('should reject strings', () => {26 expect(isNode('')).toBe(false);27 expect(isNode('a real string')).toBe(false);28 });29 it('should reject sneaky objects', () => {30 expect(isNode({tagName: 'input'})).toBe(false);31 expect(isNode({nodeName: 'input'})).toBe(false);32 });33 it('should reject the window object', () => {34 expect(isNode(window)).toBe(false);35 });36 it('should accept document fragments', () => {37 expect(isNode(document.createDocumentFragment())).toBe(true);38 });39 it('should accept elements from DOM', () => {40 expect(isNode(document.body)).toBe(true);41 expect(isNode(document.documentElement)).toBe(true);42 });43 it('should accept dynamically created elements', () => {44 expect(isNode(document.createElement('div'))).toBe(true);45 expect(isNode(document.createElement('input'))).toBe(true);46 expect(isNode(document.createElement('a'))).toBe(true);47 });48 it('should accept all types of nodes', () => {49 var body = document.body;50 var div = document.createElement('div');51 var input = document.createElement('input');52 var textnode = document.createTextNode('yet more text');53 expect(isNode(body)).toBe(true);54 expect(isNode(div)).toBe(true);55 expect(isNode(input)).toBe(true);56 expect(isNode(textnode)).toBe(true);57 expect(isNode(document)).toBe(true);58 });59 it('should run isNode', () => {60 expect(isNode(document.createElement('div'))).toBe(true);61 expect(isNode(document.createTextNode('text'))).toBe(true);62 expect(isNode(null)).toBe(false);63 expect(isNode(window)).toBe(false);64 expect(isNode({})).toBe(false);65 });66 it('should detect DOM nodes', function() {67 expect(isNode(document.createElement('object'))).toBe(true);68 expect(isNode({})).toBe(false);69 });...

Full Screen

Full Screen

runtime.js

Source:runtime.js Github

copy

Full Screen

...27 isRhino = runtime.isRhino();28 it("should return a boolean", function() {29 expect(typeof isRhino).toEqual('boolean');30 });31 it("should return the opposite value from isNode()", function() {32 if (isNode === undefined) {33 isNode = runtime.isNode();34 }35 expect(!isRhino).toBe(isNode);36 });37 });38 describe("isNode", function() {39 isNode = runtime.isNode();40 it("should return a boolean", function() {41 expect(typeof isNode).toEqual('boolean');42 });43 it("should return the opposite value from isRhino()", function() {44 if (isRhino === undefined) {45 isRhino = runtime.isRhino();46 }47 expect(!isNode).toBe(isRhino);48 });49 });...

Full Screen

Full Screen

is-node.js

Source:is-node.js Github

copy

Full Screen

2 'use strict';3 it('nodes', function() {4 var node;5 node = document;6 assert.isTrue(axe.commons.dom.isNode(node), 'Document');7 node = document.body;8 assert.isTrue(axe.commons.dom.isNode(node), 'Body');9 node = document.documentElement;10 assert.isTrue(axe.commons.dom.isNode(node), 'Document Element');11 node = document.createTextNode('cats');12 assert.isTrue(axe.commons.dom.isNode(node), 'Text Nodes');13 node = document.createElement('div');14 assert.isTrue(axe.commons.dom.isNode(node), 'Elements');15 node = document.createComment('div');16 assert.isTrue(axe.commons.dom.isNode(node), 'Comment nodes');17 node = document.createDocumentFragment();18 assert.isTrue(axe.commons.dom.isNode(node), 'Document fragments');19 });20 it('non-nodes', function() {21 var node;22 node = {};23 assert.isFalse(axe.commons.dom.isNode(node));24 node = null;25 assert.isFalse(axe.commons.dom.isNode(node));26 node = window;27 assert.isFalse(axe.commons.dom.isNode(node));28 node = [];29 assert.isFalse(axe.commons.dom.isNode(node));30 node = 'cats';31 assert.isFalse(axe.commons.dom.isNode(node));32 node = undefined;33 assert.isFalse(axe.commons.dom.isNode(node));34 node = false;35 assert.isFalse(axe.commons.dom.isNode(node));36 });...

Full Screen

Full Screen

isdomnode.js

Source:isdomnode.js Github

copy

Full Screen

...3 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license4 */5/* global document, window */6import isNode from '../../src/dom/isnode';7describe( 'isNode()', () => {8 it( 'detects native DOM nodes', () => {9 expect( isNode( document ) ).to.be.true;10 expect( isNode( document.createElement( 'div' ) ) ).to.be.true;11 expect( isNode( document.createTextNode( 'Foo' ) ) ).to.be.true;12 expect( isNode( {} ) ).to.be.false;13 expect( isNode( null ) ).to.be.false;14 expect( isNode( undefined ) ).to.be.false;15 expect( isNode( new Date() ) ).to.be.false;16 expect( isNode( 42 ) ).to.be.false;17 expect( isNode( window ) ).to.be.false;18 } );19 it( 'works for nodes in an iframe', done => {20 const iframe = document.createElement( 'iframe' );21 iframe.addEventListener( 'load', () => {22 const iframeDocument = iframe.contentWindow.document;23 expect( isNode( iframeDocument ) ).to.be.true;24 expect( isNode( iframeDocument.createElement( 'div' ) ) ).to.be.true;25 expect( isNode( iframeDocument.createTextNode( 'Foo' ) ) ).to.be.true;26 expect( isNode( iframe.contentWindow ) ).to.be.false;27 iframe.remove();28 done();29 } );30 document.body.appendChild( iframe );31 } );...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1if (window.__karma__.isNode) {2 require('angular');3 require('angular-mocks');4}5if (window.__karma__.isNode) {6 require('angular');7 require('angular-mocks');8}9if (window.__karma__.isNode) {10 require('angular');11 require('angular-mocks');12}13if (window.__karma__.isNode) {14 require('angular');15 require('angular-mocks');16}17if (window.__karma__.isNode) {18 require('angular');19 require('angular-mocks');20}21if (window.__karma__.isNode) {22 require('angular');23 require('angular-mocks');24}25if (window.__karma__.isNode) {26 require('angular');27 require('angular-mocks');28}29if (window.__karma__.isNode) {30 require('angular');31 require('angular-mocks');32}33if (window.__karma__.isNode) {34 require('angular');35 require('angular-mocks');36}37if (window.__karma__.isNode) {38 require('angular');39 require('angular-mocks');40}41if (window.__karma__.isNode) {42 require('angular');43 require('angular-mocks');44}45if (window.__karma__.isNode) {46 require('angular');47 require('angular-mocks');48}49if (window.__karma__.isNode) {50 require('angular');51 require('angular-mocks');52}

Full Screen

Using AI Code Generation

copy

Full Screen

1var isNode = typeof process === 'object' && process + '' === '[object process]';2if (isNode) {3} else {4}5var isBrowser = typeof window === 'object' && window + '' === '[object Window]';6if (isBrowser) {7} else {8}9var isCommonJS = typeof module === 'object' && module + '' === '[object Module]';10if (isCommonJS) {11} else {12}13var isAMD = typeof define === 'function' && define + '' === '[object Function]';14if (isAMD) {15} else {16}17var isPhantomJS = typeof window === 'object' && window + '' === '[object Window]' && navigator.userAgent.indexOf('PhantomJS') > -1;18if (isPhantomJS) {19} else {20}21var isIE = typeof window === 'object' && window + '' === '[object Window]' && navigator.userAgent.indexOf('MSIE') > -1;22if (isIE) {23} else {24}25var isChrome = typeof window === 'object' && window + '' === '[object Window]' && navigator.userAgent.indexOf('Chrome') > -1;26if (isChrome) {27} else {28}29var isFirefox = typeof window === 'object' && window + '' === '[object Window]' && navigator.userAgent.indexOf('Firefox') > -1;

Full Screen

Using AI Code Generation

copy

Full Screen

1if (!isNode) {2 describe('my tests', function () {3 it('should work', function () {4 expect(true).toBe(true);5 });6 });7}8if (isNode) {9 describe('my tests', function () {10 it('should work', function () {11 expect(true).toBe(true);12 });13 });14}15if (isNode) {16 describe('my tests', function () {17 it('should work', function () {18 expect(true).toBe(true);19 });20 });21}22if (isNode) {23 describe('my tests', function () {24 it('should work', function () {25 expect(true).toBe(true);26 });27 });28}29if (isNode) {30 describe('my tests', function () {31 it('should work', function () {32 expect(true).toBe(true);33 });34 });35}36if (isNode) {37 describe('my tests', function () {38 it('should work', function () {39 expect(true).toBe(true);40 });41 });42}43if (isNode) {44 describe('my tests', function () {45 it('should work', function () {46 expect(true).toBe(true);47 });48 });49}50if (isNode) {51 describe('my tests', function () {52 it('should work', function () {53 expect(true).toBe(true);54 });55 });56}57if (isNode) {58 describe('my tests', function () {59 it('should work', function () {60 expect(true).toBe(true);61 });62 });63}64if (isNode) {65 describe('my tests', function () {66 it('should work', function () {67 expect(true).toBe(true);

Full Screen

Using AI Code Generation

copy

Full Screen

1var isNode = (typeof window === 'undefined');2if (isNode) {3 var jsdom = require("jsdom");4 var doc = jsdom.jsdom("<html><head></head><body></body></html>");5 var win = doc.defaultView;6 global.document = doc;7 global.window = win;8 for (var key in window) {9 if (!window.hasOwnProperty(key)) continue;10 if (key in global) continue;11 global[key] = window[key];12 }13}14var $ = require('jquery');15var expect = require('chai').expect;16describe('test', function () {17 it('test', function () {18 expect($('body').length).to.equal(1);19 });20});21module.exports = function(config) {22 config.set({23 preprocessors: {24 },25 browserify: {26 },27 });28};29{30 "scripts": {31 },32 "dependencies": {

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 Karma 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