Best JavaScript code snippet using jest-extended
crystal.js
Source:crystal.js
1/*2Language: Crystal3Author: TSUYUSATO Kitsune <make.just.on@gmail.com>4*/5function(hljs) {6 var NUM_SUFFIX = '(_[uif](8|16|32|64))?';7 var CRYSTAL_IDENT_RE = '[a-zA-Z_]\\w*[!?=]?';8 var RE_STARTER = '!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|' +9 '>>|>|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~';10 var CRYSTAL_METHOD_RE = '[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\][=?]?';11 var CRYSTAL_KEYWORDS = {12 keyword:13 'abstract alias as as? asm begin break case class def do else elsif end ensure enum extend for fun if ' +14 'include instance_sizeof is_a? lib macro module next nil? of out pointerof private protected rescue responds_to? ' +15 'return require select self sizeof struct super then type typeof union uninitialized unless until when while with yield ' +16 '__DIR__ __END_LINE__ __FILE__ __LINE__',17 literal: 'false nil true'18 };19 var SUBST = {20 className: 'subst',21 begin: '#{', end: '}',22 keywords: CRYSTAL_KEYWORDS23 };24 var EXPANSION = {25 className: 'template-variable',26 variants: [27 {begin: '\\{\\{', end: '\\}\\}'},28 {begin: '\\{%', end: '%\\}'}29 ],30 keywords: CRYSTAL_KEYWORDS31 };32 function recursiveParen(begin, end) {33 var34 contains = [{begin: begin, end: end}];35 contains[0].contains = contains;36 return contains;37 }38 var STRING = {39 className: 'string',40 contains: [hljs.BACKSLASH_ESCAPE, SUBST],41 variants: [42 {begin: /'/, end: /'/},43 {begin: /"/, end: /"/},44 {begin: /`/, end: /`/},45 {begin: '%w?\\(', end: '\\)', contains: recursiveParen('\\(', '\\)')},46 {begin: '%w?\\[', end: '\\]', contains: recursiveParen('\\[', '\\]')},47 {begin: '%w?{', end: '}', contains: recursiveParen('{', '}')},48 {begin: '%w?<', end: '>', contains: recursiveParen('<', '>')},49 {begin: '%w?/', end: '/'},50 {begin: '%w?%', end: '%'},51 {begin: '%w?-', end: '-'},52 {begin: '%w?\\|', end: '\\|'},53 {begin: /<<-\w+$/, end: /^\s*\w+$/},54 ],55 relevance: 0,56 };57 var Q_STRING = {58 className: 'string',59 variants: [60 {begin: '%q\\(', end: '\\)', contains: recursiveParen('\\(', '\\)')},61 {begin: '%q\\[', end: '\\]', contains: recursiveParen('\\[', '\\]')},62 {begin: '%q{', end: '}', contains: recursiveParen('{', '}')},63 {begin: '%q<', end: '>', contains: recursiveParen('<', '>')},64 {begin: '%q/', end: '/'},65 {begin: '%q%', end: '%'},66 {begin: '%q-', end: '-'},67 {begin: '%q\\|', end: '\\|'},68 {begin: /<<-'\w+'$/, end: /^\s*\w+$/},69 ],70 relevance: 0,71 };72 var REGEXP = {73 begin: '(' + RE_STARTER + ')\\s*',74 contains: [75 {76 className: 'regexp',77 contains: [hljs.BACKSLASH_ESCAPE, SUBST],78 variants: [79 {begin: '//[a-z]*', relevance: 0},80 {begin: '/', end: '/[a-z]*'},81 {begin: '%r\\(', end: '\\)', contains: recursiveParen('\\(', '\\)')},82 {begin: '%r\\[', end: '\\]', contains: recursiveParen('\\[', '\\]')},83 {begin: '%r{', end: '}', contains: recursiveParen('{', '}')},84 {begin: '%r<', end: '>', contains: recursiveParen('<', '>')},85 {begin: '%r/', end: '/'},86 {begin: '%r%', end: '%'},87 {begin: '%r-', end: '-'},88 {begin: '%r\\|', end: '\\|'},89 ]90 }91 ],92 relevance: 093 };94 var REGEXP2 = {95 className: 'regexp',96 contains: [hljs.BACKSLASH_ESCAPE, SUBST],97 variants: [98 {begin: '%r\\(', end: '\\)', contains: recursiveParen('\\(', '\\)')},99 {begin: '%r\\[', end: '\\]', contains: recursiveParen('\\[', '\\]')},100 {begin: '%r{', end: '}', contains: recursiveParen('{', '}')},101 {begin: '%r<', end: '>', contains: recursiveParen('<', '>')},102 {begin: '%r/', end: '/'},103 {begin: '%r%', end: '%'},104 {begin: '%r-', end: '-'},105 {begin: '%r\\|', end: '\\|'},106 ],107 relevance: 0108 };109 var ATTRIBUTE = {110 className: 'meta',111 begin: '@\\[', end: '\\]',112 contains: [113 hljs.inherit(hljs.QUOTE_STRING_MODE, {className: 'meta-string'})114 ]115 };116 var CRYSTAL_DEFAULT_CONTAINS = [117 EXPANSION,118 STRING,119 Q_STRING,120 REGEXP,121 REGEXP2,122 ATTRIBUTE,123 hljs.HASH_COMMENT_MODE,124 {125 className: 'class',126 beginKeywords: 'class module struct', end: '$|;',127 illegal: /=/,128 contains: [129 hljs.HASH_COMMENT_MODE,130 hljs.inherit(hljs.TITLE_MODE, {begin: '[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?'}),131 {begin: '<'} // relevance booster for inheritance132 ]133 },134 {135 className: 'class',136 beginKeywords: 'lib enum union', end: '$|;',137 illegal: /=/,138 contains: [139 hljs.HASH_COMMENT_MODE,140 hljs.inherit(hljs.TITLE_MODE, {begin: '[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?'}),141 ],142 relevance: 10143 },144 {145 className: 'function',146 beginKeywords: 'def', end: /\B\b/,147 contains: [148 hljs.inherit(hljs.TITLE_MODE, {149 begin: CRYSTAL_METHOD_RE,150 endsParent: true151 })152 ]153 },154 {155 className: 'function',156 beginKeywords: 'fun macro', end: /\B\b/,157 contains: [158 hljs.inherit(hljs.TITLE_MODE, {159 begin: CRYSTAL_METHOD_RE,160 endsParent: true161 })162 ],163 relevance: 5164 },165 {166 className: 'symbol',167 begin: hljs.UNDERSCORE_IDENT_RE + '(\\!|\\?)?:',168 relevance: 0169 },170 {171 className: 'symbol',172 begin: ':',173 contains: [STRING, {begin: CRYSTAL_METHOD_RE}],174 relevance: 0175 },176 {177 className: 'number',178 variants: [179 { begin: '\\b0b([01_]*[01])' + NUM_SUFFIX },180 { begin: '\\b0o([0-7_]*[0-7])' + NUM_SUFFIX },181 { begin: '\\b0x([A-Fa-f0-9_]*[A-Fa-f0-9])' + NUM_SUFFIX },182 { begin: '\\b(([0-9][0-9_]*[0-9]|[0-9])(\\.[0-9_]*[0-9])?([eE][+-]?[0-9_]*[0-9])?)' + NUM_SUFFIX}183 ],184 relevance: 0185 }186 ];187 SUBST.contains = CRYSTAL_DEFAULT_CONTAINS;188 EXPANSION.contains = CRYSTAL_DEFAULT_CONTAINS.slice(1); // without EXPANSION189 return {190 aliases: ['cr'],191 lexemes: CRYSTAL_IDENT_RE,192 keywords: CRYSTAL_KEYWORDS,193 contains: CRYSTAL_DEFAULT_CONTAINS194 };...
ScrapeData.js
Source:ScrapeData.js
...24 var phone = {};25 phone.id = agent.url.split(/\//).pop();26 phone.name = body.find('h2').text().trim();27 phone.description = body.find('.description').text().trim();28 phone.availability = c1.find('table:nth-child(1) th:contains("Availability")+td').text().trim().split(/\s*\n\s*/),29 phone.battery = {30 type: c1.find('table:nth-child(2) th:contains("Type")+td').text(),31 talkTime: c1.find('table:nth-child(2) th:contains("Talk time")+td').text(),32 standbyTime: c1.find('table:nth-child(2) th:contains("Standby time")+td').text()33 };34 phone.storage = {35 ram: c1.find('table:nth-child(3) th:contains("RAM")+td').text(),36 flash: c1.find('table:nth-child(3) th:contains("Internal storage")+td').text()37 };38 phone.connectivity = {39 cell: c1.find('table:nth-child(4) th:contains("Network support")+td').text(),40 wifi: c1.find('table:nth-child(4) th:contains("WiFi")+td').text(),41 bluetooth: c1.find('table:nth-child(4) th:contains("Bluetooth")+td').text(),42 infrared: boolean(c1.find('table:nth-child(4) th:contains("Infrared")+td img').attr('src')),43 gps: boolean(c1.find('table:nth-child(4) th:contains("GPS")+td img').attr('src'))44 };45 phone.android = {46 os: c2.find('table:nth-child(1) th:contains("OS Version")+td').text(),47 ui: c2.find('table:nth-child(1) th:contains("UI")+td').text()48 };49 phone.sizeAndWeight = {50 dimensions: c2.find('table:nth-child(2) th:contains("Dimensions")+td').text().trim().split(/\s*\n\s*/),51 weight: c2.find('table:nth-child(2) th:contains("Weight")+td').text().trim()52 };53 phone.display = {54 screenSize: c2.find('table:nth-child(3) th:contains("Screen size")+td').text(),55 screenResolution: c2.find('table:nth-child(3) th:contains("Screen resolution")+td').text(),56 touchScreen: boolean(c2.find('table:nth-child(3) th:contains("Touch screen")+td img').attr('src'))57 };58 phone.hardware = {59 fmRadio: boolean(c2.find('table:nth-child(4) th:contains("FM Radio")+td img').attr('src')),60 physicalKeyboard: c2.find('table:nth-child(4) th:contains("Physical keyboard")+td img').attr('src'),61 accelerometer: boolean(c2.find('table:nth-child(4) th:contains("Accelerometer")+td img').attr('src')),62 cpu: c2.find('table:nth-child(4) th:contains("CPU")+td').text(),63 usb: c2.find('table:nth-child(4) th:contains("USB")+td').text(),64 audioJack: c2.find('table:nth-child(4) th:contains("Audio / headphone jack")+td').text()65 };66 phone.camera= {67 primary: c2.find('table:nth-child(5) th:contains("Primary")+td').text(),68 features: c2.find('table:nth-child(5) th:contains("Features")+td').text().trim().split(/\s*\n\s*/)69 };70 phone.additionalFeatures = c2.find('table:nth-child(6) td').text();71 phone.images = [];72 body.find('#thumbs img').each(function(){73 var imgUrl = 'http://www.google.com' + jquery(this).attr('src');74 phone.images.push({75 small: imgUrl,76 large: imgUrl.replace(/\/small$/, '/large')77 });78 });79 fs.writeSync(fs.openSync(baseDir + phone.id + '.json', 'w'), JSON.stringify(phone));80 } else {81 var age = 0;82 body.find('ul.phonelist li.list').each(function(a){...
ruby.js
Source:ruby.js
1/*2Language: Ruby3Author: Anton Kovalyov <anton@kovalyov.net>4Contributors: Peter Leonov <gojpeg@yandex.ru>, Vasily Polovnyov <vast@whiteants.net>, Loren Segal <lsegal@soen.ca>, Pascal Hurni <phi@ruby-reactive.org>, Cedric Sohrauer <sohrauer@googlemail.com>5Category: common6*/7function(hljs) {8 var RUBY_METHOD_RE = '[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?';9 var RUBY_KEYWORDS =10 'and false then defined module in return redo if BEGIN retry end for true self when ' +11 'next until do begin unless END rescue nil else break undef not super class case ' +12 'require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor';13 var YARDOCTAG = {14 className: 'doctag',15 begin: '@[A-Za-z]+'16 };17 var IRB_OBJECT = {18 className: 'value',19 begin: '#<', end: '>'20 };21 var COMMENT_MODES = [22 hljs.COMMENT(23 '#',24 '$',25 {26 contains: [YARDOCTAG]27 }28 ),29 hljs.COMMENT(30 '^\\=begin',31 '^\\=end',32 {33 contains: [YARDOCTAG],34 relevance: 1035 }36 ),37 hljs.COMMENT('^__END__', '\\n$')38 ];39 var SUBST = {40 className: 'subst',41 begin: '#\\{', end: '}',42 keywords: RUBY_KEYWORDS43 };44 var STRING = {45 className: 'string',46 contains: [hljs.BACKSLASH_ESCAPE, SUBST],47 variants: [48 {begin: /'/, end: /'/},49 {begin: /"/, end: /"/},50 {begin: /`/, end: /`/},51 {begin: '%[qQwWx]?\\(', end: '\\)'},52 {begin: '%[qQwWx]?\\[', end: '\\]'},53 {begin: '%[qQwWx]?{', end: '}'},54 {begin: '%[qQwWx]?<', end: '>'},55 {begin: '%[qQwWx]?/', end: '/'},56 {begin: '%[qQwWx]?%', end: '%'},57 {begin: '%[qQwWx]?-', end: '-'},58 {begin: '%[qQwWx]?\\|', end: '\\|'},59 {60 // \B in the beginning suppresses recognition of ?-sequences where ?61 // is the last character of a preceding identifier, as in: `func?4`62 begin: /\B\?(\\\d{1,3}|\\x[A-Fa-f0-9]{1,2}|\\u[A-Fa-f0-9]{4}|\\?\S)\b/63 }64 ]65 };66 var PARAMS = {67 className: 'params',68 begin: '\\(', end: '\\)',69 keywords: RUBY_KEYWORDS70 };71 var RUBY_DEFAULT_CONTAINS = [72 STRING,73 IRB_OBJECT,74 {75 className: 'class',76 beginKeywords: 'class module', end: '$|;',77 illegal: /=/,78 contains: [79 hljs.inherit(hljs.TITLE_MODE, {begin: '[A-Za-z_]\\w*(::\\w+)*(\\?|\\!)?'}),80 {81 className: 'inheritance',82 begin: '<\\s*',83 contains: [{84 className: 'parent',85 begin: '(' + hljs.IDENT_RE + '::)?' + hljs.IDENT_RE86 }]87 }88 ].concat(COMMENT_MODES)89 },90 {91 className: 'function',92 beginKeywords: 'def', end: '$|;',93 contains: [94 hljs.inherit(hljs.TITLE_MODE, {begin: RUBY_METHOD_RE}),95 PARAMS96 ].concat(COMMENT_MODES)97 },98 {99 className: 'constant',100 begin: '(::)?(\\b[A-Z]\\w*(::)?)+',101 relevance: 0102 },103 {104 className: 'symbol',105 begin: hljs.UNDERSCORE_IDENT_RE + '(\\!|\\?)?:',106 relevance: 0107 },108 {109 className: 'symbol',110 begin: ':',111 contains: [STRING, {begin: RUBY_METHOD_RE}],112 relevance: 0113 },114 {115 className: 'number',116 begin: '(\\b0[0-7_]+)|(\\b0x[0-9a-fA-F_]+)|(\\b[1-9][0-9_]*(\\.[0-9_]+)?)|[0_]\\b',117 relevance: 0118 },119 {120 className: 'variable',121 begin: '(\\$\\W)|((\\$|\\@\\@?)(\\w+))'122 },123 { // regexp container124 begin: '(' + hljs.RE_STARTERS_RE + ')\\s*',125 contains: [126 IRB_OBJECT,127 {128 className: 'regexp',129 contains: [hljs.BACKSLASH_ESCAPE, SUBST],130 illegal: /\n/,131 variants: [132 {begin: '/', end: '/[a-z]*'},133 {begin: '%r{', end: '}[a-z]*'},134 {begin: '%r\\(', end: '\\)[a-z]*'},135 {begin: '%r!', end: '![a-z]*'},136 {begin: '%r\\[', end: '\\][a-z]*'}137 ]138 }139 ].concat(COMMENT_MODES),140 relevance: 0141 }142 ].concat(COMMENT_MODES);143 SUBST.contains = RUBY_DEFAULT_CONTAINS;144 PARAMS.contains = RUBY_DEFAULT_CONTAINS;145 var SIMPLE_PROMPT = "[>?]>";146 var DEFAULT_PROMPT = "[\\w#]+\\(\\w+\\):\\d+:\\d+>";147 var RVM_PROMPT = "(\\w+-)?\\d+\\.\\d+\\.\\d(p\\d+)?[^>]+>";148 var IRB_DEFAULT = [149 {150 begin: /^\s*=>/,151 className: 'status',152 starts: {153 end: '$', contains: RUBY_DEFAULT_CONTAINS154 }155 },156 {157 className: 'prompt',158 begin: '^('+SIMPLE_PROMPT+"|"+DEFAULT_PROMPT+'|'+RVM_PROMPT+')',159 starts: {160 end: '$', contains: RUBY_DEFAULT_CONTAINS161 }162 }163 ];164 return {165 aliases: ['rb', 'gemspec', 'podspec', 'thor', 'irb'],166 keywords: RUBY_KEYWORDS,167 contains: COMMENT_MODES.concat(IRB_DEFAULT).concat(RUBY_DEFAULT_CONTAINS)168 };...
website.tour.event_sale.js
Source:website.tour.event_sale.js
...9},10 [11 {12 content: "Go to the `Events` page",13 trigger: 'a[href*="/event"]:contains("Conference on Business Apps"):first',14 },15 {16 content: "Select 1 unit of `Standard` ticket type",17 extra_trigger: '#wrap:not(:has(a[href*="/event"]:contains("Conference on Business Apps")))',18 trigger: 'select:eq(0)',19 run: 'text 1',20 },21 {22 content: "Select 2 units of `VIP` ticket type",23 extra_trigger: 'select:eq(0):has(option:contains(1):propSelected)',24 trigger: 'select:eq(1)',25 run: 'text 2',26 },27 {28 content: "Click on `Order Now` button",29 extra_trigger: 'select:eq(1):has(option:contains(2):propSelected)',30 trigger: '.btn-primary:contains("Register Now")',31 },32 {33 content: "Fill attendees details",34 trigger: 'form[id="attendee_registration"] .btn:contains("Continue")',35 run: function () {36 $("input[name='1-name']").val("Att1");37 $("input[name='1-phone']").val("111 111");38 $("input[name='1-email']").val("att1@example.com");39 $("input[name='2-name']").val("Att2");40 $("input[name='2-phone']").val("222 222");41 $("input[name='2-email']").val("att2@example.com");42 $("input[name='3-name']").val("Att3");43 $("input[name='3-phone']").val("333 333");44 $("input[name='3-email']").val("att3@example.com");45 },46 },47 {48 content: "Validate attendees details",49 extra_trigger: "input[name='1-name'], input[name='2-name'], input[name='3-name']",50 trigger: 'button:contains("Continue")',51 },52 {53 content: "Check that the cart contains exactly 3 triggers",54 trigger: 'a:has(.my_cart_quantity:containsExact(3))',55 run: function () {}, // it's a check56 },57 {58 content: "go to cart",59 trigger: 'a:contains(Return to Cart)',60 },61 {62 content: "Modify the cart to add 1 unit of `VIP` ticket type",63 extra_trigger: "#cart_products:contains(Standard):contains(VIP)",64 trigger: "#cart_products tr:contains(VIP) .fa-plus",65 },66 {67 content: "Now click on `Process Checkout`",68 extra_trigger: 'a:has(.my_cart_quantity):contains(4)',69 trigger: '.btn-primary:contains("Process Checkout")'70 },71 {72 content: "Complete the checkout",73 trigger: 'a[href="/shop/confirm_order"]:contains("Confirm")',74 },75 {76 content: "Check that the subtotal is 5,500.00 USD", // this test will fail if the currency of the main company is not USD77 trigger: '#order_total_untaxed .oe_currency_value:contains("5,500.00")',78 run: function () {}, // it's a check79 },80 {81 content: "Select `Wire Transfer` payment method",82 trigger: '#payment_method label:contains("Wire Transfer")',83 },84 {85 content: "Pay",86 //Either there are multiple payment methods, and one is checked, either there is only one, and therefore there are no radio inputs87 extra_trigger: '#payment_method label:contains("Wire Transfer") input:checked,#payment_method:not(:has("input:radio:visible"))',88 trigger: 'button[id="o_payment_form_pay"]:visible',89 },90 {91 content: "Last step",92 trigger: '.oe_website_sale:contains("Thank you for your order")',93 timeout: 30000,94 }95 ]96);...
tree.js
Source:tree.js
1module.exports = {2 'tree': function (browser) {3 browser4 .url('http://localhost:8080/examples/tree/')5 .waitForElementVisible('li', 1000)6 .assert.count('.item', 12)7 .assert.count('.add', 4)8 .assert.count('.item > ul', 4)9 .assert.notVisible('#demo li ul')10 .assert.containsText('#demo li div span', '[+]')11 // expand root12 .click('.bold')13 .assert.visible('#demo ul')14 .assert.evaluate(function () {15 return document.querySelector('#demo li ul').children.length === 416 })17 .assert.containsText('#demo li div span', '[-]')18 .assert.containsText('#demo > .item > ul > .item:nth-child(1)', 'hello')19 .assert.containsText('#demo > .item > ul > .item:nth-child(2)', 'wat')20 .assert.containsText('#demo > .item > ul > .item:nth-child(3)', 'child folder')21 .assert.containsText('#demo > .item > ul > .item:nth-child(3)', '[+]')22 // add items to root23 .click('#demo > .item > ul > .add')24 .assert.evaluate(function () {25 return document.querySelector('#demo li ul').children.length === 526 })27 .assert.containsText('#demo > .item > ul > .item:nth-child(1)', 'hello')28 .assert.containsText('#demo > .item > ul > .item:nth-child(2)', 'wat')29 .assert.containsText('#demo > .item > ul > .item:nth-child(3)', 'child folder')30 .assert.containsText('#demo > .item > ul > .item:nth-child(3)', '[+]')31 .assert.containsText('#demo > .item > ul > .item:nth-child(4)', 'new stuff')32 // add another item33 .click('#demo > .item > ul > .add')34 .assert.evaluate(function () {35 return document.querySelector('#demo li ul').children.length === 636 })37 .assert.containsText('#demo > .item > ul > .item:nth-child(1)', 'hello')38 .assert.containsText('#demo > .item > ul > .item:nth-child(2)', 'wat')39 .assert.containsText('#demo > .item > ul > .item:nth-child(3)', 'child folder')40 .assert.containsText('#demo > .item > ul > .item:nth-child(3)', '[+]')41 .assert.containsText('#demo > .item > ul > .item:nth-child(4)', 'new stuff')42 .assert.containsText('#demo > .item > ul > .item:nth-child(5)', 'new stuff')43 .click('#demo ul .bold')44 .assert.visible('#demo ul ul')45 .assert.containsText('#demo ul > .item:nth-child(3)', '[-]')46 .assert.evaluate(function () {47 return document.querySelector('#demo ul ul').children.length === 548 })49 .click('.bold')50 .assert.notVisible('#demo ul')51 .assert.containsText('#demo li div span', '[+]')52 .click('.bold')53 .assert.visible('#demo ul')54 .assert.containsText('#demo li div span', '[-]')55 .dblClick('#demo ul > .item div')56 .assert.count('.item', 15)57 .assert.count('.item > ul', 5)58 .assert.containsText('#demo ul > .item:nth-child(1)', '[-]')59 .assert.evaluate(function () {60 var firstItem = document.querySelector('#demo ul > .item:nth-child(1)')61 var ul = firstItem.querySelector('ul')62 return ul.children.length === 263 })64 .end()65 }...
select2.js
Source:select2.js
1/* globals vm */2module.exports = {3 'select2': function (browser) {4 browser5 .url('http://localhost:8080/examples/select2/')6 .waitForElementVisible('.select2', 1000)7 .assert.elementPresent('select')8 .assert.containsText('p', 'Selected: 0')9 .assert.containsText('span.select2', 'Select one')10 .moveToElement('span.select2', 5, 5).mouseButtonClick()11 .assert.count('.select2-results__option', 3)12 .assert.containsText('.select2-results__option:nth-child(1)', 'Select one')13 .assert.containsText('.select2-results__option:nth-child(2)', 'Hello')14 .assert.containsText('.select2-results__option:nth-child(3)', 'World')15 .assert.attributePresent('.select2-results__option:nth-child(1)', 'aria-disabled')16 .click('.select2-results__option:nth-child(2)')17 .assert.count('.select2-results__option', 0)18 .assert.containsText('p', 'Selected: 1')19 .assert.containsText('span.select2', 'Hello')20 // test dynamic options21 .execute(function () {22 vm.options.push({ id: 3, text: 'Vue' })23 })24 .moveToElement('span.select2', 5, 5).mouseButtonClick()25 .assert.count('.select2-results__option', 4)26 .assert.containsText('.select2-results__option:nth-child(1)', 'Select one')27 .assert.containsText('.select2-results__option:nth-child(2)', 'Hello')28 .assert.containsText('.select2-results__option:nth-child(3)', 'World')29 .assert.containsText('.select2-results__option:nth-child(4)', 'Vue')30 .click('.select2-results__option:nth-child(4)')31 .assert.count('.select2-results__option', 0)32 .assert.containsText('p', 'Selected: 3')33 .assert.containsText('span.select2', 'Vue')34 .execute(function () {35 vm.selected = 236 })37 .assert.containsText('p', 'Selected: 2')38 .assert.containsText('span.select2', 'World')39 .end()40 }...
deDupe.recursive.spec.js
Source:deDupe.recursive.spec.js
1var deDupe = require("../../../lib/algorithms/2-linkedLists/deDupe.recursive.js");2var LinkedList = require("../../../lib/dataStructures/linkedList.js");3describe('When using the recursive deDupe() on a linked list of integers', function () {4 var containsDupes;5 var noDupes;6 beforeEach(function() {7 containsDupes = new LinkedList();8 containsDupes.add(1);9 containsDupes.add(2);10 containsDupes.add(1);11 containsDupes.add(3);12 containsDupes.add(4);13 containsDupes.add(4);14 containsDupes.add(4);15 containsDupes.add(5);16 containsDupes.add(6);17 containsDupes.add(6);18 containsDupes.add(6);19 noDupes = new LinkedList();20 noDupes.add(1);21 noDupes.add(2);22 noDupes.add(3);23 noDupes.add(4);24 noDupes.add(5);25 noDupes.add(6);26 });27 it('any duplicate elements will be removed from the linked list.', function () {28 var result = deDupe(containsDupes.start);29 expect(JSON.stringify(result)).toEqual(JSON.stringify(noDupes.start));30 });31 it('if there are no dups, nothing will happen', function () {32 var result = deDupe(noDupes.start);33 expect(JSON.stringify(result)).toEqual(JSON.stringify(noDupes.start));34 });...
deDupe.spec.js
Source:deDupe.spec.js
1var deDupe = require("../../../lib/algorithms/2-linkedLists/deDupe.js");2var LinkedList = require("../../../lib/dataStructures/linkedList.js");3describe('When using deDupe() on a linked list of integers', function () {4 var containsDupes;5 var noDupes;6 beforeEach(function() {7 containsDupes = new LinkedList();8 containsDupes.add(1);9 containsDupes.add(2);10 containsDupes.add(1);11 containsDupes.add(3);12 containsDupes.add(4);13 containsDupes.add(4);14 containsDupes.add(4);15 containsDupes.add(5);16 containsDupes.add(6);17 containsDupes.add(6);18 containsDupes.add(6);19 noDupes = new LinkedList();20 noDupes.add(1);21 noDupes.add(2);22 noDupes.add(3);23 noDupes.add(4);24 noDupes.add(5);25 noDupes.add(6);26 });27 it('any duplicate elements will be removed from the linked list.', function () {28 var result = deDupe(containsDupes.start);29 expect(JSON.stringify(result)).toEqual(JSON.stringify(noDupes.start));30 });31 it('if there are no dups, nothing will happen', function () {32 var result = deDupe(noDupes.start);33 expect(JSON.stringify(result)).toEqual(JSON.stringify(noDupes.start));34 });...
Using AI Code Generation
1expect([1,2,3]).toContain(2);2expect([1,2,3]).not.toContain(4);3expect([1,2,3]).to.contain(2);4expect([1,2,3]).to.not.contain(4);5expect.extend({6 toContain(received, argument) {7 const pass = this.equals(8 expect.arrayContaining([expect.objectContaining(argument)])9 );10 if (pass) {11 return {12 message: () =>13 `expected ${this.utils.printReceived(14 )} not to contain object ${this.utils.printExpected(argument)}`,15 };16 } else {17 return {18 message: () =>19 `expected ${this.utils.printReceived(20 )} to contain object ${this.utils.printExpected(argument)}`,21 };22 }23 },24});25expect([{ name: 'John' }, { name: 'Jane' }, { name: 'Jack' }]).toContain({26});27expect([{ name: 'John' }, { name: 'Jane' }, { name: 'Jack' }]).not.toContain({28});
Using AI Code Generation
1const { contains } = require('jest-extended');2test('contains', () => {3 expect([1, 2, 3]).toContain(2);4 expect('hello world').toContain('world');5 expect({ a: 1, b: 2 }).toContainKey('a');6 expect({ a: 1, b: 2 }).toContainValue(2);7});8const { contains } = require('jest-extended');9test('contains', () => {10 expect([1, 2, 3]).toContain(2);11 expect('hello world').toContain('world');12 expect({ a: 1, b: 2 }).toContainKey('a');13 expect({ a: 1, b: 2 }).toContainValue(2);14});15const { contains } = require('jest-extended');16test('contains', () => {17 expect([1, 2, 3]).toContain(2);18 expect('hello world').toContain('world');19 expect({ a: 1, b: 2 }).toContainKey('a');20 expect({ a: 1, b: 2 }).toContainValue(2);21});22const { contains } = require('jest-extended');23test('contains', () => {24 expect([1, 2, 3]).toContain(2);25 expect('hello world').toContain('world');26 expect({ a: 1, b: 2 }).toContainKey('a');27 expect({ a: 1, b: 2 }).toContainValue(2);28});29const { contains } = require('jest-extended');30test('contains', () => {31 expect([1, 2, 3]).toContain(2);32 expect('hello world').toContain('world');33 expect({ a: 1, b: 2 }).toContainKey('a');34 expect({ a: 1, b: 2 }).toContainValue(2);35});36const { contains } = require('jest-
Using AI Code Generation
1const contains = require('jest-extended').contains;2test('contains', () => {3 expect('foobar').toContain('foo');4 expect([1, 2, 3]).toContain(3);5 expect({ a: 1, b: 2 }).toContain(1);6});7const contains = require('jest-extended').contains;8test('contains', () => {9 expect('foobar').toContain('foo');10 expect([1, 2, 3]).toContain(3);11 expect({ a: 1, b: 2 }).toContain(1);12});13const contains = require('jest-extended').contains;14test('contains', () => {15 expect('foobar').toContain('foo');16 expect([1, 2, 3]).toContain(3);17 expect({ a: 1, b: 2 }).toContain(1);18});19const contains = require('jest-extended').contains;20test('contains', () => {21 expect('foobar').toContain('foo');22 expect([1, 2, 3]).toContain(3);23 expect({ a: 1, b: 2 }).toContain(1);24});25const contains = require('jest-extended').contains;26test('contains', () => {27 expect('foobar').toContain('foo');28 expect([1, 2, 3]).toContain(3);29 expect({ a: 1, b: 2 }).toContain(1);30});31const contains = require('jest-extended').contains;32test('contains', () => {33 expect('foobar').toContain('foo');34 expect([1, 2, 3]).toContain(3);35 expect({ a: 1, b: 2 }).toContain(1);36});37const contains = require('jest-extended').contains;38test('contains', () => {39 expect('foobar').toContain('foo');40 expect([1, 2, 3
Using AI Code Generation
1const contains = require('jest-extended').contains;2const array = ['foo', 'bar', 'baz'];3expect(array).toContains('foo');4const chai = require('chai');5const contains = chai.assert.contains;6const array = ['foo', 'bar', 'baz'];7contains(array, 'foo');8const chai = require('chai');9const contains = chai.expect(array).to.contains;10const array = ['foo', 'bar', 'baz'];11contains('foo');12const chai = require('chai');13const contains = chai.expect(array).to.have.ordered.members;14const array = ['foo', 'bar', 'baz'];15contains(['foo', 'bar', 'baz']);16const chai = require('chai');17const contains = chai.expect(array).to.have.members;18const array = ['foo', 'bar', 'baz'];19contains(['foo', 'bar', 'baz']);20const chai = require('chai');21const contains = chai.expect(array).to.have.members;22const array = ['foo', 'bar', 'baz'];23contains(['foo', 'bar', 'baz']);24const chai = require('chai');25const contains = chai.expect(array).to.have.members;26const array = ['foo', 'bar', 'baz'];27contains(['foo', 'bar', 'baz']);28const chai = require('chai');29const contains = chai.expect(array).to.have.members;30const array = ['foo', 'bar', 'baz'];31contains(['foo', 'bar', 'baz']);32const chai = require('chai');33const contains = chai.expect(array).to.have.members;34const array = ['foo', 'bar', 'baz'];35contains(['foo', 'bar', 'baz']);36const chai = require('chai');37const contains = chai.expect(array).to.have.members;38const array = ['foo', 'bar', 'baz'];39contains(['foo', 'bar', 'baz']);40const chai = require('chai');41const contains = chai.expect(array).to.have.members;42const array = ['foo', 'bar', 'baz'];
Using AI Code Generation
1describe('test', () => {2 it('should test', () => {3 expect('test').toContain('es');4 });5});6describe('test', () => {7 it('should test', () => {8 expect('test').toContain('es');9 });10});11describe('test', () => {12 it('should test', () => {13 expect('test').toContain('es');14 });15});16describe('test', () => {17 it('should test', () => {18 expect('test').toContain('es');19 });20});21describe('test', () => {22 it('should test', () => {23 expect('test').toContain('es');24 });25});26describe('test', () => {27 it('should test', () => {28 expect('test').toContain('es');29 });30});31describe('test', () => {32 it('should test', () => {33 expect('test').toContain('es');34 });35});36describe('test', () => {37 it('should test', () => {38 expect('test').toContain('es');39 });40});41describe('test', () => {42 it('should test', () => {43 expect('test').toContain('es');44 });45});46describe('test', () => {47 it('should test', () => {48 expect('test').toContain('es');49 });50});51describe('test', () => {52 it('should test', () => {53 expect('test').toContain('es');54 });55});
Using AI Code Generation
1const { contains } = require('jest-extended');2test('contains', () => {3 const str = 'This is a test string';4 expect(str).toContain('test');5 expect(str).contains('test');6});
Using AI Code Generation
1const contains = require('jest-extended').contains;2test('test contains method of jest-extended', () => {3 expect('hello').toContain('hell');4});5const chai = require('chai');6const expect = chai.expect;7chai.use(require('chai-string'));8test('test contains method of chai', () => {9 expect('hello').to.contain('hell');10});11const should = require('should');12should.use(require('should-sinon'));13test('test contains method of should', () => {14 'hello'.should.containEql('hell');15});16const expect = require('expect');17test('test contains method of expect', () => {18 expect('hello').toContain('hell');19});20const assert = require('assert');21test('test contains method of assert', () => {22 assert('hello'.includes('hell'));23});24const sinon = require('sinon');25test('test contains method of sinon', () => {26 sinon.assert.match('hello', /hell/);27});28const assert = require('assert');29test('test contains method of node assert', () => {30 assert('hello'.includes('hell'));31});32const expect = require('expect');33test('test contains method of node expect', () => {34 expect('hello').toContain('hell');35});36const should = require('should');37test('test contains method of node should', () => {38 'hello'.should.containEql('hell');39});40const assert = require('assert');41test('test contains method of node assert', () => {42 assert('hello'.includes('hell'));43});44const expect = require('expect');45test('test contains method of node expect', () => {46 expect('hello').toContain('hell');47});48const should = require('should');49test('test contains method of node should', () => {50 'hello'.should.containEql('hell');51});
Using AI Code Generation
1const { contains } = require('jest-extended');2expect.extend({ contains });3test('test string', () => {4 expect('Hello Jest').toContain('Jest');5});6test('test array', () => {7 expect([1, 2, 3]).toContain(1);8});9test('test object', () => {10 expect({ a: 1, b: 2 }).toContain(1);11});12test('test object', () => {13 expect({ a: 1, b: 2 }).toContain('a');14});15test('test string', () => {16 expect('Hello Jest').not.toContain('Jest');17});18test('test array', () => {19 expect([1, 2, 3]).not.toContain(4);20});21test('test object', () => {22 expect({ a: 1, b: 2 }).not.toContain(3);23});24test('test object', () => {25 expect({ a: 1, b: 2 }).not.toContain('c');26});27test('test string', () => {28 expect('Hello Jest').toContain('Jest');29});30test('test array', () => {31 expect([1, 2, 3]).toContain(1);32});33test('test object', () => {34 expect({ a: 1, b: 2 }).toContain(1);35});36test('test object', () => {37 expect({ a: 1, b: 2 }).toContain('a');38});39test('test string', () => {40 expect('Hello Jest').not.toContain('Jest');41});42test('test array', () => {43 expect([1, 2, 3]).not.toContain(4);44});45test('test object', () => {46 expect({
Using AI Code Generation
1const { contains } = require('jest-extended');2const obj = {3};4test('contains', () => {5 expect(obj).toContains('John');6});7 ✓ contains (3ms)8const { contains } = require('jest-extended');9const obj = {10};11test('contains', () => {12 expect(obj).toContainAny(['John', 'Doe']);13});14 ✓ contains (3ms)15const { contains } = require('jest-extended');16const obj = {17};18test('contains', () => {19 expect(obj).toContainAll(['John', 'Doe']);20});21 ✓ contains (3ms)22const { contains } = require('jest-extended');23const obj = {24};25test('contains', () => {26 expect(obj).toContainKeys(['name', 'age']);27});28 ✓ contains (3ms)
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!