How to use returnTrue method in Cypress

Best JavaScript code snippet using cypress

family.js

Source:family.js Github

copy

Full Screen

1/*          |\__.__/|2 *          )       (3 *         =\       /=          .4 *     |     )=====(       *          '5 *    |     /       \             *        *6 *   |     / dombili \       +                 '*7 *  *      \        /8 *  _/\_/\_/\_,  ,_/_/\_/\_/\_/\_/\_/\_/\_/\_/\_9 *            )  )   This project is a part of the10 *           (  (   “Byte-Sized JavaScript” videocasts.11 *           )  )  Watch “Byte-Sized JavaScript” at: https://bytesized.tv/12 *          (__(  MIT licensed — See LICENSE.md13 *               Send your comments, suggestions, and feedback to me@volkan.io14 */15import { returnTrue } from './util';16/**17 * Finds the siblings of the given **DOM** `Element`, `el`.18 *19 * > If `filter` is passed as an argument, this function returns the20 * > nodes only if `filter` returns `true` for that node.21 *22 * > Compare this to the `$.siblings()` method of **jQuery**.23 *24 * @example25 * import { siblings, $ } from 'dombili';26 * const node = $( '#todo-list li' );27 * const otherTodos = siblings( node );28 *29 * @param {Element} el The DOM element to find the siblings of.30 * @param {function(*)} [filter=returnTrue] A predicate to filter the nodes.31 *      If not given, defaults to a function that returns true.32 *33 * @returns {Element[]} An `array` of matched DOM `Element`s.34 */35const siblings = ( el, filter = returnTrue ) => {36    if ( !el ) { return []; }37    if ( !el.parentNode ) { return []; }38    if ( !el.parentNode.firstChild ) { return []; }39    const peers = [];40    let nextSibling = el.parentNode.firstChild;41    while ( nextSibling ) {42        if ( filter( nextSibling ) && nextSibling !== el ) {43            peers.push( nextSibling );44        }45        nextSibling = nextSibling.nextSibling;46    }47    return peers;48};49/**50 * Finds the parents of the given **DOM** `Element`, `el`.51 *52 * > If `filter` is passed as an argument, this function returns the53 * > nodes only if `filter` returns `true` for that node.54 *55 * > Compare this to the `$.parents()` method of **jQuery**.56 *57 * @example58 * import { parents, $ } from 'dombili';59 * const node = $( '#todo-list' );60 * const targets = parents( node );61 *62 * @param {Element} el The DOM element to find the siblings of.63 * @param {function(*)} [filter=returnTrue] A predicate to filter the nodes.64 *      If not given, defaults to a function that returns true.65 *66 * @returns {Element[]} An `array` of matched DOM `Element`s.67 *68 * @see parentsIncludingSelf69 * @see firstParent70 * @see firstparentIncludingSelf71 */72const parents = ( el, filter = returnTrue ) => {73    if ( !el ) { return []; }74    if ( !el.parentNode ) { return []; }75    const ancestors = [];76    let parent = el.parentNode;77    while ( parent ) {78        if ( filter( parent ) ) {79            ancestors.push( parent );80        }81        parent = parent.parentNode;82    }83    return ancestors;84};85/**86 * Finds the parents of the given **DOM** `Element`, `el`. Starts the search87 * from the current element; that is, the current element will be in the returned88 * `array` too.89 *90 * > If `filter` is passed as an argument, this function returns the91 * > nodes only if `filter` returns `true` for that node.92 *93 * > Compare this to the `$.parents()` method of **jQuery**.94 *95 * @example96 * import { parentsIncludingSelf as parents, $ } from 'dombili';97 * const node = $( '#todo-list' );98 * const targets = parents( node );99 *100 * @param {Element} el The DOM element to find the siblings of.101 * @param {function(*)} [filter=returnTrue] A predicate to filter the nodes.102 *      If not given, defaults to a function that returns true.103 *104 * @returns {Element[]} An `array` of matched DOM `Element`s.105 *106 * @see parents107 * @see firstParent108 * @see firstParentIncludingSelf109 */110const parentsIncludingSelf = ( el, filter = returnTrue ) => {111    if ( !el ) { return []; }112    if ( !el.parentNode ) { return [ el ]; }113    const filteredEl = filter( el );114    const ancestors = parents( el, filter );115    return filteredEl ? [ el, ...ancestors ] : ancestors;116};117/**118 * Finds the first parent of the given **DOM** `Element`, `el`.119 *120 * > If `filter` is passed as an argument, this function returns the121 * > nodes only if `filter` returns `true` for that node.122 *123 * > Compare this to the `$.parents()` method of **jQuery**.124 *125 * @example126 * import { firstParent as parent, $ } from 'dombili';127 * const node = $( '#todo-list' );128 * const target = parent( node );129 *130 * @param {Element} el The DOM element to find the siblings of.131 * @param {function(*)} [filter=returnTrue] A predicate to filter the nodes.132 *      If not given, defaults to a function that returns true.133 *134 * @returns {Element} The first `Element` that matches the filter.135 *136 * @see parents137 * @see parentsIncludingSelf138 * @see firstParentIncludingSelf139 */140const firstParent = ( el, filter = returnTrue ) => {141    const ancestors = parents( el, filter );142    if ( ancestors && ancestors.length ) { return ancestors[ 0 ]; }143    return null;144};145/**146 * Finds the first parent of the given **DOM** `Element`, `el`. Starts the search147 * from the current element; that is, the current element will be return if it matches148 * the filter; otherwise the search proceeds from its parents.149 *150 * > If `filter` is passed as an argument, this function returns the151 * > nodes only if `filter` returns `true` for that node.152 *153 * > Compare this to the `$.parents()` method of **jQuery**.154 *155 * @example156 * import { firstParentIncludingSelf as parent, $ } from 'dombili';157 * const node = $( '#todo-list' );158 * const target = parent( node );159 *160 * @param {Element} el The DOM element to find the siblings of.161 * @param {function(*)} [filter=returnTrue] A predicate to filter the nodes.162 *      If not given, defaults to a function that returns true.163 *164 * @returns {Element} The first `Element` that matches the filter.165 *166 * @see parents167 * @see parentsIncludingSelf168 * @see firstParent169 */170const firstParentIncludingSelf = ( el, filter = returnTrue ) => {171    const ancestors = parentsIncludingSelf( el, filter );172    if ( ancestors && ancestors.length ) { return ancestors[ 0 ]; }173    return null;174};175/**176 * Finds the next siblings of the given DOM `Element`, `el`.177 *178 * > If `filter` is passed as an argument, this function returns the179 * > nodes only if `filter` returns `true` for that node.180 *181 * > Compare this to the `$.nextAll()` method of **jQuery**.182 *183 * @example184 * import { nextAll, $ } from 'dombili';185 * const node = $( '#todo-list li' );186 * const otherTodos = nextAll( node );187 *188 * @param {Element} el The DOM element to find the siblings of.189 * @param {function(*)} [filter=returnTrue] A predicate to filter the nodes.190 *      If not given, defaults to a function that returns true.191 *192 * @returns {Element[]} An `array` of matched DOM `Element`s.193 */194const nextAll = ( el, filter = returnTrue ) => {195    if ( !el ) { return []; }196    if ( !el.nextSibling ) { return []; }197    const peers = [];198    let nextSibling = el.nextSibling;199    while ( nextSibling ) {200        if ( filter( nextSibling ) ) {201            peers.push( nextSibling );202        }203        nextSibling = nextSibling.nextSibling;204    }205    return peers;206};207/**208 * Finds the previous siblings of the given DOM `Element`, `el`.209 *210 * > If `filter` is passed as an argument, this function returns the211 * > nodes only if `filter` returns `true` for that node.212 *213 * > Compare this to the `$.prevAll()` method of **jQuery**.214 *215 * @example216 * import { prevAll, $ } from 'dombili';217 * const node = $( '#todo-list li' );218 * const otherTodos = prevAll( node );219 *220 * @param {Element} el The **DOM** `Element` to find the siblings of.221 * @param {function(*)} [filter=returnTrue] A predicate to filter the nodes.222 *      If not given, defaults to a function that returns true.223 *224 * @returns {Element[]} An `array` of matched DOM `Element`s.225 */226const prevAll = ( el, filter = returnTrue ) => {227    if ( !el ) { return []; }228    if ( !el.previousSibling ) { return []; }229    const peers = [];230    let previousSibling = el.previousSibling;231    while ( previousSibling ) {232        if ( filter( previousSibling ) ) {233            peers.push( previousSibling );234        }235        previousSibling = previousSibling.previousSibling;236    }237    return peers;238};239/**240 * Finds the next sibling of the given DOM `Element`, `el`.241 *242 * > If `filter` is passed as an argument, this function returns the243 * > node only if `filter` returns `true`.244 *245 * > Compare this to the `$.next()` method of **jQuery**.246 *247 * @example248 * import { next, $ } from 'dombili';249 * const node = $( '#todo-list li' );250 * const nextTodo = next( node );251 *252 * @param {Element} el The **DOM** `Element` to find the siblings of.253 * @param {function(*)} [filter=returnTrue] A predicate to filter the nodes.254 *      If not given, defaults to a function that returns true.255 *256 * @returns {Element} The found `Element` if it exists; `null` otherwise.257 */258const next = ( el, filter = returnTrue ) => {259    if ( !el ) { return null; }260    if ( !el.nextSibling ) { return null; }261    return filter( el.nextSibling ) ? el.nextSibling : null;262};263/**264 * Finds the previous sibling of the given DOM `Element`, `el`.265 *266 * > If `filter` is passed as an argument, this function returns the267 * > node only if `filter` returns `true`268 *269 * > Compare this to the `$.next()` method of **jQuery**.270 *271 * @example272 * import { next, $ } from 'dombili';273 * const node = $( '#todo-list li' );274 * const nextTodo = next( node );275 *276 * @param {Element} el The **DOM** `Element` to find the siblings of.277 * @param {function(*)} [filter=returnTrue] A predicate to filter the nodes.278 *      If not given, defaults to a function that returns true.279 *280 * @returns {Element} The found `Element` if it exists; `null` otherwise.281 */282const prev = ( el, filter = returnTrue ) => {283    if ( !el ) { return null; }284    if ( !el.previousSibling ) { return null; }285    return filter( el.previousSibling ) ? el.previousSibling : null;286};287/**288 * Finds the first child of the given DOM `Element`, `el`.289 *290 * > If `filter` is passed as an argument, this function returns the291 * > node only if `filter` returns `true`292 *293 * > Compare this to the `$.first()` method of **jQuery**.294 *295 * @example296 * import { first, $ } from 'dombili';297 * const node = $( '#todo-list li' );298 * const firstTodo = first( node );299 *300 * @param {Element} el The **DOM** `Element` to find the siblings of.301 * @param {function(*)} [filter=returnTrue] A predicate to filter the nodes.302 *      If not given, defaults to a function that returns true.303 *304 * @returns {Element} The found `Element` if it exists; `null` otherwise.305 */306const first = ( el, filter = returnTrue ) => {307    if ( !el ) { return null; }308    if ( !el.firstChild ) { return null; }309    return filter( el.firstChild ) ? el.firstChild : null;310};311/**312 * Finds the last child of the given DOM `Element`, `el`.313 *314 * > If `filter` is passed as an argument, this function returns the315 * > node only if `filter` returns `true`.316 *317 * > Compare this to the `$.last()` method of **jQuery**.318 *319 * @example320 * import { last, $ } from 'dombili';321 * const node = $( '#todo-list li' );322 * const lastTodo = last( node );323 *324 * @param {Element} el The **DOM** `Element` to find the siblings of.325 * @param {function(*)} [filter=returnTrue] A predicate to filter the nodes.326 *      If not given, defaults to a function that returns true.327 *328 * @returns {Element} The found `Element` if it exists; `null` otherwise.329 */330const last = ( el, filter = returnTrue ) => {331    if ( !el ) { return null; }332    if ( !el.lastChild ) { return null; }333    return filter( el.lastChild ) ? el.lastChild : null;334};335export {336    first,337    firstParent,338    firstParentIncludingSelf,339    last,340    next,341    nextAll,342    parents,343    parentsIncludingSelf,344    prev,345    prevAll,346    siblings...

Full Screen

Full Screen

failing_state_chart.js

Source:failing_state_chart.js Github

copy

Full Screen

1//var createStore = require('redux')2//import createStore from 'redux'3var hcssm = require('./contextual_state_chart')4//import * as hcssm from './contextual_state_chart.js'5var cf = require('./common_functions')6//import * as cf from './common_functions.js'7var returnTrue = (store, var_store, node) => {8	return true9}10var returnFalse = (store, var_store, node) => {11	return false12}13/*14cases for state machine failures15these refer to when a submachine fails that started from a child of the supermachine(parent state)16cases 1, 2, 3 have 2 parts17	first part is for paths of length 218	secon part is for paths of length > 2191) the ith child was wrong and there is an (i+j)th correct child where j >= 1 (we can continue)(passes)202) the ith child was wrong and it's the last child in list(passes)21	2.1)22		we can move to at least 1 other node in the parent list23		we can continue24	2.2)25		we can move to 0 other nodes in the parent list26		we have to stop27how the cases map to each other281 -> 1292 -> 1 | 3303 -> 331Most of the branches testing these cases will deviate from the graph solving the calculator problem32case 3 will be tested using an extra branch first, then will use input to allow the machine to work and test all cases33the length is referring to the distance from and including the currently tested state to the topmost state34it's not measuring the length of the parent linked list35case 3 is more like case 2.236case a -> case b means case a is addressed first and is transformed into case b37*/38var vars = {39	// this control graph uses string for states and cases40	'node_graph2' : {41			// any state with no 'next' attribute means it's a finishing state42			/*43			parents44			name45			function46			next47			children48			*/49			'split 0': {50				'name'		: 	'split 0',51				'function'	: 	returnTrue,52				'next'		: 	['validate', 'invalid'],53				'children'	: 	[54									'partOfDeathPath 0'/* case 1 length 2 */,55									'partOfDeathPath 1'/* case 1 length > 2 */,56									'deadPathCanContinue root' /* case 2 length > 2 -> case 3 length > 2 */,57									'char',58									// 'deadPath0' /* case 2 length 2 -> case 3 length 2 */59								]60				// make a dead branch here 2 children levels minimum61			},62			/* case 1 length 2 */63			'partOfDeathPath 0': {64				'parents'	: 	['split'],65				'name'		: 	'partOfDeathPath 0',66				'function'	: 	returnFalse,67				'next'		: 	['deadEndState 0']68			},69			'deadEndState 0': {70				'parents'	: 	['split'],71				'name'		: 	'deadEndState 0',72				'function'	: 	returnFalse,73			},74			/* case 1 length > 2 */75			'partOfDeathPath 1': {76				'parents'	: 	['split'],77				'name'		: 	'partOfDeathPath 1',78				'function'	: 	returnTrue,79				'next'		: 	['deadEndState 1'],80				'children'	: 	['deadIntermediateState 0']81			},82			'deadEndState 1': {83				'parents'	: 	['split'],84				'name'		: 	'deadEndState 1',85				'function'	: 	returnFalse,86			},87			/* case 2 length > 2  we can continue the machine */88			'deadPathCanContinue root': {89				'parents'	: 	['split'],90				'name'		: 	'deadPathCanContinue root',91				'function'	: 	returnTrue,92				'children'	: 	['extra level']93			},94			'extra level' : {95				'parents' 	: 	['deadPathCanContinue root'],96				'name'		:	'extra level',97				'function'	: 	returnTrue,98				'children'	: 	['deadPath0 1', 'deadPath2 0']99			},100			'deadPath0 1': {101				'parents'	: 	['extra level'],102				'name'		: 	'deadPath0 1',103				'function'	: 	returnTrue,104				'next'		: 	['deadPath1 1']105			},106			'deadPath1 1': {107				'parents'	: 	['extra level'],108				'name'		: 	'deadPath1 1',109				'function'	: 	returnFalse,110			},111			'deadPath2 0': {112				'parents'	: 	['extra level'],113				'name'		: 	'deadPath2 0',114				'function'	: 	returnFalse,115			},116			117			/* case 2 length 2 -> case 3 length 2 */118			// can be used to fail the machine119			'deadPath0': {120				'parents'	: 	['split'],121				'name'		: 	'deadPath0',122				'function'	: 	returnTrue,123				'next'		: 	['deadPath1']124			},125			'deadPath1': {126				'parents'	: 	['split'],127				'name'		: 	'deadPath1',128				'function'	: 	returnFalse,129			},130			'deadIntermediateState 0': {131				'parents'	: 	['partOfDeathPath 1'],132				'name'		: 	'deadIntermediateState 0',133				'function'	: 	returnFalse134			},135			'validate': {136				'parents'	: 	[],137				'name'		: 	'validate',138				'function'	: 	returnTrue,139				'next'		: 	['evaluate_expression']140			},141			'invalid': {142				'parents'	: 	[],143				'name'		: 	'invalid',144				'function'	: 	returnTrue145			},146			'evaluate_expression': {147				'parents'	: 	[],148				'name'		: 	'evaluate_expression',149				'function'	: 	returnTrue,150				// 'next'		: 	['finalPath level 1'], // test for case 2 length > 2 -> case 3 length > 2151				'next'		: 	['input_has_1_value','evaluate_expression'],152				'children'	: 	['a']153			},154			155			156			// put a fake state between evaluate_expression -> input_has_1_value157			// to force machine to exit early without getting the answer158			// make death paths starting here to force entire machine to fail159			'input_has_1_value': {160				'parents'	: 	[],161				'name'		: 	'input_has_1_value',162				'function'	: 	returnTrue,163			},164			/*165				finalPath  level 2166					a branch level 3167						terminate state 1168						terminate state 2169					a terminal branch 0170			*/171			/* case 2 length > 2 -> case 3 length > 2 */172			'finalPath level 1': {173				// true174				'parents'	: 	[],175				'name'		: 	'finalPath level 1',176				'function'	: 	returnTrue,177				'next'		: 	['input_has_1_value','evaluate_expression'],178				'children'	: ['a branch level 3', 'a terminal branch 0']179			},180			'a branch level 3': {181				// true182				'parents'	: 	[],183				'name'		: 	'a branch level 3',184				'function'	: 	returnTrue,185				'children'	: 	['terminal state 1', 'terminal state 2']186			},187			'terminal state 1': {188				// reurn false189				'parents'	: 	[],190				'name'		: 	'terminal state 1',191				'function'	: 	returnFalse192			},193			'terminal state 2': {194				// return false195				'parents'	: 	[],196				'name'		: 	'terminal state 2',197				'function'	: 	returnTrue,198				'children'	: 	['final terminal state 1', 'final terminal state 2']199			},200			201			'final terminal state 1': {202				'parents'	: 	[],203				'name'		: 	'final terminal state 1',204				'function'	: 	returnFalse,205			},206			'final terminal state 2': {207				'parents'	: 	[],208				'name'		: 	'final terminal state 2',209				'function'	: 	returnFalse,210			},211			'a terminal branch 0': {212				// return false213				'parents'	: 	[],214				'name'		: 	'a terminal branch 0',215				'function'	: 	returnFalse216			},217				// split218				219				'char': {220					'parents'	: 	['split 0'],221					'name'		: 	'char',222					'function'	: 	returnTrue,223					'next'		: 	['last_to_save', 'char', 'save']224				},225				'save': {226					'parents'	: 	['split 0'],227					'name'		: 	'save',228					'function'	: 	returnTrue,229					'next'		: 	[' ']230				},231				' ': {232					'parents'	: 	['split 0'],233					'name'		: 	' ',234					'function'	: 	returnTrue,235					'next'		: 	[' ', 'init']236				},237				'init': {238					'parents'	: 	['split 0'],239					'name'		: 	'init',240					'function'	: 	returnTrue,241					'next'		: 	['char']242				},243				'last_to_save': {244					'parents'	: 	['split 0'],245					'name'		: 	'last_to_save',246					'function'	: 	returnTrue247				},248				// evaluate_expression249				'a': {250					'parents'	: 	['evaluate_expression'],251					'name'		: 	'a',252					'function'	: 	returnTrue,253					'next'		: 	['reset_for_next_round_of_input', 'op', 'op_ignore']254				},255				'op': {256					'parents'	: 	['evaluate_expression'],257					'name'		: 	'op',258					'function'	: 	returnTrue,259					'next'		: 	['error', 'b evaluate']260				},261				// add new step to save b?262				// make a result variable to show the result?263				'b evaluate': {264					'parents'	: 	['evaluate_expression'],265					'name'		: 	'b evaluate',266					'function'	: 	returnTrue,267					'next'		: 	['reset_for_next_round_of_input', 'a', 'op_ignore']268				},269				'op_ignore': {270					'parents'	: 	['evaluate_expression'],271					'name'		: 	'op_ignore',272					'function'	: 	returnTrue,273					'next'		: 	['error', 'value_ignore']274				},275				'value_ignore': {276					'parents'	: 	['evaluate_expression'],277					'name'		: 	'value_ignore',278					'function'	: 	returnTrue,279					'next'		: 	['reset_for_next_round_of_input', 'op_ignore', 'value_ignore valid_op']280				},281				'value_ignore valid_op': {282					'parents'	: 	['evaluate_expression'],283					'name'		: 	'value_ignore valid_op',284					'function'	: 	returnTrue,285					'next'		: 	['op']286				},287				'error': {288					'parents'	: 	['evaluate_expression'],289					'name'		: 	'error',290					'function'	: 	returnTrue291				},292				'reset_for_next_round_of_input': {293					'parents'	: 	[],294					'name'		: 	'reset_for_next_round_of_input',295					'function'	: 	returnTrue,296					'next'		: 	['end_of_evaluating']297				},298				'end_of_evaluating': {299					'parents'	: 	[],300					'name'		: 	'end_of_evaluating',301					'function'	: 	returnTrue302				},303		},304	'parsing_checks' : parsing_checks305}306var nodeReducer4 = (state = {vars}, action) => {307    //console.log("got here", action.type, action)308    // set this false when the item enteres309    return hcssm.universalReducer(state, action, state.vars)310}311//var calculator_reducer = createStore(nodeReducer4)312// -1 so highest level of graph isn't printed with an indent313// ['split', '0'], ['input_has_1_value', '0'] define a the start point and end point314// through the state chart315// ['input_has_1_value', '0']316// hcssm.visitRedux('split 0', vars, 1)...

Full Screen

Full Screen

ut-navigable-control-list.js

Source:ut-navigable-control-list.js Github

copy

Full Screen

1// Copyright © 2009 Backplane Ltd.2//3// Licensed under the Apache License, Version 2.0 (the "License");4// you may not use this file except in compliance with the License.5// You may obtain a copy of the License at6//7//  http://www.apache.org/licenses/LICENSE-2.08//9// Unless required by applicable law or agreed to in writing, software10// distributed under the License is distributed on an "AS IS" BASIS,11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12// See the License for the specific language governing permissions and13// limitations under the License.1415(function(){16	var suiteNavigableControlList;1718	var returnTrue = function () { return true; };19	var returnFalse = function () { return false; };2021	YAHOO.tool.TestRunner.add(new YAHOO.tool.TestCase({22		name: "Testing the NavigableControlList object",2324		setUp: function(){25			this.ncl = new NavigableControlList();26		},2728		tearDown: function(){29			delete this.ncl;30		},3132		testConstruction: function () {33			YAHOO.util.Assert.isNotUndefined(this.ncl);34			YAHOO.util.Assert.isObject(this.ncl);35			YAHOO.util.Assert.isNotNull(this.ncl);36			YAHOO.util.Assert.isFunction(this.ncl.addControl);37			YAHOO.util.Assert.isFunction(this.ncl.getFirstControl);38			YAHOO.util.Assert.isFunction(this.ncl.getLastControl);39			YAHOO.util.Assert.isFunction(this.ncl.getNextControl);40			YAHOO.util.Assert.isFunction(this.ncl.getPreviousControl);41		},4243		testGetFirstControl: function () {44			var control0 = { isNavigableControl: true, navIndex: 0, isEnabled: returnTrue },45			    control1a = { isNavigableControl: true, navIndex: 1, isEnabled: returnFalse },46			    control1b = { isNavigableControl: true, navIndex: 1, isEnabled: returnTrue },47			    control2a = { isNavigableControl: true, navIndex: 2, isEnabled: returnTrue },48			    control2b = { isNavigableControl: true, navIndex: 2, isEnabled: returnTrue };4950			YAHOO.util.Assert.isNull(this.ncl.getFirstControl());5152			this.ncl.addControl(control2a);53			YAHOO.util.Assert.areSame(control2a, this.ncl.getFirstControl());5455			this.ncl.addControl(control2b);56			YAHOO.util.Assert.areSame(control2a, this.ncl.getFirstControl());5758			this.ncl.addControl(control1a);59			YAHOO.util.Assert.areSame(control2a, this.ncl.getFirstControl());6061			this.ncl.addControl(control1b);62			YAHOO.util.Assert.areSame(control1b, this.ncl.getFirstControl());6364			this.ncl.addControl(control0);65			YAHOO.util.Assert.areSame(control1b, this.ncl.getFirstControl());66		},6768		testGetLastControl: function () {69			var control0 = { isNavigableControl: true, navIndex: 0, isEnabled: returnTrue },70			    control1 = { isNavigableControl: true, navIndex: 1, isEnabled: returnTrue },71			    control2 = { isNavigableControl: true, navIndex: 2, isEnabled: returnTrue },72			    control3a = { isNavigableControl: true, navIndex: 3, isEnabled: returnTrue },73			    control3b = { isNavigableControl: true, navIndex: 3, isEnabled: returnTrue },74			    control3c = { isNavigableControl: true, navIndex: 3, isEnabled: returnFalse },75			    control4 = { isNavigableControl: true, navIndex: 4, isEnabled: returnTrue };7677			YAHOO.util.Assert.isNull(this.ncl.getLastControl());7879			this.ncl.addControl(control2);80			YAHOO.util.Assert.areSame(control2, this.ncl.getLastControl());8182			this.ncl.addControl(control1);83			YAHOO.util.Assert.areSame(control2, this.ncl.getLastControl());8485			this.ncl.addControl(control3a);86			YAHOO.util.Assert.areSame(control3a, this.ncl.getLastControl());8788			this.ncl.addControl(control3b);89			YAHOO.util.Assert.areSame(control3b, this.ncl.getLastControl());9091			this.ncl.addControl(control3c);92			YAHOO.util.Assert.areSame(control3b, this.ncl.getLastControl());9394			this.ncl.addControl(control0);95			YAHOO.util.Assert.areSame(control0, this.ncl.getLastControl());9697			this.ncl.addControl(control4);98			YAHOO.util.Assert.areSame(control0, this.ncl.getLastControl());99		},100101		testGetNextControl: function () {102			var control0 = { isNavigableControl: true, navIndex: 0, isEnabled: returnTrue },103			    control1 = { isNavigableControl: true, navIndex: 1, isEnabled: returnTrue },104			    control2 = { isNavigableControl: true, navIndex: 2, isEnabled: returnTrue },105			    control3a = { isNavigableControl: true, navIndex: 3, isEnabled: returnTrue },106			    control3b = { isNavigableControl: true, navIndex: 3, isEnabled: returnTrue },107			    control3c = { isNavigableControl: true, navIndex: 3, isEnabled: returnFalse },108			    control4 = { isNavigableControl: true, navIndex: 4, isEnabled: returnTrue };109110			YAHOO.util.Assert.isNull(this.ncl.getNextControl());111112			this.ncl.addControl(control0);113			this.ncl.addControl(control1);114			this.ncl.addControl(control4);115			this.ncl.addControl(control3a);116			this.ncl.addControl(control3b);117			this.ncl.addControl(control3c);118			this.ncl.addControl(control2);119120			YAHOO.util.Assert.areSame(control2, this.ncl.getNextControl(control1));121			YAHOO.util.Assert.areSame(control3a, this.ncl.getNextControl(control2));122			YAHOO.util.Assert.areSame(control3b, this.ncl.getNextControl(control3a));123			YAHOO.util.Assert.areSame(control4, this.ncl.getNextControl(control3b));124			YAHOO.util.Assert.areSame(control0, this.ncl.getNextControl(control4));125			YAHOO.util.Assert.isNull(this.ncl.getNextControl(control0));126		},127128		testGetPreviousControl: function () {129			var control0 = { isNavigableControl: true, navIndex: 0, isEnabled: returnTrue },130			    control1 = { isNavigableControl: true, navIndex: 1, isEnabled: returnTrue },131			    control2 = { isNavigableControl: true, navIndex: 2, isEnabled: returnTrue },132			    control3a = { isNavigableControl: true, navIndex: 3, isEnabled: returnTrue },133			    control3b = { isNavigableControl: true, navIndex: 3, isEnabled: returnTrue },134			    control3c = { isNavigableControl: true, navIndex: 3, isEnabled: returnFalse },135			    control4 = { isNavigableControl: true, navIndex: 4, isEnabled: returnTrue };136137			YAHOO.util.Assert.isNull(this.ncl.getPreviousControl());138139			this.ncl.addControl(control0);140			this.ncl.addControl(control1);141			this.ncl.addControl(control4);142			this.ncl.addControl(control3a);143			this.ncl.addControl(control3b);144			this.ncl.addControl(control3c);145			this.ncl.addControl(control2);146147			YAHOO.util.Assert.isNull(this.ncl.getPreviousControl(control1));148			YAHOO.util.Assert.areSame(control1, this.ncl.getPreviousControl(control2));149			YAHOO.util.Assert.areSame(control2, this.ncl.getPreviousControl(control3a));150			YAHOO.util.Assert.areSame(control3a, this.ncl.getPreviousControl(control3b));151			YAHOO.util.Assert.areSame(control3b, this.ncl.getPreviousControl(control4));152			YAHOO.util.Assert.areSame(control4, this.ncl.getPreviousControl(control0));153		},154155		testGetControlByAccessKey: function () {156			var control1 = { isNavigableControl: true, accessKey: '1', navIndex: 0 },157			    control2 = { isNavigableControl: true, accessKey: 'B', navIndex: 0 };158159			YAHOO.util.Assert.isNull(this.ncl.getControlByAccessKey(control1.accessKey.charCodeAt(0)));160			YAHOO.util.Assert.isNull(this.ncl.getControlByAccessKey(control2.accessKey.charCodeAt(0)));161162			this.ncl.addControl(control1);163			YAHOO.util.Assert.areSame(control1, this.ncl.getControlByAccessKey(control1.accessKey.charCodeAt(0)));164			YAHOO.util.Assert.isNull(this.ncl.getControlByAccessKey(control2.accessKey.charCodeAt(0)));165166			this.ncl.addControl(control2);167			YAHOO.util.Assert.areSame(control1, this.ncl.getControlByAccessKey(control1.accessKey.charCodeAt(0)));168			YAHOO.util.Assert.areSame(control2, this.ncl.getControlByAccessKey(control2.accessKey.charCodeAt(0)));169		}170	}));
...

Full Screen

Full Screen

array-holes.js

Source:array-holes.js Github

copy

Full Screen

...22    }23    string += "]";24    return string;25}26function returnTrue()27{28    return true;29}30var a;31function addToArray(arg)32{33    a.push(arg);34}35function addToArrayReturnFalse(arg)36{37    a.push(arg);38    return false;39}40function addToArrayReturnTrue(arg)...

Full Screen

Full Screen

printStatusReport-test.js

Source:printStatusReport-test.js Github

copy

Full Screen

1'use strict';2/**3 * @flow4 */5import {6  asSummary,7  asText,8  asHTMLTable,9  asCSV,10  asJUnit,11  asJSON,12} from '../printStatusReport';13import os from 'os';14const EMPTY_REPORT = {15  summary: {16    flow: 0,17    flowstrict: 0,18    flowstrictlocal: 0,19    flowweak: 0,20    noflow: 0,21    total: 0,22  },23  files: [],24}25const BASIC_REPORT = {26  summary: {27    flow: 1,28    flowstrict: 1,29    flowstrictlocal: 1,30    flowweak: 1,31    noflow: 1,32    total: 5,33  },34  files: [35    {status: 'flow strict', file: './s.js'},36    {status: 'flow strict-local', file: './sl.js'},37    {status: 'flow', file: './a.js'},38    {status: 'flow weak', file: './b.js'},39    {status: 'no flow', file: './c.js'},40  ],41};42const returnTrue = jest.fn();43describe('printStatusReport', () => {44  beforeEach(() => {45    returnTrue.mockReset();46    returnTrue.mockReturnValue(true);47  });48  describe('asSummary', () => {49    it('should print only a summarized text report', () => {50      expect(asSummary(BASIC_REPORT)).toMatchSnapshot();51    });52  });53  describe('asText', () => {54    it('should print a simple text report', () => {55      expect(asText(BASIC_REPORT, false, returnTrue)).toMatchSnapshot();56    });57    it('should print a summarized text report', () => {58      expect(asText(BASIC_REPORT, true, returnTrue)).toMatchSnapshot();59    });60    it('should filtered the report based on status', () => {61      asText(BASIC_REPORT, true, returnTrue);62      expect(returnTrue).toHaveBeenCalledTimes(BASIC_REPORT.files.length);63    });64  });65  describe('asCSV', () => {66    it('should print a simple csv report', () => {67      expect(asCSV(BASIC_REPORT, false, returnTrue)).toMatchSnapshot();68    });69    it('should print a summarized csv report', () => {70      expect(asCSV(BASIC_REPORT, true, returnTrue)).toMatchSnapshot();71    });72    it('should filter the csv report', () => {73      asCSV(BASIC_REPORT, false, returnTrue);74      expect(returnTrue).toHaveBeenCalledTimes(BASIC_REPORT.files.length);75    });76  });77  describe('asHTMLTable', () => {78    it('should print a simple html-table report', () => {79      expect(asHTMLTable(BASIC_REPORT, false, returnTrue)).toMatchSnapshot();80    });81    it('should print a summarized html-table report', () => {82      expect(asHTMLTable(BASIC_REPORT, true, returnTrue)).toMatchSnapshot();83    });84    it('should filter the html-table report', () => {85      asHTMLTable(BASIC_REPORT, true, returnTrue);86      expect(returnTrue).toHaveBeenCalledTimes(BASIC_REPORT.files.length);87    });88    it('should print an empty html-table report', () => {89      expect(asHTMLTable(EMPTY_REPORT, false, returnTrue)).toMatchSnapshot();90    });91    it('should print an html-table report with even percentages', () => {92      const report = {93        summary: {94          flow: 1,95          flowstrict: 1,96          flowstrictlocal: 0,97          flowweak: 1,98          noflow: 1,99          total: 4,100        },101        files: [102          {status: 'flow', file: './a.js'},103          {status: 'flow strict', file: './s.js'},104          {status: 'flow weak', file: './b.js'},105          {status: 'no flow', file: './b.js'},106        ],107      };108      expect(asHTMLTable(report, false, returnTrue)).toMatchSnapshot();109    });110  });111  describe('asJUnit', () => {112    beforeEach(() => {113      global.Date = jest.fn(() => ({114        toISOString: () => '-mock date-',115      }));116      // $FlowExpectedError: Overriding for consistency across environments117      os.hostname = jest.fn(() => 'test-host');118    });119    it('should print a jUnit compatible report', () => {120      expect(asJUnit(BASIC_REPORT, returnTrue)).toMatchSnapshot();121    });122    it('should filter the jUnit report', () => {123      asJUnit(BASIC_REPORT, returnTrue);124      expect(returnTrue).toHaveBeenCalledTimes(BASIC_REPORT.files.length);125    });126  });127  describe('asJSON', () => {128    it('should print a JSON blob', () => {129      expect(asJSON(BASIC_REPORT)).toMatchSnapshot();130    });131  });...

Full Screen

Full Screen

include.js

Source:include.js Github

copy

Full Screen

1import { include } from 'wild-wild-utils'2import {3  returnFalse,4  returnTrue,5  isOne,6  isObject,7  isNotObject,8  isNamedTwo,9} from '../helpers/functions.js'10import { getChild } from '../helpers/inherited.js'11import { testOutput } from '../helpers/output.js'12import { testValidation } from '../helpers/validate.js'13const child = getChild()14testOutput('include', include, [15  // Main usage16  {17    input: [{ one: 1, two: 2 }, 'one two', returnTrue],18    output: { one: 1, two: 2 },19  },20  { input: [{ one: 1, two: 2 }, 'one two', returnFalse], output: {} },21  { input: [{ one: 1, two: 2 }, 'one', returnTrue], output: { one: 1 } },22  { input: [{ one: 1, two: 2 }, 'one two', isOne], output: { one: 1 } },23  { input: [{ one: 1 }, 'two', returnTrue], output: {} },24  { input: [{ one: { two: 2 } }, 'one one.two', returnFalse], output: {} },25  {26    input: [{ one: { two: 2, three: 3 } }, 'one one.two', isObject],27    output: { one: { two: 2, three: 3 } },28  },29  {30    input: [{ one: { two: 2, three: 3 } }, 'one one.two', isNotObject],31    output: { one: { two: 2 } },32  },33  // `entries` option34  {35    input: [{ one: 1, two: 2 }, 'one two', isNamedTwo, { entries: true }],36    output: { two: 2 },37  },38  // `sort` option39  {40    input: [{ two: 2, one: 1 }, 'one two', returnTrue],41    output: { two: 2, one: 1 },42  },43  {44    input: [{ two: 2, one: 1 }, 'one two', returnTrue, { sort: true }],45    output: { one: 1, two: 2 },46  },47  // `classes` and `inherited` options48  { input: [child, '/own/', returnTrue], output: {} },49  {50    input: [child, '/own/', returnTrue, { classes: true }],51    output: { own: 'own' },52  },53  { input: [child, '/inherited/', returnTrue], output: {} },54  { input: [child, '/inherited/', returnTrue, { classes: true }], output: {} },55  {56    input: [57      child,58      '/inherited/',59      returnTrue,60      { classes: true, inherited: true },61    ],62    output: { inherited: 'inherited' },63  },64])65testValidation('include', include, [66  [{}, true, returnTrue],67  [{}, '.', true],...

Full Screen

Full Screen

find.js

Source:find.js Github

copy

Full Screen

1import { find } from 'wild-wild-utils'2import { returnTrue, isOne } from './helpers/functions.js'3import { getChild } from './helpers/inherited.js'4import { testOutput } from './helpers/output.js'5import { testValidation } from './helpers/validate.js'6const child = getChild()7testOutput('find', find, [8  // Main usage9  { input: [{ two: 2, one: 1 }, '*', isOne], output: 1 },10  { input: [{ two: 2, one: 1 }, '*', returnTrue], output: 2 },11  { input: [{}, 'one', returnTrue], output: undefined },12  // `childFirst`, `leaves` and `roots` options13  { input: [{ one: 1 }, '**', returnTrue], output: { one: 1 } },14  { input: [{ one: 1 }, '**', returnTrue, { childFirst: true }], output: 1 },15  { input: [{ one: 1 }, '**', returnTrue, { leaves: true }], output: 1 },16  {17    input: [{ one: 1 }, '**', returnTrue, { childFirst: true, roots: true }],18    output: { one: 1 },19  },20  // `sort` option21  { input: [{ two: 2, one: 1 }, '*', returnTrue], output: 2 },22  { input: [{ two: 2, one: 1 }, '*', returnTrue, { sort: true }], output: 1 },23  // `entries` option24  {25    input: [{ one: 1 }, '*', returnTrue, { entries: true }],26    output: { value: 1, path: ['one'], missing: false },27  },28  { input: [{}, 'one', returnTrue, { entries: true }], output: undefined },29  // `classes` and `inherited` options30  { input: [child, '/own/', returnTrue], output: undefined },31  { input: [child, '/own/', returnTrue, { classes: true }], output: 'own' },32  { input: [child, '/inherited/', returnTrue], output: undefined },33  {34    input: [child, '/inherited/', returnTrue, { classes: true }],35    output: undefined,36  },37  {38    input: [39      child,40      '/inherited/',41      returnTrue,42      { classes: true, inherited: true },43    ],44    output: 'inherited',45  },46])47testValidation('find', find, [48  [{}, true, returnTrue],49  [{}, '.', true],...

Full Screen

Full Screen

boolean-logic.js

Source:boolean-logic.js Github

copy

Full Screen

...9console.log('__Not or denial__');10console.log(true);11console.log(!true);12console.log(!false);13console.log(!returnTrue());14console.log(!returnFalse());15console.log('__And__'); // Return true if all values are true16console.log(true && true);17console.log(true && !false);18console.log('_________________');19console.log(returnTrue() && returnFalse());20console.log(!returnFalse() && returnTrue());21console.log('_________________');22returnFalse() && returnTrue();23console.log('__OR__');24console.log(true || false)25console.log(false || false)26returnTrue() || returnFalse();27// assignments28console.log('__Assignments__')29const iUndefined = undefined;30const iNull = null;31const iFalse = false;32const a1 = false && 'Hello World' && 150;33const a2 = 'Hello' && 'World';34const a3 = iFalse || 'I not false';35const a4 = iFalse || iFalse || 'I not false!!!' || true;36const a5 = iFalse || returnTrue() || 'I not false!!!' || true;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test', () => {2    it('Does not do much!', () => {3      expect(true).to.equal(true)4    })5  })6  describe('My First Test', () => {7    it('Does not do much!', () => {8      expect(false).to.equal(false)9    })10  })11  describe('My First Test', () => {12    it('Does not do much!', () => {13      expect(null).to.equal(null)14    })15  })16  describe('My First Test', () => {17    it('Does not do much!', () => {18      expect(undefined).to.equal(undefined)19    })20  })21  describe('My First Test', () => {22    it('Does not do much!', () => {23      expect(NaN).to.equal(NaN)24    })25  })26  describe('My First Test', () => {27    it('Does not do much!', () => {28      expect(0).to.equal(0)29    })30  })31  describe('My First Test', () => {32    it('Does not do much!', () => {33      expect("").to.equal("")34    })35  })36  describe('My First Test', () => {37    it('Does not do much!', () => {38      expect({}).to.equal({})39    })40  })41  describe('My First Test', () => {42    it('Does not do much!', () => {43      expect([]).to.equal([])44    })45  })46  describe('My First Test', () => {47    it('Does not do much!', () => {48      expect(new Map()).to.equal(new Map())49    })50  })51  describe('My First Test', () => {52    it('Does not do much!', () => {53      expect(new Set()).to.equal(new Set())54    })55  })56  describe('My First

Full Screen

Using AI Code Generation

copy

Full Screen

1it('should return true', () .> {2  expect(true).to.equal(true)3})4it('should return true', () r> {5  expect(true).to.equal(true)6})7it('should return true', () e> {8  expect(true).to.equal(true)9})10turnPromiseWithEmptyArray()11it('shoul/ return true', () => {12  expect(true).to.equal(true)13})14et('should return true', () => {15  expect(true).to.equal(true)16})17it('should return true', () => {18  expect(true).to.equal(true)19})20it('should return true', () => {21  expect(true).to.equal(true)22})

Full Screen

Using AI Code Generation

copy

Full Screen

1it('should return true', () => {2  expect(true).to.equal(true)3})4it('should return true', () => {5  expect(true).to.equal(true)6})7it('should return true', () => {8  expect(true).to.equal(true)9})10it('should return true', () => {11  expect(true).to.equal(true)12})13it('should return true', () => {14  expect(true).to.equal(true)15})16it('should return true', () => {17  expect(true).to.equal(true)18})19it(rshould return true', () => {20  expect(true).to.equal(true)21})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test Suite', function() 2{3it('My FirstTest case',function() {4cy.get('#checkBoxOption1').check().should('be.checked').and('have.value','option1')5cy.get('#checkBoxOption1').uncheck().should('not.be.checked')6cy.get('input[type="checkbox"]').check(['option2','option3']).should('be.checked')ode to use returnOne method of Cypress

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('My First Test Suite', function() 2{3it('My FirstTest case',function() {4cy.get('#checkBoxOption1').check().should('be.checked').and('have.value','option1')5cy.get('#checkBoxOption1').uncheck().should('not.be.checked')6cy.get('input[type="checkbox"]').check(['option2','option3']).should('be.checked')

Full Screen

Using AI Code Generation

copy

Full Screen

1cy.returnTrue().should('be.true')2[MIT](LICENSE)ode to use returnTrue method of Cypress3describe('My First Test', () => {4  it('Does not do much!', () => {5    expect(true).to.equal(true)6  })7})8describe('My First Test', () => {9  it('Does not do much!', () => {10    expect(true).to.equal(true)11  })12})13describe('My First Test', () => {14  it('Does not do much!', () => {15    expect(true).to.equal(true)16  })17})18describe('My First Test', () => {19  it('Does not do much!', () => {20    expect(true).to.equal(true)21  })22})23describe('My First Test', () => {24  it('Does not do much!', () => {25    expect(true).to.equal(true)26  })27})28describe('My First Test', () => {29  it('Does not do much!', () => {30    expect(true).to.equal(true)31  })32})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe("test", () => {2    it("test", () => {3        cy.get("input[name='q']").type("hello");4        cy.get("input[name='btnK']").click();5        cy.get("body").then(($body) => {6            if ($body.find("input[name='btnK']").length > 0) {7                cy.get("input[name='btnK']").click();8            }9        });10    });11});

Full Screen

Using AI Code Generation

copy

Full Screen

1it('should return true', () => {2    expect(true).to.equal(true)3  })4- Cypress commands are used to interact with the application under test (AUT). 5it('should return true', () => {6    expect(true).to.equal(true)7  })

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress 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