Best JavaScript code snippet using cypress
click.js
Source:click.js
1const counter = document.querySelector('.counte_guests');2const c1 = document.querySelector('#counter1');3const c2 = document.querySelector('#counter2');4const c3 = document.querySelector('#counter3');5const plus1 = document.querySelector('.circle_drop_plus1'); 6const plus2 = document.querySelector('.circle_drop_plus2'); 7const plus3 = document.querySelector('.circle_drop_plus3'); 8const minus1 = document.querySelector('.circle_drop_minus1');9const minus2 = document.querySelector('.circle_drop_minus2');10const minus3 = document.querySelector('.circle_drop_minus3');11const clear = document.getElementById('clear');12var both = 0;13var old = 0;14var young = 0;15var strGuest = '';16var strBoth = '';17function plus(directPlus) {18 directPlus.addEventListener('click', () => {19 old += 1;20 if ( both === 0 ) {21 if ( old + young === 1 || old + young === 21 )22 {23 strGuest = 'รยณรยพรยรยรย';24 counter.value = `${old + young} ${strGuest}`;25 } else if ( old + young >= 2 && old + young <= 4 || old + young >= 22 && old + young <= 24) {26 strGuest = 'รยณรยพรยรยรย'27 counter.value = `${old + young} ${strGuest}`;28 } else {29 strGuest = 'รยณรยพรยรยรยตรยน';30 counter.value = `${old + young} ${strGuest}`;31 }32 } else {33 if ( old + young === 1 || old + young === 21 )34 {35 strGuest = 'รยณรยพรยรยรย';36 counter.value = `${old + young} ${strGuest} ${both} ${strBoth}`;37 } else if ( old + young >= 2 && old + young <= 4 || old + young >= 22 && old + young <= 24) {38 strGuest = 'รยณรยพรยรยรย'39 counter.value = `${old + young} ${strGuest} ${both} ${strBoth}`;40 } else {41 strGuest = 'รยณรยพรยรยรยตรยน';42 counter.value = `${old + young} ${strGuest} ${both} ${strBoth}`;43 }44 }45 c1.value = old;46 })47}48function minus(directMinus) {49 directMinus.addEventListener('click', () => {50 old -= 1;51 if (old<0) {52 old = 0;53 }54 if ( both === 0 ) {55 if ( old + young === 1 || old + young === 21 ) {56 strGuest = 'รยณรยพรยรยรย';57 counter.value = `${old + young} ${strGuest}`;58 } else if ( old + young >= 2 && old + young <= 4 || old + young >= 22 && old + young <= 24) {59 strGuest = 'รยณรยพรยรยรย'60 counter.value = `${old + young} ${strGuest}`;61 } else if ( old + young <= 0 ) {62 counter.value = '';63 c1.value = 0;64 } else {65 strGuest = 'รยณรยพรยรยรยตรยน';66 counter.value = `${old + young} ${strGuest}`;67 }68 } else {69 if ( old + young === 1 || old + young === 21 ) {70 strGuest = 'รยณรยพรยรยรย';71 counter.value = `${old + young} ${strGuest} ${both} ${strBoth}`;72 } else if ( old + young >= 2 && old + young <= 4 || old + young >= 22 && old + young <= 24) {73 strGuest = 'รยณรยพรยรยรย'74 counter.value = `${old + young} ${strGuest} ${both} ${strBoth}`;75 } else if ( old + young <= 0 ) {76 strGuest = '';77 counter.value = `${both} ${strBoth}`78 c1.value = 0;79 } else {80 strGuest = 'รยณรยพรยรยรยตรยน';81 counter.value = `${old + young} ${strGuest} ${both} ${strBoth}`;82 }83 }84 c1.value = old;85 })86}87function plusYoung(directPlus) {88 directPlus.addEventListener('click', () => {89 young += 1;90 if ( both === 0 ) {91 if ( old + young === 1 || old + young === 21 ) {92 strGuest = 'รยณรยพรยรยรย';93 counter.value = `${old + young} ${strGuest}`;94 } else if ( old + young >= 2 && old + young <= 4 || old + young >= 22 && old + young <= 24) {95 strGuest = 'รยณรยพรยรยรย';96 counter.value = `${old + young} ${strGuest}`;97 } else {98 strGuest = 'รยณรยพรยรยรยตรยน';99 counter.value = `${old + young} ${strGuest}`;100 }101 } else {102 if ( old + young === 1 || old + young === 21 ) {103 strGuest = 'รยณรยพรยรยรย';104 counter.value = `${old + young} ${strGuest} ${both} ${strBoth}`;105 } else if ( old + young >= 2 && old + young <= 4 || old + young >= 22 && old + young <= 24) {106 strGuest = 'รยณรยพรยรยรย';107 counter.value = `${old + young} ${strGuest} ${both} ${strBoth}`;108 } else {109 strGuest = 'รยณรยพรยรยรยตรยน';110 counter.value = `${old + young} ${strGuest} ${both} ${strBoth}`;111 }112 }113 c2.value = young;114 })115}116function minusYoung(directMinus) {117 directMinus.addEventListener('click', () => {118 young -= 1;119 if ( young < 0 ) {120 young = 0;121 }122 if ( both === 0 ) {123 if ( old + young === 1 || old + young === 21 ) {124 strGuest = 'รยณรยพรยรยรย';125 counter.value = `${old + young} ${strGuest}`;126 } else if ( old + young >= 2 && old + young <= 4 || old + young >= 22 && old + young <= 24) {127 strGuest = 'รยณรยพรยรยรย'128 counter.value = `${old + young} ${strGuest}`;129 } else if ( old + young <= 0) {130 counter.value = '';131 c2.value = 0;132 } else {133 counter.value = `${old + young} ${strGuest}`;134 }135 } else {136 if ( old + young === 1 || old + young === 21 ) {137 strGuest = 'รยณรยพรยรยรย';138 counter.value = `${old + young} ${strGuest} ${both} ${strBoth}`;139 } else if ( old + young >= 2 && old + young <= 4 || old + young >= 22 && old + young <= 24) {140 strGuest = 'รยณรยพรยรยรย'141 counter.value = `${old + young} ${strGuest} ${both} ${strBoth}`;142 } else if ( old + young <= 0) {143 strGuest = '';144 counter.value = `${both} ${strBoth}`145 c2.value = 0;146 } else {147 strGuest = 'รยณรยพรยรยรยตรยน'148 counter.value = `${old + young} ${strGuest} ${both} ${strBoth}`;149 }150 }151 c2.value = young;152 })153}154function plusBoth(directMinus) {155 directMinus.addEventListener('click', () => {156 both += 1;157 if ( old + young === 0 ) {158 if ( both === 1 || both === 21 ) {159 strBoth = 'รยผรยปรยฐรยดรยตรยฝรยตรย';160 counter.value = ` ${both} ${strBoth}`;161 } else if ( both >= 2 && both <= 4 || both >= 22 && both <= 24 ) {162 strBoth = 'รยผรยปรยฐรยดรยตรยฝรยตรยรยฐ';163 counter.value = ` ${both} ${strBoth}`;164 } else {165 strBoth = 'รยผรยปรยฐรยดรยตรยฝรยตรยรยตรยฒ';166 counter.value = ` ${both} ${strBoth}`;167 }168 }169 else { 170 if ( both === 1 || both === 21 ) {171 strBoth = 'รยผรยปรยฐรยดรยตรยฝรยตรย';172 counter.value = `${old + young} ${strGuest}`;173 counter.value += ` ${both} ${strBoth}`;174 } else if ( both >= 2 && both <= 4 || both >= 22 && both <= 24 ) {175 strBoth = 'รยผรยปรยฐรยดรยตรยฝรยตรยรยฐ';176 counter.value = `${old + young} ${strGuest}`;177 counter.value += ` ${both} ${strBoth}`;178 } else {179 strBoth = 'รยผรยปรยฐรยดรยตรยฝรยตรยรยตรยฒ';180 counter.value = `${old + young} ${strGuest}`;181 counter.value += ` ${both} ${strBoth}`;182 }183 }184 c3.value = both;185 })186}187function minusBoth(directMinus) {188 directMinus.addEventListener('click', () => {189 both -= 1;190 if ( both <= 0 ) {191 both = 0;192 }193 if ( old + young === 0 ) {194 if ( both === 1 || both === 21 ) {195 strBoth = 'รยผรยปรยฐรยดรยตรยฝรยตรย';196 counter.value = ` ${both} ${strBoth}`;197 } else if ( both >= 2 && both <= 4 || both >= 22 && both <= 24 ) {198 strBoth = 'รยผรยปรยฐรยดรยตรยฝรยตรยรยฐ';199 counter.value = ` ${both} ${strBoth}`;200 } else if ( both <= 0 ) {201 both = 0;202 strBoth = '';203 counter.value = '';204 c3.value = both;205 } else {206 strBoth = 'รยผรยปรยฐรยดรยตรยฝรยตรยรยตรยฒ';207 counter.value = ` ${both} ${strBoth}`;208 }209 }210 else {211 if ( both === 1 || both === 21 ) {212 strBoth = 'รยผรยปรยฐรยดรยตรยฝรยตรย';213 counter.value = `${old + young} ${strGuest}`;214 counter.value += ` ${both} ${strBoth}`;215 } else if ( young + old === 0 ) {216 counter.value = `${both} ${strBoth}`;217 } else if ( both >= 2 && both <= 4 || both >= 22 && both <= 24 ) {218 strBoth = 'รยผรยปรยฐรยดรยตรยฝรยตรยรยฐ';219 counter.value = `${old + young} ${strGuest}`;220 counter.value += ` ${both} ${strBoth}`;221 } else if ( both <= 0 ) {222 counter.value = `${old + young} ${strGuest}`;223 c3.value = 0;224 } else {225 strBoth = 'รยผรยปรยฐรยดรยตรยฝรยตรยรยตรยฒ';226 counter.value = `${old + young} ${strGuest}`;227 counter.value += ` ${both} ${strBoth}`;228 }229 }230 231 c3.value = both;232 })233}234clear.onclick = function() {235 old = 0;236 young = 0;237 both = 0;238 strGuest = '';239 strBoth = '';240}241plus(plus1);242minus(minus1);243plusYoung(plus2);244minusYoung(minus2);245plusBoth(plus3);...
ld-customize-preview.js
Source:ld-customize-preview.js
1/โ**2 * Update Learn Dash Customizer settings live.3 *4 * @version 1.0.05 * 6 * @since 2.07 */โ8( function( $ ) {9 /โ/โ Declare vars10 var api = wp.customize;11 12 /โ/โ Both Sidebars - Learn Dash Global13 api( 'ocean_ld_global_both_sidebars_content_width', function( value ) {14 value.bind( function( to ) {15 var $child = $( '.customizer-ocean_ld_global_both_sidebars_content_width' );16 if ( to ) {17 var style = '<style class="customizer-ocean_ld_global_both_sidebars_content_width">@media only screen and (min-width: 960px){ body.ld-global-layout.content-both-sidebars .content-area { width: ' + to + '%; } body.ld-global-layout.content-both-sidebars.scs-style .widget-area.sidebar-secondary, body.ld-global-layout.content-both-sidebars.ssc-style .widget-area {left: -' + to + '%;} }</โstyle>';18 if ( $child.length ) {19 $child.replaceWith( style );20 } else {21 $( 'head' ).append( style );22 }23 } else {24 $child.remove();25 }26 } );27 }),28 api( 'ocean_ld_global_both_sidebars_sidebars_width', function( value ) {29 value.bind( function( to ) {30 var $child = $( '.customizer-ocean_ld_global_both_sidebars_sidebars_width' );31 if ( to ) {32 var style = '<style class="customizer-ocean_ld_global_both_sidebars_sidebars_width">@media only screen and (min-width: 960px){ body.ld-global-layout.content-both-sidebars .widget-area{width:' + to + '%;} body.ld-global-layout.content-both-sidebars.scs-style .content-area{left:' + to + '%;} body.ld-global-layout.content-both-sidebars.ssc-style .content-area{left:'+ to * 2 +'%;} }</โstyle>';33 if ( $child.length ) {34 $child.replaceWith( style );35 } else {36 $( 'head' ).append( style );37 }38 } else {39 $child.remove();40 }41 } );42 }),43 /โ/โ Both Sidebars - Learn Dash Course44 api( 'ocean_ld_course_both_sidebars_content_width', function( value ) {45 value.bind( function( to ) {46 var $child = $( '.customizer-ocean_ld_course_both_sidebars_content_width' );47 if ( to ) {48 var style = '<style class="customizer-ocean_ld_course_both_sidebars_content_width">@media only screen and (min-width: 960px){ body.single-course.content-both-sidebars .content-area { width: ' + to + '%; } body.single-course.content-both-sidebars.scs-style .widget-area.sidebar-secondary, body.single-course.content-both-sidebars.ssc-style .widget-area {left: -' + to + '%;} }</โstyle>';49 if ( $child.length ) {50 $child.replaceWith( style );51 } else {52 $( 'head' ).append( style );53 }54 } else {55 $child.remove();56 }57 } );58 }),59 api( 'ocean_ld_course_both_sidebars_sidebars_width', function( value ) {60 value.bind( function( to ) {61 var $child = $( '.customizer-ocean_ld_course_both_sidebars_sidebars_width' );62 if ( to ) {63 var style = '<style class="customizer-ocean_ld_course_both_sidebars_sidebars_width">@media only screen and (min-width: 960px){ body.single-course.content-both-sidebars .widget-area{width:' + to + '%;} body.single-course.content-both-sidebars.scs-style .content-area{left:' + to + '%;} body.single-course.content-both-sidebars.ssc-style .content-area{left:'+ to * 2 +'%;} }</โstyle>';64 if ( $child.length ) {65 $child.replaceWith( style );66 } else {67 $( 'head' ).append( style );68 }69 } else {70 $child.remove();71 }72 } );73 }),74 /โ/โ Both Sidebars - Learn Dash Lesson75 api( 'ocean_ld_lesson_both_sidebars_content_width', function( value ) {76 value.bind( function( to ) {77 var $child = $( '.customizer-ocean_ld_lesson_both_sidebars_content_width' );78 if ( to ) {79 var style = '<style class="customizer-ocean_ld_lesson_both_sidebars_content_width">@media only screen and (min-width: 960px){ body.single-lesson.content-both-sidebars .content-area { width: ' + to + '%; } body.single-lesson.content-both-sidebars.scs-style .widget-area.sidebar-secondary, body.single-lesson.content-both-sidebars.ssc-style .widget-area {left: -' + to + '%;} }</โstyle>';80 if ( $child.length ) {81 $child.replaceWith( style );82 } else {83 $( 'head' ).append( style );84 }85 } else {86 $child.remove();87 }88 } );89 }),90 api( 'ocean_ld_lesson_both_sidebars_sidebars_width', function( value ) {91 value.bind( function( to ) {92 var $child = $( '.customizer-ocean_ld_lesson_both_sidebars_sidebars_width' );93 if ( to ) {94 var style = '<style class="customizer-ocean_ld_lesson_both_sidebars_sidebars_width">@media only screen and (min-width: 960px){ body.single-lesson.content-both-sidebars .widget-area{width:' + to + '%;} body.single-lesson.content-both-sidebars.scs-style .content-area{left:' + to + '%;} body.single-lesson.content-both-sidebars.ssc-style .content-area{left:'+ to * 2 +'%;} }</โstyle>';95 if ( $child.length ) {96 $child.replaceWith( style );97 } else {98 $( 'head' ).append( style );99 }100 } else {101 $child.remove();102 }103 } );104 }), api("ocean_ld_heading_color", function($swipe) {105 $swipe.bind(function(size) {106 $("#learndash_lessons #lesson_heading, #learndash_profile .learndash_profile_heading, #learndash_quizzes #quiz_heading, #learndash_lesson_topics_list div > strong").css("color", size);107 });108 }), api("ocean_ld_heading_bg_color", function($swipe) {109 $swipe.bind(function(size) {110 $("#learndash_lessons #lesson_heading, #learndash_profile .learndash_profile_heading, #learndash_quizzes #quiz_heading, #learndash_lesson_topics_list div > strong").css("background-color", size);111 });112 }), api("ocean_ld_item_color", function($swipe) {113 $swipe.bind(function(size) {114 $("#lessons_list > div h4 a, #course_list > div h4 a, #quiz_list > div h4 a, .learndash_topic_dots a, .learndash_topic_dots a > span, #learndash_lesson_topics_list span a").css("color", size);115 });116 }), api("ocean_ld_item_hover_color", function($swipe) {117 $swipe.bind(function(to) {118 var $child = $(".customizer-ocean_ld_item_hover_color");119 if (to) {120 /โ** @type {string} */โ121 var img = '<style class="customizer-ocean_ld_item_hover_color">#lessons_list > div h4 a:hover, #lessons_list > div h4 a:hover > span, #course_list > div h4 a:hover, #course_list > div h4 a:hover > span, #quiz_list > div h4 a:hover, #quiz_list > div h4 a:hover > span, .learndash_topic_dots a:hover, .learndash_topic_dots a:hover span, #learndash_lesson_topics_list span a:hover{ color: ' + to + "; }</โstyle>";122 if ($child.length) {123 $child.replaceWith(img);124 } else {125 $("head").append(img);126 }127 } else {128 $child.remove();129 }130 });131 }), api("ocean_ld_complete_color", function($swipe) {132 $swipe.bind(function(size) {133 $(".learndash_navigation_lesson_topics_list .topic-completed span:before, .learndash_navigation_lesson_topics_list ul .topic-completed span:before, .learndash_topic_dots .topic-completed span:before, .learndash_topic_dots ul .topic-completed span:before, .learndash .completed:before, #learndash_profile .completed:before").css("color", size);134 });135 }), api("ocean_ld_incomplete_color", function($swipe) {136 $swipe.bind(function(size) {137 $(".learndash_navigation_lesson_topics_list .topic-notcompleted span:before, .learndash_navigation_lesson_topics_list ul .topic-notcompleted span:before, .learndash_topic_dots .topic-notcompleted span:before, .learndash_topic_dots ul .topic-notcompleted span:before, .learndash .notcompleted:before, #learndash_profile .notcompleted:before").css("color", size);138 });139 }), api("ocean_ld_progressbar_color", function($swipe) {140 $swipe.bind(function(size) {141 $("dd.course_progress div.course_progress_blue").css("color", size);142 });143 });...
conflict.js
Source:conflict.js
1require('should');2const Immutable = require('immutable');3const repofs = require('../โsrc/โ');4const ConflictUtils = require('../โsrc/โutils/โconflict');5const TreeEntry = require('../โsrc/โmodels/โtreeEntry');6const TreeConflict = repofs.TreeConflict;7const Conflict = repofs.Conflict;8const WorkingState = repofs.WorkingState;9describe('ConflictUtils', () => {10 const parentEntries = new Immutable.Map({11 bothDeleted: entry('bothDeleted'),12 bothModified: entry('bothModified-parent'), /โ/โ conflict13 deletedBase: entry('deletedBase'),14 /โ/โ Deleted by base, modified by parent15 deletedModified: entry('deletedModified-parent'), /โ/โ conflict16 modifiedBase: entry('modifiedBase-parent'),17 unchanged: entry('unchanged')18 });19 const baseEntries = new Immutable.Map({20 addedBase: entry('addedBase'),21 bothAddedDifferent: entry('bothAddedDifferent-base'), /โ/โ conflict22 bothAddedSame: entry('bothAddedSame'),23 bothModified: entry('bothModified-base'), /โ/โ conflict24 modifiedBase: entry('modifiedBase-base'),25 unchanged: entry('unchanged')26 });27 const headEntries = new Immutable.Map({28 bothAddedDifferent: entry('bothAddedDifferent-head'), /โ/โ conflict29 bothAddedSame: entry('bothAddedSame'),30 bothModified: entry('bothModified-head'), /โ/โ conflict31 deletedBase: entry('deletedBase'),32 deletedModified: entry('deletedModified-head'), /โ/โ conflict33 modifiedBase: entry('modifiedBase-parent'),34 unchanged: entry('unchanged')35 });36 const parentWK = WorkingState.createWithTree('parentWK', parentEntries);37 const headWK = WorkingState.createWithTree('headWK', headEntries);38 const baseWK = WorkingState.createWithTree('baseWK', baseEntries);39 const CONFLICTS = {40 bothModified: new Conflict({41 parentSha: 'bothModified-parent',42 baseSha: 'bothModified-base',43 headSha: 'bothModified-head'44 }),45 bothAddedDifferent: new Conflict({46 parentSha: null,47 baseSha: 'bothAddedDifferent-base',48 headSha: 'bothAddedDifferent-head'49 }),50 deletedModified: new Conflict({51 parentSha: 'deletedModified-parent',52 baseSha: null,53 headSha: 'deletedModified-head'54 })55 };56 const treeConflict = new TreeConflict({57 base: baseWK,58 head: headWK,59 parent: parentWK,60 conflicts: new Immutable.Map(CONFLICTS)61 });62 /โ/โ The list of solved conflicts, as returned after resolution63 const solvedConflicts = treeConflict.getConflicts().merge({64 bothModified: CONFLICTS.bothModified.solveWithContent('Solved content'),65 /โ/โ bothAddedDifferent not solved, should default to keep base in the end66 deletedModified: CONFLICTS.deletedModified.keepHead()67 });68 /โ/โ ---- TESTS ----69 describe('._diffEntries', () => {70 it('should detect modified entries, added entries, and deleted entries', () => {71 const result = ConflictUtils._diffEntries(parentEntries, baseEntries);72 const expectedDiff = new Immutable.Map({73 addedBase: entry('addedBase'),74 bothAddedDifferent: entry('bothAddedDifferent-base'),75 bothAddedSame: entry('bothAddedSame'),76 bothDeleted: null,77 bothModified: entry('bothModified-base'),78 deletedBase: null,79 deletedModified: null,80 modifiedBase: entry('modifiedBase-base')81 });82 Immutable.is(result, expectedDiff).should.be.true();83 });84 });85 describe('._compareTrees', () => {86 it('should detect minimum set of conflicts', () => {87 const result = ConflictUtils._compareTrees(parentEntries, baseEntries, headEntries);88 const expected = treeConflict.getConflicts();89 Immutable.is(result, expected).should.be.true();90 });91 });92 describe('.solveTree', () => {93 it('should merge back solved conflicts into a TreeConflict, defaulting to base version', () => {94 const solvedTreeConflict = ConflictUtils.solveTree(treeConflict, solvedConflicts);95 /โ/โ Expect tree to be unchanged outside of conflicts96 Immutable.is(solvedTreeConflict.set('conflicts', null),97 treeConflict.set('conflicts', null));98 /โ/โ Expect conflicts to be solved99 const expected = solvedConflicts.set('bothAddedDifferent',100 CONFLICTS.bothAddedDifferent.keepBase());101 const result = solvedTreeConflict.getConflicts();102 Immutable.is(result, expected).should.be.true();103 });104 });105 describe('._getSolvedEntries', () => {106 it('should generate the solved tree entries', () => {107 const solvedTreeConflict = ConflictUtils.solveTree(treeConflict, solvedConflicts);108 const result = ConflictUtils._getSolvedEntries(solvedTreeConflict);109 const expected = new Immutable.Map({110 deletedModified: entry('deletedModified-head'), /โ/โ keeped head111 bothAddedSame: entry('bothAddedSame'),112 bothModified: entry(null), /โ/โ solved with content113 addedBase: entry('addedBase'),114 bothAddedDifferent: entry('bothAddedDifferent-base'), /โ/โ keeped base115 modifiedBase: entry('modifiedBase-base'),116 unchanged: entry('unchanged')117 });118 Immutable.is(result, expected).should.be.true();119 });120 });121 describe('.mergeCommit', () => {122 const solvedTreeConflict = ConflictUtils.solveTree(treeConflict, solvedConflicts);123 const mergeCommit = ConflictUtils.mergeCommit(solvedTreeConflict, [124 'parentCommitSha1',125 'parentCommitSha2'126 ], {127 author: 'Shakespeare'128 });129 it('should create a merge CommitBuilder with two parents', () => {130 mergeCommit.getParents().toJS().should.eql([131 'parentCommitSha1',132 'parentCommitSha2'133 ]);134 });135 it('should create a merge CommitBuilder with an author', () => {136 mergeCommit.getAuthor().should.eql('Shakespeare');137 });138 it('should create a merge CommitBuilder with solved content as blob', () => {139 mergeCommit.getBlobs().get('bothModified').getAsString().should.eql('Solved content');140 mergeCommit.getBlobs().count().should.eql(1);141 });142 it('should create a merge CommitBuilder with final solved entries', () => {143 const solvedEntries = new Immutable.Map({144 deletedModified: entry('deletedModified-head'), /โ/โ keeped head145 bothAddedSame: entry('bothAddedSame'),146 bothModified: entry(null), /โ/โ solved with content147 addedBase: entry('addedBase'),148 bothAddedDifferent: entry('bothAddedDifferent-base'), /โ/โ keeped base149 modifiedBase: entry('modifiedBase-base'),150 unchanged: entry('unchanged')151 });152 Immutable.is(mergeCommit.getTreeEntries(), solvedEntries).should.be.true();153 });154 });155});156/โ/โ ---- Utils ----157function entry(sha) {158 return new TreeEntry({ sha });...
register.js
Source:register.js
1import {Navigation} from 'react-native-navigation';2import {mainScreens,miscellaneousScreens} from '../โconfigs/โnavigator';3import {reduxProvider} from '../โconfig-store';4Navigation.setLazyComponentRegistrator((componentName) => {5 Navigation.registerComponent(componentName, () => reduxProvider(miscellaneousScreens[componentName]),()=>miscellaneousScreens[componentName])6});7export function registerMainScreens () {8 Object.keys (mainScreens).map (Component => {9 Navigation.registerComponent (10 Component,11 () => reduxProvider (mainScreens[Component]),12 () => mainScreens[Component]13 );14 });15}16/โ/โ export function registerMiscellaneousScreens () {17/โ/โ Object.keys (miscellaneousScreens).map (Component => {18/โ/โ Navigation.registerComponent (19/โ/โ Component,20/โ/โ () => reduxProvider (miscellaneousScreens[Component]),21/โ/โ () => miscellaneousScreens[Component]22/โ/โ );23/โ/โ });24/โ/โ }25/โ*****26 * setDefault() need to be applied before setting setRoot()27 * if we need to update theme we can use processor or setDefaults() again28 * with changed values and re set setRoot()29 * 30 * 31 * These are the options set which can be used in Navigation.mergeOptions(componentID,{OPTIONS});32 * according to type33 * 34 * 35 ****/โ36export function setDefault() {37 Navigation.setDefaultOptions({38 /โ**39 * Status bar options40 */โ41 statusBar: {42 style:'light', /โ/โboth43 drawBehind:false, /โ/โandroid44 visible: true, /โ/โboth45 translucent:false, /โ/โandroid46 /โ/โ backgroundColor: statusBarBgColor, /โ/โandroid47 },48 /โ***49 * Top bar of stack50 * Options51 */โ52 topBar: {53 animate: true, /โ/โboth54 visible: false, /โ/โboth55 /โ/โ drawBehind:'' /โ/โboth56 /โ/โ hideOnScroll:true, /โ/โboth57 58 /โ/โ elevation:10, /โ/โAndroid59 /โ/โ borderHeight:'', /โ/โAndroid60 61 noBorder:true, /โ/โiOS62 barStyle:'black', /โ/โiOS63 /โ/โ borderColor:'grey', /โ/โiOS64 searchBar:true, /โ/โiOS65 /โ/โ searchBarHiddenWhenScrolling:false, /โ/โiOS66 /โ/โ searchBarPlaceholder:'Search here...', /โ/โiOS67 /โ/โ hideNavBarOnFocusSearchBar:true, /โ/โiOS68 69 70 title: {71 /โ/โ text: 'Home', /โ/โboth72 fontSize: 20, /โ/โboth73 fontWeight: 20, /โ/โboth74 /โ/โ fontFamily:'', /โ/โboth75 color: 'grey', /โ/โboth76 /โ/โ component:'', /โ/โboth77 visible:false, /โ/โboth78 79 /โ/โ topMargin:10, /โ/โandroid80 81 /โ/โ alignment:'center', /โ/โfill is for android & center is for iOS,82 },83 84 /โ/โ subtitle: {85 /โ/โ text: 'Home Sub', /โ/โboth86 /โ/โ fontSize: 20, /โ/โboth87 /โ/โ fontWeight: 200, /โ/โboth88 /โ/โ /โ/โ fontFamily:'', /โ/โboth89 /โ/โ color: 'grey', /โ/โboth90 /โ/โ alignment: 'center', /โ/โboth91 /โ/โ visible:false,92 /โ/โ },93 94 background: {95 /โ/โ color:'grey', /โ/โboth96 /โ/โ component:'', /โ/โboth97 98 /โ/โ clipToBounds:true, /โ/โiOS99 /โ/โ translucent:true, /โ/โiOS100 /โ/โ blur:true, /โ/โiOS101 },102 103 backButton: {104 color:'grey', /โ/โboth105 /โ/โ icon:'', /โ/โboth106 /โ/โ visible:false, /โ/โboth107 108 showTitle:true, /โ/โiOS109 /โ/โ title:'Title', /โ/โiOS110 },111 112 leftButtonColor: 'grey', /โ/โboth113 114 leftButtons:{115 allCaps:false, /โ/โboth116 fontSize:20, /โ/โboth117 /โ/โ icon:'', /โ/โboth118 /โ/โ text:'jj', /โ/โboth119 /โ/โ component:'', /โ/โboth120 /โ/โ showAsAction:'', /โ/โandroid121 /โ/โ iconInsets:{ /โ/โiOS122 /โ/โ left:'',123 /โ/โ right:'',124 /โ/โ top:'',125 /โ/โ bottom:'',126 /โ/โ },127 /โ/โ systemItem:1,/โ/โiOS , icon128 },129 130 rightButtonColor:'grey', /โ/โboth131 rightButtons:{132 allCaps: false, /โ/โboth133 fontSize: 20, /โ/โboth134 /โ/โ icon:'', /โ/โboth135 /โ/โ text:'jj', /โ/โboth136 /โ/โ component: '', /โ/โboth137 /โ/โ showAsAction:'', /โ/โandroid138 /โ/โ iconInsets:{ /โ/โiOS139 /โ/โ left:'',140 /โ/โ right:'',141 /โ/โ top:'',142 /โ/โ bottom:'',143 /โ/โ },144 /โ/โ systemItem:1,/โ/โiOS , icon145 },146 },147 148 /โ***149 * Bottom Tabs options150 */โ151 bottomTabs:{152 animate: true, /โ/โboth153 /โ/โ backgroundColor:'black', /โ/โboth154 /โ/โ barStyle:'black', /โ/โboth155 visible:true, /โ/โboth156 titleDisplayMode:'showWhenActive', /โ/โboth157 tabsAttachMode:'onSwitchToTab', /โ/โboth158 /โ/โ currentTabIndex:1, /โ/โboth159 /โ/โ currentTabId:1, /โ/โboth160 /โ/โ drawBehind:false, /โ/โboth161 162 preferLargeIcons:true, /โ/โandroid163 /โ/โ elevation:10, /โ/โandroid164 /โ/โ hideOnScroll:true, /โ/โandroid165 166 /โ/โ hideShadow:true, /โ/โiOS167 /โ/โ translucent:true, /โ/โiOS168 },169 /โ***170 * Bottom Tab options171 */โ172 bottomTab: {173 fontSize: 20, /โ/โboth174 /โ/โ fontFamily:'', /โ/โboth175 /โ/โ text:'', /โ/โboth176 textColor: 'grey', /โ/โboth177 iconColor: 'grey', /โ/โboth178 179 selectedTextColor: 'orange', /โ/โboth180 selectedIconColor: 'orange', /โ/โboth181 selectedFontSize: 20, /โ/โboth182 183 /โ/โ selectedIcon:3, /โ/โboth184 /โ/โ iconInsets:{ /โ/โboth185 /โ/โ left:3,186 /โ/โ right:100,187 /โ/โ top:70,188 /โ/โ bottom:90,189 /โ/โ },190 191 /โ/โ disableIconTint:true, /โ/โandroid192 /โ/โ disableSelectedIconTint:true, /โ/โandroid193 194 /โ/โ badge:1, /โ/โboth195 /โ/โ badgeColor:'red', /โ/โboth196 /โ/โ animateBadge:true, /โ/โandroid197 /โ/โ dotIndicator:{ /โ/โboth198 /โ/โ visible:true,199 /โ/โ color:'red',200 /โ/โ size:20,201 /โ/โ animate:true202 /โ/โ },203 },204 /โ*****205 * Navigation bar options206 */โ207 navigationBar:{ /โ/โandroid208 visible:true,209 /โ/โ backgroundColor:'red'210 },211 /โ***212 * Layout options213 */โ214 layout:{215 /โ/โ fitSystemWindows:true, /โ/โboth216 /โ/โ backgroundColor:'grey' /โ/โboth217 /โ/โ componentBackgroundColor:'grey', /โ/โboth218 /โ/โ orientation:'portrait' /โ/โboth219 /โ/โ topMargin:20, /โ/โandroid220 /โ/โ direction:'locale', /โ/โboth221 },222 223 /โ***224 * Overlay options225 */โ226 overlay: {227 /โ/โ interceptTouchOutside:false, /โ/โboth228 /โ/โ handleKeyboardEvents:true, /โ/โiOS229 },230 /โ***231 * SideMenu options232 */โ233 sideMenu: {234 openGestureMode: 'bezel', /โ/โboth235 left: { /โ/โboth236 enabled:true,237 visible:true, 238 /โ/โ width:20, 239 /โ/โ height:20,240 },241 right: { /โ/โboth242 enabled: false,243 visible: false,244 /โ/โ width: 20,245 /โ/โ height: 20,246 },247 },248 });...
samevalue.js
Source:samevalue.js
1/โ/โ Copyright 2010 the V8 project authors. All rights reserved.2/โ/โ Redistribution and use in source and binary forms, with or without3/โ/โ modification, are permitted provided that the following conditions are4/โ/โ met:5/โ/โ6/โ/โ * Redistributions of source code must retain the above copyright7/โ/โ notice, this list of conditions and the following disclaimer.8/โ/โ * Redistributions in binary form must reproduce the above9/โ/โ copyright notice, this list of conditions and the following10/โ/โ disclaimer in the documentation and/โor other materials provided11/โ/โ with the distribution.12/โ/โ * Neither the name of Google Inc. nor the names of its13/โ/โ contributors may be used to endorse or promote products derived14/โ/โ from this software without specific prior written permission.15/โ/โ16/โ/โ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS17/โ/โ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT18/โ/โ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR19/โ/โ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT20/โ/โ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,21/โ/โ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT22/โ/โ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,23/โ/โ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY24/โ/โ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT25/โ/โ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE26/โ/โ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.27/โ/โ Flags: --expose-natives-as natives28/โ/โ Test the SameValue and SameValueZero internal methods.29var obj1 = {x: 10, y: 11, z: "test"};30var obj2 = {x: 10, y: 11, z: "test"};31var sameValue = Object.is;32var sameValueZero = natives.ImportNow("SameValueZero");33/โ/โ Calls SameValue and SameValueZero and checks that their results match.34function sameValueBoth(a, b) {35 var result = sameValue(a, b);36 assertTrue(result === sameValueZero(a, b));37 return result;38}39/โ/โ Calls SameValue and SameValueZero and checks that their results don't match.40function sameValueZeroOnly(a, b) {41 var result = sameValueZero(a, b);42 assertTrue(result && !sameValue(a, b));43 return result;44}45assertTrue(sameValueBoth(0, 0));46assertTrue(sameValueBoth(+0, +0));47assertTrue(sameValueBoth(-0, -0));48assertTrue(sameValueBoth(1, 1));49assertTrue(sameValueBoth(2, 2));50assertTrue(sameValueBoth(-1, -1));51assertTrue(sameValueBoth(0.5, 0.5));52assertTrue(sameValueBoth(true, true));53assertTrue(sameValueBoth(false, false));54assertTrue(sameValueBoth(NaN, NaN));55assertTrue(sameValueBoth(null, null));56assertTrue(sameValueBoth("foo", "foo"));57assertTrue(sameValueBoth(obj1, obj1));58/โ/โ Undefined values.59assertTrue(sameValueBoth());60assertTrue(sameValueBoth(undefined, undefined));61assertFalse(sameValueBoth(0,1));62assertFalse(sameValueBoth("foo", "bar"));63assertFalse(sameValueBoth(obj1, obj2));64assertFalse(sameValueBoth(true, false));65assertFalse(sameValueBoth(obj1, true));66assertFalse(sameValueBoth(obj1, "foo"));67assertFalse(sameValueBoth(obj1, 1));68assertFalse(sameValueBoth(obj1, undefined));69assertFalse(sameValueBoth(obj1, NaN));70assertFalse(sameValueBoth(undefined, true));71assertFalse(sameValueBoth(undefined, "foo"));72assertFalse(sameValueBoth(undefined, 1));73assertFalse(sameValueBoth(undefined, obj1));74assertFalse(sameValueBoth(undefined, NaN));75assertFalse(sameValueBoth(NaN, true));76assertFalse(sameValueBoth(NaN, "foo"));77assertFalse(sameValueBoth(NaN, 1));78assertFalse(sameValueBoth(NaN, obj1));79assertFalse(sameValueBoth(NaN, undefined));80assertFalse(sameValueBoth("foo", true));81assertFalse(sameValueBoth("foo", 1));82assertFalse(sameValueBoth("foo", obj1));83assertFalse(sameValueBoth("foo", undefined));84assertFalse(sameValueBoth("foo", NaN));85assertFalse(sameValueBoth(true, 1));86assertFalse(sameValueBoth(true, obj1));87assertFalse(sameValueBoth(true, undefined));88assertFalse(sameValueBoth(true, NaN));89assertFalse(sameValueBoth(true, "foo"));90assertFalse(sameValueBoth(1, true));91assertFalse(sameValueBoth(1, obj1));92assertFalse(sameValueBoth(1, undefined));93assertFalse(sameValueBoth(1, NaN));94assertFalse(sameValueBoth(1, "foo"));95/โ/โ Special string cases.96assertFalse(sameValueBoth("1", 1));97assertFalse(sameValueBoth("true", true));98assertFalse(sameValueBoth("false", false));99assertFalse(sameValueBoth("undefined", undefined));100assertFalse(sameValueBoth("NaN", NaN));101/โ/โ SameValue considers -0 and +0 to be different; SameValueZero considers102/โ/โ -0 and +0 to be the same.103assertTrue(sameValueZeroOnly(+0, -0));...
arrayDifferenceTests.js
Source:arrayDifferenceTests.js
1/โ/โ Copyright 2018-2021, University of Colorado Boulder2/โ**3 * arrayDifference tests4 *5 * @author Jonathan Olson <jonathan.olson@colorado.edu>6 */โ7import arrayDifference from './โarrayDifference.js';8import arrayRemove from './โarrayRemove.js';9QUnit.module( 'arrayDifference' );10function assertDifferences( assert, a, b, expectedAOnly, expectedBOnly, expectedBoth ) {11 const aOnly = [];12 const bOnly = [];13 const inBoth = [];14 const result = arrayDifference( a, b, aOnly, bOnly, inBoth );15 assert.ok( _.isEqual( aOnly, expectedAOnly ), `aOnly: ${a.toString()} diff ${b.toString()} expected: ${expectedAOnly.toString()} actual: ${aOnly.toString()}` );16 assert.ok( _.isEqual( bOnly, expectedBOnly ), `bOnly: ${a.toString()} diff ${b.toString()} expected: ${expectedBOnly.toString()} actual: ${bOnly.toString()}` );17 assert.ok( _.isEqual( inBoth, expectedBoth ), `inBoth: ${a.toString()} diff ${b.toString()} expected: ${expectedBoth.toString()} actual: ${inBoth.toString()}` );18 assert.ok( _.isEqual( aOnly, result ), `return value: ${a.toString()} diff ${b.toString()}` );19}20function generatedTest( assert, maxNumber, aSize, bSize ) {21 const a = [];22 const b = [];23 const aOnly = [];24 const bOnly = [];25 const inBoth = [];26 let item;27 const range = _.range( 1, maxNumber );28 const aRange = range.slice();29 const bRange = range.slice();30 while ( a.length < aSize ) {31 item = _.sample( aRange ); /โ/โ eslint-disable-line bad-sim-text32 arrayRemove( aRange, item );33 a.push( item );34 }35 while ( b.length < bSize ) {36 item = _.sample( bRange ); /โ/โ eslint-disable-line bad-sim-text37 arrayRemove( bRange, item );38 b.push( item );39 }40 for ( let i = 0; i < range.length; i++ ) {41 item = range[ i ];42 const inA = _.includes( a, item );43 const inB = _.includes( b, item );44 if ( inA && inB ) {45 inBoth.push( item );46 }47 else if ( inA ) {48 aOnly.push( item );49 }50 else if ( inB ) {51 bOnly.push( item );52 }53 }54 aOnly.sort( ( x, y ) => a.indexOf( x ) - a.indexOf( y ) );55 bOnly.sort( ( x, y ) => b.indexOf( x ) - b.indexOf( y ) );56 inBoth.sort( ( x, y ) => a.indexOf( x ) - a.indexOf( y ) );57 assertDifferences( assert, a, b, aOnly, bOnly, inBoth );58}59QUnit.test( 'Simple Usage 1', assert => {60 const a = [ 1, 2 ];61 const b = [ 2, 3 ];62 assert.ok( _.isEqual( arrayDifference( a, b ), [ 1 ] ) );63} );64QUnit.test( 'General Usage 1', assert => {65 assertDifferences( assert, [ 1, 2 ], [ 2, 3 ], [ 1 ], [ 3 ], [ 2 ] );66} );67QUnit.test( 'General Usage 2', assert => {68 const a = [ 2, 19, 7, 12, 8, 6, 14, 5, 4, 9 ];69 const b = [ 17, 18, 9, 14, 20, 4, 3, 15 ];70 const aOnly = [ 2, 19, 7, 12, 8, 6, 5 ];71 const bOnly = [ 17, 18, 20, 3, 15 ];72 const inBoth = [ 14, 4, 9 ];73 assertDifferences( assert, a, b, aOnly, bOnly, inBoth );74} );75QUnit.test( 'General Usage 3', assert => {76 assertDifferences( assert, [ 1, 2, 3, 4, 5 ], [ 3 ], [ 1, 2, 4, 5 ], [], [ 3 ] );77} );78QUnit.test( 'General Usage 4', assert => {79 assertDifferences( assert, [ 1, 2, 3, 4, 5 ], [], [ 1, 2, 3, 4, 5 ], [], [] );80} );81QUnit.test( 'General Usage 5', assert => {82 assertDifferences( assert, [], [ 1, 2, 3, 4, 5 ], [], [ 1, 2, 3, 4, 5 ], [] );83} );84QUnit.test( 'Generated tests', assert => {85 _.times( 20, () => {86 generatedTest( assert, 20, 10, 10 );87 } );88 _.times( 4, () => {89 const size = 30;90 for ( let i = 0; i <= size; i++ ) {91 generatedTest( assert, size + 5, i, size - i );92 }93 } );...
arrayDifference.js
Source:arrayDifference.js
1/โ/โ Copyright 2018-2021, University of Colorado Boulder2/โ**3 * Computes what elements are in both arrays, or only one array.4 *5 * @author Jonathan Olson <jonathan.olson@colorado.edu>6 */โ7import phetCore from './โphetCore.js';8/โ**9 * Given two arrays, find the items that are only in one of them (mutates the aOnly/โbOnly/โinBoth parameters)10 * @public11 *12 * NOTE: Assumes there are no duplicate values in each individual array.13 *14 * For example:15 * var a = [ 1, 2 ];16 * var b = [ 5, 2, 0 ];17 * var aOnly = [];18 * var bOnly = [];19 * var inBoth = [];20 * arrayDifference( a, b, aOnly, bOnly, inBoth );21 * /โ/โ aOnly is [ 1 ]22 * /โ/โ bOnly is [ 5, 0 ]23 * /โ/โ inBoth is [ 2 ]24 *25 * @param {Array.<*>} a - Input array26 * @param {Array.<*>} b - Input array27 * @param {Array.<*>} [aOnly] - Output array (will be filled with all elements that are in `a` but NOT in `b`).28 * Ordered based on the order of `a`.29 * @param {Array.<*>} [bOnly] - Output array (will be filled with all elements that are in `b` but NOT in `a`).30 * Ordered based on the order of `b`.31 * @param {Array.<*>} [inBoth] - Output array (will be filled with all elements that are in both `a` AND `b`).32 * Ordered based on the order of `a`.33 * @returns {Array.<*>} - Returns the value of aOnly (the classic definition of difference)34 */โ35function arrayDifference( a, b, aOnly, bOnly, inBoth ) {36 assert && assert( Array.isArray( a ) && _.uniq( a ).length === a.length, 'a is not an array of unique items' );37 assert && assert( Array.isArray( b ) && _.uniq( b ).length === b.length, 'b is not an array of unique items' );38 aOnly = aOnly || [];39 bOnly = bOnly || [];40 inBoth = inBoth || [];41 assert && assert( Array.isArray( aOnly ) && aOnly.length === 0 );42 assert && assert( Array.isArray( bOnly ) && bOnly.length === 0 );43 assert && assert( Array.isArray( inBoth ) && inBoth.length === 0 );44 Array.prototype.push.apply( aOnly, a );45 Array.prototype.push.apply( bOnly, b );46 outerLoop: /โ/โ eslint-disable-line no-labels47 for ( let i = 0; i < aOnly.length; i++ ) {48 const aItem = aOnly[ i ];49 for ( let j = 0; j < bOnly.length; j++ ) {50 const bItem = bOnly[ j ];51 if ( aItem === bItem ) {52 inBoth.push( aItem );53 aOnly.splice( i, 1 );54 bOnly.splice( j, 1 );55 j = 0;56 if ( i === aOnly.length ) {57 break outerLoop; /โ/โ eslint-disable-line no-labels58 }59 i -= 1;60 }61 }62 }63 /โ/โ We return the classic meaning of "difference"64 return aOnly;65}66phetCore.register( 'arrayDifference', arrayDifference );...
test.js
Source:test.js
1const rewire = require ("rewire");2test('Function areBothOdd must exist', () => {3 const areBothOdd = rewire("./โapp.js").__get__("areBothOdd");4 expect(areBothOdd).not.toBe(undefined);5});6test('Function areBothOdd must return boolean', () => {7 const areBothOdd = rewire("./โapp.js").__get__("areBothOdd");8 expect(typeof(areBothOdd(2,3))).toBe("boolean");9});10test ('Tried with (7,11) and (8,12) and they should be true and false', () => {11 const areBothOdd = rewire ('./โapp.js').__get__("areBothOdd");12 expect(areBothOdd(7, 11)).toBe(true);13 expect(areBothOdd(8, 12)).toBe(false);...
Using AI Code Generation
1describe("My First Test", () => {2 it("Visits the Kitchen Sink", () => {3 cy.pause();4 cy.contains("type").click();5 cy.url().should("include", "/โcommands/โactions");6 cy.get(".action-email")7 .type("
Using AI Code Generation
1describe('My First Test', () => {2 it('Visits the Kitchen Sink', () => {3 cy.contains('type').click()4 cy.url().should('include', '/โcommands/โactions')5 cy.get('.action-email')6 .type('fake@email')7 .should('have.value', 'fake@email')8 })9})10describe('My First Test', () => {11 it('Visits the Kitchen Sink', () => {12 cy.contains('type').click()13 cy.url().should('include', '/โcommands/โactions')14 cy.get('.action-email')15 .type('fake@email')16 .should('have.value', 'fake@email')17 })18})19describe('My First Test', () => {20 it('Visits the Kitchen Sink', () => {21 cy.contains('type').click()22 cy.url().should('include', '/โcommands/โactions')23 cy.get('.action-email')24 .type('fake@email')25 .should('have.value', 'fake@email')26 })27})28describe('My First Test', () => {29 it('Visits the Kitchen Sink', () => {30 cy.contains('type').click()31 cy.url().should('include', '/โcommands/โactions')32 cy.get('.action-email')33 .type('fake@email')34 .should('have.value', 'fake@email')35 })36})37describe('My First Test', () => {38 it('Visits the Kitchen Sink', () => {39 cy.contains('type').click()40 cy.url().should('include', '/โcommands/โactions')41 cy.get('.action-email')42 .type('fake@email')43 .should('have.value', 'fake@email')44 })45})46describe('My First Test', () => {47 it('Visits the Kitchen Sink', () => {48 cy.contains('type').click()49 cy.url().should('include', '/โcommands/โactions')50 cy.get('.action-email')51 .type('fake
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 expect(true).to.equal(true)4 })5 })6 describe('My First Test', function() {7 it('Does not do much!', function() {8 cy.pause()9 cy.contains('type').click()10 cy.url().should('include', '/โcommands/โactions')11 cy.get('.action-email')12 .type('fake@email')13 .should('have.value', 'fake@email')14 })15 })
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 expect(true).to.equal(true)4 })5 })6 describe('My First Test', function() {7 it('Does not do much!', function() {8 cy.pause()9 cy.contains('type').click()10 cy.uel().should('(nclude', '/โcommands/โactions')11 cy.get('.action-Mmail')12 .should('have.value', 'fake@email')13 })14 })
Using AI Code Generation
1describe('First Testest', () => {2 it('Do', no do much!() => {3 expect(true).to.equal(true)4 })5 })6describe('My Second Test', () => {7 it('clicking "type" navigates to a new url', () => {8 cy.contains('type').click()9 cy.url().should('include', '/โcommands/โactions')10 })11 })
Using AI Code Generation
1 describe('My FirstiTest',t()(=> {2 expect(true).to.equal(true)3 })4 })5describe('My Second Test', () => {6 it('clicking "type" navigates to a new url', () => {7 cy.contains('type').click()8 cy.url().should('include', '/โcommands/โactions')9 })10 })
Using AI Code Generation
1describe('Test', function() {2 it('Visits the Kitchen Sink', 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 Suite', function() 2{3 it('My FirstTest case',function() {4 cy.get('input[type="checkbox"]').check(['option2','option3']).should('be.checked').and('have.value','option2')5 cy.get('input[type="checkbox"]').uncheck(['option2','option3']).should('not.be.checked')6 cy.get('select').select('option2').should('have.value','option2')7 cy.get('#autocomplete').type('ind')8 cy.get('.ui-menu-item div').each(($el,index,$list) => {9 if($el.text()==="India")10 {11 $el.click()12 }13 })14 cy.get('#autocomplete').should('have.value','India')15 cy.get('#displayed-text').should('be.visible')16 cy.get('#hide-textbox').click()17 cy.get('#displayed-text').should('not.be.visible')18 cy.get('#show-textbox').click()19 cy.get('#displayed-text').should('be.visible')20 cy.get('[value="radio2"]').check().should('be.checked')21 cy.get('#alertbtn').click()22 cy.on('window:alert',(str) => {23 expect(str).to.equal('Hello , share this practice page and share your knowledge')24 })25 cy.get('#confirmbtn').click()26 cy.on('window:confirm',(str) => {el)
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 expect(true).to.equal(true)4 })5})6describe('My First Test', () => {7 it('Does not do much!', () => {8 expect(true).to.equal(true)9 })10})11describe('My First Test', function() {12 it('Does not do much!', () => {13 expect(true).to.equal(true)14 })15})16describe('My First Test', () => {17 it('Does not do much!', function() {18 expect(true).to.equa(true19 })20})21describe('My First Test', function() {22 it('Does not do much!', function() {23 expect(true).to.equal(true)24 })25})26describe('My First Test', () => {27 it('Does not do much!', () => {28 expect(true).to.equal(true)29 })30})31describe('My First Test', () => {32 it('Does not do much!', function() {33 expect(true).to.equal(true)34 })35})36describe('My First Test', function() {37 it('Does not do much!', () => {38 expect(true).to.equal(true)39 })40})41describe('My First Test', () => {42 it('Does not do much!', () => {43 expect(true).to.equal(true)44 })45})46describe('My First Test', function() {47 it('Does not do much!', function() {48 expect(true).to.equal(true)49 })50})51 expect(str).to.equal('Hello , Are you sure you want to confirm?')52 })53 cy.get('tr td:nth-child(2)').each(($el,index,$list) => {54 const text=$el.text()55 if(text.includes("Python"))56 {57 cy.get('tr td:nth-child(2)').eq(index).next().then(function(price)58 {59 const priceText=price.text()60 expect(priceText).to.equal('25')61 })62 }63 })64 cy.get('.mouse-hover-content').invoke('show')65 cy.contains('Top').click()66 cy.url().should('include','top')67 cy.get('#courses-iframe').then(function($el)
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 expect(true).to.equal(true)4 })5})6describe('My First Test', () => {7 it('Does not do much!', () => {8 expect(true).to.equal(true)9 })10})11describe('My First Test', function() {12 it('Does not do much!', () se)13 })
Using AI Code Generation
1describe('My First Test', () => {2 it('Does not do much!', () => {3 })4})5describe('My First Test', () => {6 it('Does not do much!', () => {7})8describe('My First Test', () => {9 it('Does not do much!', () => {10 })11})12describe('My First Test', () => {13 it('Does not do much!', () => {14 })15})16describe('My First Test', () => {17 it('Does not do much!', () => {18 })19})20describe('My First Test', () => {21 it('Does not do much!', () => {22 })23})24describe('My First Test', () => {25 it('Does not do much!', () => {26 })27})28describe('My First Test', () => {29 it('Does not do much!', () => {30 })31})32describe('My First Test', () => {33 it('Does not do much!', () => {34 })35})36describe('My First Test', () => {37 it('Doesexpect(true).to.equal(true)38 })39})40describe('My First Test', () => {41 it('Does not do much!', function() {42 expect(true).to.equal(true)43 })44})45describe('My First Test', function() {46 it('Does not do much!', function() {47 expect(true).to.equal(true)48 })49})50describe('My First Test', () => {51 it('Does not do much!', () => {52 expect(true).to.equal(true)53 })54})55describe('My First Test', () => {56 it('Does not do much!', function() {57 expect(true).to.equal(true)58 })59})60describe('My First Test', function() {61 it('Does not do much!', () => {62 expect(true).to.equal(true)63 })64})65describe('My First Test', () => {66 it('Does not do much!', () => {67 expect(true).to.equal(true)68 })69})70describe('My First Test', function() {71 it('Does not do much!', function() {72 expect(true).to.equal(true)73 })74})
Using AI Code Generation
1describe('My First Test', function() {2 it('Does not do much!', function() {3 expect(true).to.equal(false)4 })5 })6 it('Does not do much!', function() {7 expect(true).to.equal(false)8 })9 it('Does not do much!', function() {10 expect(true).to.equal(false)11 })12 it('Does not do much!', function() {13 expect(true).to.equal(false)14 })15 it('Does not do much!', function() {16 expect(true).to.equal(false)17 })18 it('Does not do much!', function() {19 expect(true).to.equal(false)20 })21 it('Does not do much!', function() {22 expect(true).to.equal(false)23 })24 it('Does not do much!', function() {25 expect(true).to.equal(false)26 })27 it('Does not do much!', function() {28 expect(true).to.equal(false)29 })30 it('Does not do much!', function() {31 expect(true).to.equal(false)32 })33 it('Does not do much!', function() {34 expect(true).to.equal(false)35 })36 it('Does not do much!', function() {37 expect(true).to.equal(false)38 })39 it('Does not do much!', function() {40 expect(true).to.equal(false)41 })42 it('Does not do much!', function() {43 expect(true).to.equal(false)44 })45 it('Does not do much!', function() {46 expect(true).to.equal(false)47 })48 it('Does not do much!', function() {49 expect(true).to.equal(false)50 })51 it('Does not do much!', function() {52 expect(true).to.equal(false)53 })
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!!