Best JavaScript code snippet using cypress
delete.js
Source:delete.js
1/*ï¼2 * å é¤æ§å¶3 */4define( function ( require, exports, module ) {5 var kity = require( "kity" );6 return kity.createClass( "DeleteComponent", {7 constructor: function ( parentComponent, kfEditor ) {8 this.parentComponent = parentComponent;9 this.kfEditor = kfEditor;10 },11 deleteGroup: function () {12 var cursorInfo = this.parentComponent.getCursorRecord(),13 objTree = this.parentComponent.getObjectTree(),14 // å½åçæ ä¿¡æ¯15 currentTree = objTree.mapping[ cursorInfo.groupId ].strGroup;16 // éåºé¿åº¦ä¸º0, åå é¤åä¸ä¸ªç»17 if ( cursorInfo.startOffset === cursorInfo.endOffset ) {18 // å·²ç»å°æåï¼ éè¦è¿ä¸æ¥å¤ç19 if ( cursorInfo.startOffset === 0 ) {20 // æ ¹èç¹æ¶ï¼ ç´æ¥éåºï¼ ä¸åä»»ä½å¤ç21 if ( this.parentComponent.isRootTree( currentTree ) ) {22 return false;23 }24 // ä¸æ¯æ ¹èç¹æ¶ï¼ éä¸å½å容å¨çç¶å®¹å¨25 cursorInfo = this.selectParentContainer( cursorInfo.groupId );26 this.parentComponent.updateCursor( cursorInfo );27 return false;28 } else {29 // è¿ææ´å¤å©ä½å
å®¹ï¼ åç´æ¥å é¤åä¸ä¸ªç»30 if ( currentTree.operand.length > 1 ) {31 cursorInfo = this.deletePrevGroup( currentTree, cursorInfo );32 // ä»
æä¸ä¸ªéè¦å é¤çç»åå¨æ¶çå¤ç33 } else {34 // æ´æ°å
æ ä½ç½®35 cursorInfo.startOffset = 0;36 cursorInfo.endOffset = 1;37 // å¤çç»ç±»åï¼ éä¸è¯¥ç»å³å¯38 if ( currentTree.operand[ 0 ].attr && this.parentComponent.isGroupNode( currentTree.operand[ 0 ].attr.id ) ) {39 this.parentComponent.updateCursor( cursorInfo );40 return false;41 // æ®éå
ç´ å¤ç42 } else {43 // æ¿æ¢æå ä½ç¬¦44 currentTree.operand[ 0 ] = {45 name: "placeholder",46 operand: []47 };48 this.parentComponent.updateCursor( cursorInfo );49 return true;50 }51 }52 }53 // å½åæ¯éåº54 } else {55 // å½åéä¸å ä½ç¬¦çæ
åµ56 if ( this.parentComponent.isSelectPlaceholder() ) {57 // å¦ææ¯æ ¹èç¹ï¼ åä¸å
许å é¤58 if ( this.parentComponent.isRootTree( currentTree ) ) {59 return false;60 // å¦åï¼æ´æ°éåºå°éä¸è¯¥å®¹å¨61 } else {62 cursorInfo = this.selectParentContainer( cursorInfo.groupId );63 this.parentComponent.updateCursor( cursorInfo );64 return false;65 }66 // å
¶ä»éåºæ£å¸¸å é¤67 } else {68 return this.deleteSelection( currentTree, cursorInfo );69 }70 }71 this.parentComponent.updateCursor( cursorInfo );72 // éåºé¿åº¦ä¸º0ï¼ åå¯ä»¥å¤å®å½åå
¬å¼åçäºæ¹å73 if ( cursorInfo.startOffset === cursorInfo.endOffset ) {74 return true;75 }76 return false;77 },78 // å é¤åä¸ä¸ªèç¹, è¿åæ´æ°åçå
æ ä¿¡æ¯79 deletePrevGroup: function ( tree, cursorInfo ) {80 // å¾
å é¤çç»81 var index = cursorInfo.startOffset - 1,82 group = tree.operand[ index ];83 // å¶åèç¹å¯ä»¥ç´æ¥å é¤84 if ( this.parentComponent.isLeafTree( group ) ) {85 tree.operand.splice( index, 1 );86 cursorInfo.startOffset -= 1;87 cursorInfo.endOffset -= 1;88 // å¦åï¼ éä¸è¯¥èç¹89 } else {90 cursorInfo.startOffset -= 1;91 }92 return cursorInfo;93 },94 // å é¤éåºå
容95 deleteSelection: function ( tree, cursorInfo ) {96 // éä¸çæ¯å®¹å¨å
çææå
容97 if ( cursorInfo.startOffset === 0 && cursorInfo.endOffset === tree.operand.length ) {98 tree.operand.length = 1;99 tree.operand[ 0 ] = {100 name: "placeholder",101 operand: []102 };103 cursorInfo.endOffset = 1;104 // å¦åå¯ä»¥å é¤å½åéä¸å
容105 } else {106 tree.operand.splice( cursorInfo.startOffset, cursorInfo.endOffset - cursorInfo.startOffset );107 cursorInfo.endOffset = cursorInfo.startOffset;108 }109 this.parentComponent.updateCursor( cursorInfo );110 return true;111 },112 // éä¸ç»å®IDèç¹çç¶å®¹å¨113 selectParentContainer: function ( groupId ) {114 var currentGroupNode = this.parentComponent.getGroupObject( groupId ).node,115 parentContainerInfo = this.kfEditor.requestService( "position.get.group", currentGroupNode ),116 // å½åç»å¨ç¶å®¹å¨ä¸çç´¢å¼117 index = this.kfEditor.requestService( "position.get.index", parentContainerInfo.groupObj, currentGroupNode );118 // è¿åæ°çå
æ ä¿¡æ¯119 return {120 groupId: parentContainerInfo.id,121 startOffset: index,122 endOffset: index + 1123 };124 }125 } );...
indxf03.js
Source:indxf03.js
1//# ==++== 2//# 3//# 4//# Copyright (c) 2006 Microsoft Corporation. All rights reserved.5//# 6//# The use and distribution terms for this software are contained in the file7//# named license.txt, which can be found in the root of this distribution.8//# By using this software in any fashion, you are agreeing to be bound by the9//# terms of this license.10//# 11//# You must not remove this notice, or any other, from this software.12//# 13//# 14//# ==--== 15//####################################################################################16@cc_on17import System;18var NULL_DISPATCH = null;19var apGlobalObj;20var apPlatform;21var lFailCount;22var iTestID = 52864;23var g_lang;24function GetLang()25{26 g_lang = apGlobalObj.apGetLangExt(apGlobalObj.LangHost());27}28 function indxf03 () {29 apInitTest("indxf03 ");30 GetLang();31 var VarString1 , VarString2;32 var IntegerVar1 , IntegerVar2;33 var LongVar1 , LongVar2;34 var DoubleVar1 , DoubleVar2;35 var FixedString1 , FixedString2;36 apInitScenario("Scenario 1 - Use a numeric constant of each type for START");37 VarString1 = "ABCDEFG-1-ABCDEFG-1-ABCDEFG";38 var Temp = VarString1.indexOf( "-1-",3);39 var Expected = 7;40 if (Temp != Expected) {41 apLogFailInfo("(START as INTEGER constant)", Expected, Temp, "");42 }43 Temp = VarString1.indexOf( "-1-",7.7);44 Expected = 7;45 if (Temp != Expected) {46 apLogFailInfo("(START as single constant)", Expected, Temp, "");47 }48 Temp = VarString1.indexOf("-1-",2.00000099999)49 Expected = 7;50 if (Temp != Expected) {51 apLogFailInfo("(START as DOUBLE constant)", Expected, Temp, "");52 }53 54 apInitScenario("Use a numeric variable of each type for START");55 VarString1 = "ABCDEFG-1-ABCDEFG-1-ABCDEFG";56 IntegerVar1 = 3;57 Temp = VarString1.indexOf( "-1-",IntegerVar1);58 Expected = 7;59 if (Temp != Expected) {60 apLogFailInfo("(START as INTEGER constant)", Expected, Temp, "");61 }62 DoubleVar1 = 7.7;63 Temp = VarString1.indexOf( "-1-",DoubleVar1);64 Expected = 7;65 if (Temp != Expected) {66 apLogFailInfo("(START as single constant)", Expected, Temp, "");67 }68 DoubleVar2 = 2.00000099999;69 Temp = VarString1.indexOf("-1-",DoubleVar2);70 Expected = 7;71 if (Temp != Expected) {72 apLogFailInfo("(START as DOUBLE constant)", Expected, Temp, "");73 }74 75 apInitScenario("Use a numeric expression for START");76 VarString1 = "ABCDEFG-1-ABCDEFG-1-ABCDEFG";77 IntegerVar1 = 2;78 Temp = VarString1.indexOf( "-1-",IntegerVar1 + 1);79 Expected = 7;80 if (Temp != Expected) {81 apLogFailInfo("(START as INTEGER constant)", Expected, Temp, "");82 }83 DoubleVar1 = 3.7;84 Temp = VarString1.indexOf( "-1-",DoubleVar1 * 2);85 Expected = 7;86 if (Temp != Expected) {87 apLogFailInfo("(START as single constant)", Expected, Temp, "");88 }89 DoubleVar2 = 20;90 Temp = VarString1.indexOf("-1-",DoubleVar2 / 9);91 Expected = 7;92 if (Temp != Expected) {93 apLogFailInfo("(START as DOUBLE constant)", Expected, Temp, "");94 }95 96 apInitScenario("Use a string constant of each type for START");97 VarString1 = "ABCDEFG-1-ABCDEFG-1-ABCDEFG";98 Temp = VarString1.indexOf( "-1-","3");99 Expected = 7;100 if (Temp != Expected) {101 apLogFailInfo("(START as INTEGER constant)", Expected, Temp, "");102 }103 Temp = VarString1.indexOf( "-1-","7.7");104 Expected = 7;105 if (Temp != Expected) {106 apLogFailInfo("(START as single constant)", Expected, Temp, "");107 }108 Temp = VarString1.indexOf("-1-","2.00000099999")109 Expected = 7;110 if (Temp != Expected) {111 apLogFailInfo("(START as DOUBLE constant)", Expected, Temp, "");112 }113 114 apInitScenario("Use a string variable of each type for START");115 VarString1 = "ABCDEFG-1-ABCDEFG-1-ABCDEFG";116 IntegerVar1 = "3";117 Temp = VarString1.indexOf( "-1-",IntegerVar1);118 Expected = 7;119 if (Temp != Expected) {120 apLogFailInfo("(START as INTEGER constant)", Expected, Temp, "");121 }122 DoubleVar1 = "7.7";123 Temp = VarString1.indexOf( "-1-",DoubleVar1);124 Expected = 7;125 if (Temp != Expected) {126 apLogFailInfo("(START as single constant)", Expected, Temp, "");127 }128 DoubleVar2 = "2.00000099999";129 Temp = VarString1.indexOf("-1-",DoubleVar2);130 Expected = 7;131 if (Temp != Expected) {132 apLogFailInfo("(START as DOUBLE constant)", Expected, Temp, "");133 }134 135 apEndTest();136}137indxf03();138if(lFailCount >= 0) System.Environment.ExitCode = lFailCount;139else System.Environment.ExitCode = 1;140function apInitTest(stTestName) {141 lFailCount = 0;142 apGlobalObj = new Object();143 apGlobalObj.apGetPlatform = function Funca() { return "Rotor" }144 apGlobalObj.LangHost = function Funcb() { return 1033;}145 apGlobalObj.apGetLangExt = function Funcc(num) { return "EN"; }146 apPlatform = apGlobalObj.apGetPlatform();147 var sVer = "1.0"; //navigator.appVersion.toUpperCase().charAt(navigator.appVersion.toUpperCase().indexOf("MSIE")+5);148 apGlobalObj.apGetHost = function Funcp() { return "Rotor " + sVer; }149 print ("apInitTest: " + stTestName);150}151function apInitScenario(stScenarioName) {print( "\tapInitScenario: " + stScenarioName);}152function apLogFailInfo(stMessage, stExpected, stActual, stBugNum) {153 lFailCount = lFailCount + 1;154 print ("***** FAILED:");155 print ("\t\t" + stMessage);156 print ("\t\tExpected: " + stExpected);157 print ("\t\tActual: " + stActual);158}159function apGetLocale(){ return 1033; }160function apWriteDebug(s) { print("dbg ---> " + s) }...
lstnd03.js
Source:lstnd03.js
1//# ==++== 2//# 3//# 4//# Copyright (c) 2006 Microsoft Corporation. All rights reserved.5//# 6//# The use and distribution terms for this software are contained in the file7//# named license.txt, which can be found in the root of this distribution.8//# By using this software in any fashion, you are agreeing to be bound by the9//# terms of this license.10//# 11//# You must not remove this notice, or any other, from this software.12//# 13//# 14//# ==--== 15//####################################################################################16@cc_on17import System;18var NULL_DISPATCH = null;19var apGlobalObj;20var apPlatform;21var lFailCount;22var iTestID = 52873;23function lstnd03 () {24 apInitTest("lstnd03 ");25 var VarString1 , VarString2;26 var IntegerVar1 , IntegerVar2;27 var LongVar1 , LongVar2;28 var DoubleVar1 , DoubleVar2;29 var FixedString1 , FixedString2;30 apInitScenario("Scenario 1 - Use a numeric constant of each type for START");31 VarString1 = "ABCDEFG-1-ABCDEFG-1-ABCDEFG";32 var Temp = VarString1.lastIndexOf( "-1-",12);33 var Expected = 7;34 if (Temp != Expected) {35 apLogFailInfo("(START as INTEGER constant)", Expected, Temp, "");36 }37 Temp = VarString1.lastIndexOf( "-1-",9.7);38 Expected = 7;39 if (Temp != Expected) {40 apLogFailInfo("(START as single constant)", Expected, Temp, "");41 }42 Temp = VarString1.lastIndexOf("-1-",22.00000099999)43 Expected = 17;44 if (Temp != Expected) {45 apLogFailInfo("(START as DOUBLE constant)", Expected, Temp, "");46 }47 apInitScenario("Use a numeric variable of each type for START");48 VarString1 = "ABCDEFG-1-ABCDEFG-1-ABCDEFG";49 IntegerVar1 = 12;50 Temp = VarString1.lastIndexOf( "-1-",IntegerVar1);51 Expected = 7;52 if (Temp != Expected) {53 apLogFailInfo("(START as INTEGER constant)", Expected, Temp, "");54 }55 DoubleVar1 = 9.7;56 Temp = VarString1.lastIndexOf( "-1-",DoubleVar1);57 Expected = 7;58 if (Temp != Expected) {59 apLogFailInfo("(START as single constant)", Expected, Temp, "");60 }61 DoubleVar2 = 22.00000099999;62 Temp = VarString1.lastIndexOf("-1-",DoubleVar2);63 Expected = 17;64 if (Temp != Expected) {65 apLogFailInfo("(START as DOUBLE constant)", Expected, Temp, "");66 }67 apInitScenario("Use a numeric expression for START");68 VarString1 = "ABCDEFG-1-ABCDEFG-1-ABCDEFG";69 IntegerVar1 = 11;70 Temp = VarString1.lastIndexOf( "-1-",IntegerVar1 + 1);71 Expected = 7;72 if (Temp != Expected) {73 apLogFailInfo("(START as INTEGER constant)", Expected, Temp, "");74 }75 DoubleVar1 = 5.7;76 Temp = VarString1.lastIndexOf( "-1-",DoubleVar1 * 2);77 Expected = 7;78 if (Temp != Expected) {79 apLogFailInfo("(START as single constant)", Expected, Temp, "");80 }81 DoubleVar2 = 170;82 Temp = VarString1.lastIndexOf("-1-",DoubleVar2 / 9);83 Expected = 17;84 if (Temp != Expected) {85 apLogFailInfo("(START as DOUBLE constant)", Expected, Temp, "");86 }87 apInitScenario("Use a string constant of each type for START");88 VarString1 = "ABCDEFG-1-ABCDEFG-1-ABCDEFG";89 Temp = VarString1.lastIndexOf( "-1-","12");90 Expected = 7;91 if (Temp != Expected) {92 apLogFailInfo("(START as INTEGER constant)", Expected, Temp, "");93 }94 Temp = VarString1.lastIndexOf( "-1-","9.7");95 Expected = 7;96 if (Temp != Expected) {97 apLogFailInfo("(START as single constant)", Expected, Temp, "");98 }99 Temp = VarString1.lastIndexOf("-1-","22.00000099999")100 Expected = 17;101 if (Temp != Expected) {102 apLogFailInfo("(START as DOUBLE constant)", Expected, Temp, "");103 }104 apInitScenario("Use a string variable of each type for START");105 VarString1 = "ABCDEFG-1-ABCDEFG-1-ABCDEFG";106 IntegerVar1 = "12";107 Temp = VarString1.lastIndexOf( "-1-",IntegerVar1);108 Expected = 7;109 if (Temp != Expected) {110 apLogFailInfo("(START as INTEGER constant)", Expected, Temp, "");111 }112 DoubleVar1 = "10.7";113 Temp = VarString1.lastIndexOf( "-1-",DoubleVar1);114 Expected = 7;115 if (Temp != Expected) {116 apLogFailInfo("(START as single constant)", Expected, Temp, "");117 }118 DoubleVar2 = "22.00000099999";119 Temp = VarString1.lastIndexOf("-1-",DoubleVar2);120 Expected = 17;121 if (Temp != Expected) {122 apLogFailInfo("(START as DOUBLE constant)", Expected, Temp, "");123 }124 apEndTest();125}126lstnd03();127if(lFailCount >= 0) System.Environment.ExitCode = lFailCount;128else System.Environment.ExitCode = 1;129function apInitTest(stTestName) {130 lFailCount = 0;131 apGlobalObj = new Object();132 apGlobalObj.apGetPlatform = function Funca() { return "Rotor" }133 apGlobalObj.LangHost = function Funcb() { return 1033;}134 apGlobalObj.apGetLangExt = function Funcc(num) { return "EN"; }135 apPlatform = apGlobalObj.apGetPlatform();136 var sVer = "1.0"; //navigator.appVersion.toUpperCase().charAt(navigator.appVersion.toUpperCase().indexOf("MSIE")+5);137 apGlobalObj.apGetHost = function Funcp() { return "Rotor " + sVer; }138 print ("apInitTest: " + stTestName);139}140function apInitScenario(stScenarioName) {print( "\tapInitScenario: " + stScenarioName);}141function apLogFailInfo(stMessage, stExpected, stActual, stBugNum) {142 lFailCount = lFailCount + 1;143 print ("***** FAILED:");144 print ("\t\t" + stMessage);145 print ("\t\tExpected: " + stExpected);146 print ("\t\tActual: " + stActual);147}148function apGetLocale(){ return 1033; }149function apWriteDebug(s) { print("dbg ---> " + s) }...
actions.js
Source:actions.js
1/* This Source Code Form is subject to the terms of the Mozilla Public2 * License, v. 2.0. If a copy of the MPL was not distributed with this3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */4BrowserID.Modules.Actions = (function() {5 "use strict";6 var bid = BrowserID,7 sc,8 serviceManager = bid.module,9 user = bid.User,10 errors = bid.Errors,11 mediator = bid.Mediator,12 dialogHelpers = bid.Helpers.Dialog,13 runningService,14 onsuccess;15 function startService(name, options, reported_service_name) {16 mediator.publish("service", { name: reported_service_name || name });17 // Only one service outside of the main dialog allowed.18 if(runningService) {19 serviceManager.stop(runningService);20 }21 var module = serviceManager.start(name, options);22 if(module) {23 runningService = name;24 }25 return module;26 }27 function startRegCheckService(options, verifier, message) {28 var controller = startService("check_registration", {29 verifier: verifier,30 verificationMessage: message,31 rpInfo: options.rpInfo,32 email: options.email33 });34 controller.startCheck();35 }36 var Module = bid.Modules.PageModule.extend({37 start: function(data) {38 var self=this;39 data = data || {};40 onsuccess = data.onsuccess;41 sc.start.call(self, data);42 if(data.ready) _.defer(data.ready);43 },44 doCancel: function() {45 if(onsuccess) onsuccess(null);46 },47 doSetPassword: function(info) {48 startService("set_password", info);49 },50 doStageUser: function(info) {51 dialogHelpers.createUser.call(this, info.email, info.password, info.ready);52 },53 doConfirmUser: function(info) {54 startRegCheckService.call(this, info, "waitForUserValidation", "user_confirmed");55 },56 doPickEmail: function(info) {57 startService("pick_email", info);58 },59 doAddEmail: function(info) {60 startService("add_email", info);61 },62 doStageEmail: function(info) {63 dialogHelpers.addSecondaryEmail.call(this, info.email, info.password, info.ready);64 },65 doConfirmEmail: function(info) {66 startRegCheckService.call(this, info, "waitForEmailValidation", "email_confirmed");67 },68 doAuthenticate: function(info) {69 startService("authenticate", info);70 },71 doAuthenticateWithUnverifiedEmail: function(info) {72 var self = this;73 dialogHelpers.authenticateUser.call(this, info.email, info.password,74 function() {75 self.publish("authenticated", info);76 });77 },78 doStageResetPassword: function(info) {79 dialogHelpers.resetPassword.call(this, info.email, info.ready);80 },81 doConfirmResetPassword: function(info) {82 startRegCheckService.call(this, info, "waitForPasswordResetComplete", "reset_password_confirmed");83 },84 doStageReverifyEmail: function(info) {85 dialogHelpers.reverifyEmail.call(this, info.email, info.ready);86 },87 doConfirmReverifyEmail: function(info) {88 startRegCheckService.call(this, info, "waitForEmailReverifyComplete", "reverify_email_confirmed");89 },90 doStageTransitionToSecondary: function(info) {91 dialogHelpers.transitionToSecondary.call(this, info.email,92 info.password, info.ready);93 },94 doConfirmTransitionToSecondary: function(info) {95 startRegCheckService.call(this, info,96 "waitForTransitionToSecondaryComplete",97 "transition_to_secondary_confirmed");98 },99 doCompleteSignIn: function(info) {100 info.ready = function() {101 onsuccess(info);102 };103 startService("complete_sign_in", info);104 },105 doNotMe: function() {106 var self=this;107 user.logoutUser(self.publish.bind(self, "logged_out"), self.getErrorDialog(errors.logoutUser));108 },109 doCheckAuth: function(info) {110 var self=this;111 info = info || {};112 user.checkAuthenticationAndSync(function (authenticated) {113 // Does the RP want us to force the user to authenticate?114 authenticated = info.forceAuthentication ? false : authenticated;115 self.publish("authentication_checked", {116 authenticated: authenticated117 });118 }, self.getErrorDialog(errors.checkAuthentication));119 },120 doProvisionPrimaryUser: function(info) {121 startService("provision_primary_user", info);122 },123 doVerifyPrimaryUser: function(info) {124 startService("verify_primary_user", info);125 },126 doPrimaryUserProvisioned: function(info) {127 startService("primary_user_provisioned", info);128 },129 doPrimaryUserNotProvisioned: function(info) {130 startService("primary_user_not_provisioned", info);131 },132 doPrimaryOffline: function(info) {133 startService("primary_offline", info);134 },135 doIsThisYourComputer: function(info) {136 startService("is_this_your_computer", info);137 },138 doGenerateAssertion: function(info) {139 startService("generate_assertion", info);140 },141 doRPInfo: function(info) {142 startService("rp_info", info);143 }144 });145 sc = Module.sc;146 return Module;...
nom.comp.info.js
Source:nom.comp.info.js
1import React from "react";2import moment from "moment";3import Countdown from "../../../components/countdown/countdown";4const CompInfo = (props) => {5 if(!props.compInfo) return null;6 var info = props.compInfo;7 var date = moment(info.startDate).locale("uk").format("DD MMM") + "-" + moment(info.endDate).locale("uk").format("DD MMM") + ", " + moment(info.endDate).format("YYYY");8 var p = (new Date(info.startDate)).setDate((new Date(info.startDate)).getDate() - 30);9 var f = (new Date(info.startDate)).setDate((new Date(info.startDate)).getDate() - 15);10 var bm7 = (new Date(info.startDate)).setDate((new Date(info.startDate)).getDate() - 10);11 var mc = (new Date(info.startDate)).setDate((new Date(info.startDate)).getDate());12 var status = null;13 var statusColor = null;14 var statusEnd = null;15 if((+new Date()) <= p){16 status = "ÐопеÑÐµÐ´Ð½Ñ Ð½Ð¾Ð¼ÑнаÑÑÑ";17 statusColor = "#7AB800";18 var statusEnd = p;19 }else if(p < (+new Date()) && (+new Date()) <= f){20 status = "ФÑналÑна номÑнаÑÑÑ";21 statusColor = "#0582FF";22 var statusEnd = f;23 }else if(f < (+new Date()) && (+new Date()) <= mc){24 status = "ÐеÑед мандаÑÐ½Ð¾Ñ ÐºÐ¾Ð¼ÑÑÑÑÑ";25 statusColor = "#CC0033";26 var statusEnd = mc;27 }else{28 status = "ÐÑÑ
Ñв";29 statusColor = "#8E8E48";30 } 31 const pLabel = moment(p).subtract(1, "day").locale("uk").format("DD.MM.YYYY")32 const fLabel = moment(f).subtract(1, "day").locale("uk").format("DD.MM.YYYY")33 const bm7Label = moment(bm7).locale("uk").format("DD.MM.YYYY")34 const mcLabel = moment(mc).locale("uk").format("DD.MM.YYYY") 35 return (<div>36 <div className="comp-info-header">37 <p className="info-title">{info.name}</p>38 <p className="info-location">{info.location}</p>39 <p className="info-date">{date}</p>40 </div>41 <div className="comp-info-status">42 <p className="status">СÑаÑÑÑ: <span style={{color: statusColor}}>{String(status).toUpperCase()}</span></p>43 <Countdown till={statusEnd} />44 <p>ÐÑÑаннÑй Ð´ÐµÐ½Ñ Ð¿Ð¾Ð¿ÐµÑеднÑÐ¾Ñ Ð½Ð¾Ð¼ÑнаÑÑÑ: {pLabel}</p>45 <p>ÐÑÑаннÑй Ð´ÐµÐ½Ñ ÑÑналÑÐ½Ð¾Ñ Ð½Ð¾Ð¼ÑнаÑÑÑ: {fLabel}</p>46 <p>10 днÑв до мандаÑÐ½Ð¾Ñ ÐºÐ¾Ð¼ÑÑÑÑ: {bm7Label}</p>47 <p>ÐандаÑна комÑÑÑÑ: {mcLabel}</p>48 </div>49 </div>);50}...
comp.info.js
Source:comp.info.js
1import React from "react";2import moment from "moment";3import Countdown from "../../../components/countdown/countdown";4const CompInfo = (props) => {5 if(!props.compInfo) return null;6 var info = props.compInfo;7 var date = moment(info.startDate).locale("uk").format("DD MMM") + "-" + moment(info.endDate).locale("uk").format("DD MMM") + ", " + moment(info.endDate).format("YYYY");8 var p = (new Date(info.startDate)).setDate((new Date(info.startDate)).getDate() - 30);9 var f = (new Date(info.startDate)).setDate((new Date(info.startDate)).getDate() - 15);10 var bm7 = (new Date(info.startDate)).setDate((new Date(info.startDate)).getDate() - 10);11 var mc = (new Date(info.startDate)).setDate((new Date(info.startDate)).getDate());12 var status = null;13 var statusColor = null;14 var statusEnd = null;15 if((+new Date()) <= p){16 status = "ÐопеÑÐµÐ´Ð½Ñ Ð½Ð¾Ð¼ÑнаÑÑÑ";17 statusColor = "#7AB800";18 statusEnd = p;19 }else if(p < (+new Date()) && (+new Date()) <= f){20 status = "ФÑналÑна номÑнаÑÑÑ";21 statusColor = "#0582FF";22 statusEnd = f;23 }else if(f < (+new Date()) && (+new Date()) <= mc){24 status = "ÐеÑед мандаÑÐ½Ð¾Ñ ÐºÐ¾Ð¼ÑÑÑÑÑ";25 statusColor = "#CC0033";26 statusEnd = mc;27 }else{28 status = "ÐÑÑ
Ñв";29 statusColor = "#8E8E48";30 } 31 const pLabel = moment(p).subtract(1, "day").locale("uk").format("DD.MM.YYYY")32 const fLabel = moment(f).subtract(1, "day").locale("uk").format("DD.MM.YYYY")33 const bm7Label = moment(bm7).locale("uk").format("DD.MM.YYYY")34 const mcLabel = moment(mc).locale("uk").format("DD.MM.YYYY") 35 return (<div>36 <div className="comp-info-header">37 <p className="info-title">{info.name}</p>38 <p className="info-location">{info.location}</p>39 <p className="info-date">{date}</p>40 </div>41 <div className="comp-info-status">42 <p className="status">СÑаÑÑÑ: <span style={{color: statusColor}}>{String(status).toUpperCase()}</span></p>43 <Countdown till={statusEnd} />44 <p>ÐÑÑаннÑй Ð´ÐµÐ½Ñ Ð¿Ð¾Ð¿ÐµÑеднÑÐ¾Ñ Ð½Ð¾Ð¼ÑнаÑÑÑ: {pLabel}</p>45 <p>ÐÑÑаннÑй Ð´ÐµÐ½Ñ ÑÑналÑÐ½Ð¾Ñ Ð½Ð¾Ð¼ÑнаÑÑÑ: {fLabel}</p>46 <p>10 днÑв до мандаÑÐ½Ð¾Ñ ÐºÐ¾Ð¼ÑÑÑÑ: {bm7Label}</p>47 <p>ÐандаÑна комÑÑÑÑ: {mcLabel}</p>48 </div>49 </div>); 50}...
matrix.utils.spec.js
Source:matrix.utils.spec.js
1// utils2import MatrixUtils from 'utils/matrix.utils'3describe('MatrixUtils ç©éµå·¥å
·ç±»', () => {4 describe('buildXY ä¸åèµ·ç¹,ç»ç¹,åè¿åå·¦ä¸è§åå³ä¸è§ç2ç¹åæ ', () => {5 let selectInfo = {6 startCell: {7 X: 0,8 Y: 09 },10 endCell: {11 X: 0,12 Y: 013 }14 }15 it('ææ(0,0),(7,7) è¿å (0, 0),(7, 7)', () => {16 selectInfo.startCell.X = 017 selectInfo.startCell.Y = 018 selectInfo.endCell.X = 719 selectInfo.endCell.Y = 720 const result = MatrixUtils.buildXY(selectInfo.startCell, selectInfo.endCell)21 expect(result.startCell.X).to.be.equal(0);22 expect(result.startCell.Y).to.be.equal(0);23 expect(result.endCell.X).to.be.equal(7);24 expect(result.endCell.Y).to.be.equal(7);25 })26 it('ææ(0,7),(7,0) è¿å (0, 0),(7, 7)', () => {27 selectInfo.startCell.X = 028 selectInfo.startCell.Y = 029 selectInfo.endCell.X = 730 selectInfo.endCell.Y = 731 const result = MatrixUtils.buildXY(selectInfo.startCell, selectInfo.endCell)32 expect(result.startCell.X).to.be.equal(0);33 expect(result.startCell.Y).to.be.equal(0);34 expect(result.endCell.X).to.be.equal(7);35 expect(result.endCell.Y).to.be.equal(7);36 })37 it('ææ(7,7),(0,0) è¿å (0, 0),(7, 7)', () => {38 selectInfo.startCell.X = 039 selectInfo.startCell.Y = 040 selectInfo.endCell.X = 741 selectInfo.endCell.Y = 742 const result = MatrixUtils.buildXY(selectInfo.startCell, selectInfo.endCell)43 expect(result.startCell.X).to.be.equal(0);44 expect(result.startCell.Y).to.be.equal(0);45 expect(result.endCell.X).to.be.equal(7);46 expect(result.endCell.Y).to.be.equal(7);47 })48 it('ææ(7,0),(0,7) è¿å (0, 0),(7, 7)', () => {49 selectInfo.startCell.X = 050 selectInfo.startCell.Y = 051 selectInfo.endCell.X = 752 selectInfo.endCell.Y = 753 const result = MatrixUtils.buildXY(selectInfo.startCell, selectInfo.endCell)54 expect(result.startCell.X).to.be.equal(0);55 expect(result.startCell.Y).to.be.equal(0);56 expect(result.endCell.X).to.be.equal(7);57 expect(result.endCell.Y).to.be.equal(7);58 })59 })...
timer-test.js
Source:timer-test.js
1var vows = require("vows"),2 load = require("../load"),3 assert = require("../assert");4var suite = vows.describe("d3.timer");5suite.addBatch({6 "timer": {7 topic: load("event/timer").expression("d3.timer").document(),8 "with no delay": {9 topic: delay(),10 "first calls after 17 ms or less": function(info) {11 assert.inDelta(info.start - info.scheduled, 17, 20);12 },13 "calls until the function returns true": function(info) {14 assert.equal(info.count, 4);15 },16 "calls every 17 ms": function(info) {17 assert.inDelta(info.stop - info.start, 17 * 3, 20);18 }19 },20 "with a specified delay": {21 topic: delay(250),22 "first calls after the delay": function(info) {23 assert.inDelta(info.start - info.scheduled, 250, 20);24 },25 "calls until the function returns true": function(info) {26 assert.equal(info.count, 4);27 },28 "calls every 17 ms": function(info) {29 assert.inDelta(info.stop - info.start, 17 * 3, 20);30 }31 }32 }33});34function delay(delay) {35 var args = Array.prototype.slice.call(arguments);36 return function(timer) {37 var cb = this.callback,38 info = {scheduled: Date.now(), count: 0};39 args.unshift(function() {40 var count = ++info.count;41 if (count === 1) {42 info.start = Date.now();43 } else if (count === 4) {44 info.stop = Date.now();45 cb(null, info);46 return true;47 }48 });49 timer.apply(this, args);50 };51}...
Using AI Code Generation
1describe('My First Test', () => {2 it('Does not do much!', () => {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('
Using AI Code Generation
1describe('My First Test', () => {2 it('Does not do much!', () => {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 cy.contains('type').click()4 cy.url().should('include', '/commands/actions')5 cy.get('.action-email')6 .type('
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 })4})5describe('My First Test', function() {6 it('Does not do much!', function() {7 })8})
Using AI Code Generation
1describe("Test", () => {2 it("test", () => {3 cy.get("input.gLFyf.gsfi").type("Cypress");4 cy.get("input.gNO89b").click();5 cy.get("h3").should("contain", "Cypress");6 });7});8describe("Test", () => {9 it("test", () => {10 cy.get("input.gLFyf.gsfi").type("Cypress");11 cy.get("input.gNO89b").click();12 cy.get("h3").should("contain", "Cypress");13 });14});15Cypress.io – API Reference – cy.visit()16Cypress.io – API Reference – cy.get()17Cypress.io – API Reference – cy.should()18Cypress.io – API Reference – cy.start()19Cypress.io – API Reference – cy.end()20Cypress.io – API Reference – cy.log()21Cypress.io – API Reference – cy.task()22Cypress.io – API Reference – cy.exec()23Cypress.io – API Reference – cy.writeFile()24Cypress.io – API Reference – cy.readFile()25Cypress.io – API Reference – cy.fixture()26Cypress.io – API Reference – cy.clearLocalStorage()27Cypress.io – API Reference – cy.clearCookies()28Cypress.io – API Reference – cy.clearLocalStorage()
Using AI Code Generation
1describe('Test', () => {2 it('test', () => {3 cy.wait(10000)4 cy.get('.gLFyf').type('test')5 })6})7describe('Test', () => {8 it('test', () => {9 cy.wait(10000)10 cy.get('.gLFyf').type('test')11 cy.wait(10000)12 })13})14describe('Test', () => {15 it('test', () => {16 cy.wait(10000)17 cy.get('.gLFyf').type('test')18 cy.wait(10000)19 cy.get('.gLFyf').type('test')20 })21})22describe('Test', () => {23 it('test', () => {24 cy.wait(10000)25 cy.get('.gLFyf').type('test')26 cy.wait(10000)27 cy.get('.gLFyf').type('test')28 cy.wait(10000)29 })30})31describe('Test', () => {32 it('test', () => {33 cy.wait(10000)34 cy.get('.gLFyf').type('test')35 cy.wait(10000)36 cy.get('.gLFyf').type('test')37 cy.wait(10000)38 cy.get('.gLFyf').type('test')39 })40})41describe('Test', () => {42 it('test', () => {43 cy.wait(10000)44 cy.get('.gLFyf').type('test')45 cy.wait(10000)46 cy.get('.gLFyf').type('test')47 cy.wait(10000)48 cy.get('.gLFyf').type('test')49 cy.wait(10000)50 })51})52describe('Test', () => {53 it('
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.
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.
Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.
Get 100 minutes of automation test minutes FREE!!