How to use contains method in sinon

Best JavaScript code snippet using sinon

crystal.js

Source:crystal.js Github

copy

Full Screen

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 };...

Full Screen

Full Screen

ScrapeData.js

Source:ScrapeData.js Github

copy

Full Screen

...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){...

Full Screen

Full Screen

ruby.js

Source:ruby.js Github

copy

Full Screen

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 };...

Full Screen

Full Screen

website.tour.event_sale.js

Source:website.tour.event_sale.js Github

copy

Full Screen

...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);...

Full Screen

Full Screen

tree.js

Source:tree.js Github

copy

Full Screen

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 }...

Full Screen

Full Screen

select2.js

Source:select2.js Github

copy

Full Screen

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 }...

Full Screen

Full Screen

deDupe.recursive.spec.js

Source:deDupe.recursive.spec.js Github

copy

Full Screen

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 });...

Full Screen

Full Screen

deDupe.spec.js

Source:deDupe.spec.js Github

copy

Full Screen

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 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var assert = require('assert');2var sinon = require('sinon');3var myObject = {4 myMethod: function() {5 return true;6 }7};8var spy = sinon.spy(myObject, 'myMethod');9myObject.myMethod();10assert(spy.withArgs().calledOnce);11assert(spy.calledOnce);12assert(spy.called);13assert(spy.calledWith());14assert(spy.calledOn(myObject));15assert(spy.calledWithExactly());16assert(spy.calledWithNew());17assert(spy.alwaysCalledWithNew());18assert(spy.neverCalledWithNew());19assert(spy.alwaysCalledOn(myObject));20assert(spy.neverCalledOn(myObject));21assert(spy.alwaysCalledWith());22assert(spy.neverCalledWith());23assert(spy.alwaysCalledWithExactly());24assert(spy.neverCalledWithExactly());25assert(spy.threw());26assert(spy.alwaysThrew());27assert(spy.neverThrew());28assert(spy.returned(true));29assert(spy.alwaysReturned(true));30assert(spy.neverReturned(true));31assert(spy.calledWithMatch());32assert(spy.alwaysCalledWithMatch());33assert(spy.neverCalledWithMatch());34assert(spy.calledBefore());35assert(spy.calledAfter());36assert(spy.calledImmediatelyBefore());37assert(spy.calledImmediatelyAfter());38assert(spy.firstCall.calledWith());39assert(spy.firstCall.calledWithExactly());40assert(spy.firstCall.calledWithMatch());41assert(spy.firstCall.calledOn(myObject));42assert(spy.firstCall.calledWithNew());43assert(spy.firstCall.threw());44assert(spy.firstCall.returned(true));45assert(spy.secondCall.calledWith());46assert(spy.secondCall.calledWithExactly());47assert(spy.secondCall.calledWithMatch());48assert(spy.secondCall.calledOn(myObject));49assert(spy.secondCall.calledWithNew());50assert(spy.secondCall.threw());51assert(spy.secondCall.returned(true));52assert(spy.thirdCall.calledWith());53assert(spy.thirdCall.calledWithExactly());54assert(spy.thirdCall.calledWithMatch());55assert(spy.thirdCall.calledOn(myObject));56assert(spy.thirdCall.calledWithNew());57assert(spy.thirdCall.threw());58assert(spy.thirdCall.returned(true));59assert(spy.lastCall.calledWith());60assert(spy.lastCall.calledWithExactly());61assert(spy.lastCall.calledWithMatch());62assert(spy.lastCall.calledOn(myObject));63assert(spy

Full Screen

Using AI Code Generation

copy

Full Screen

1var sinon = require('sinon');2var assert = require('assert');3var myObj = {4 myMethod: function (arg1, arg2) {5 return arg1 + arg2;6 }7};8var spy = sinon.spy(myObj, 'myMethod');9myObj.myMethod(1, 2);10assert(spy.calledWith(1, 2));11assert(spy.calledWith(3, 4) === false);12assert(spy.calledWithMatch(1));13assert(spy.calledWithMatch(2, 3));14assert(spy.calledWithMatch(1, 2, 3) === false);15assert(spy.neverCalledWith(3, 4));16assert(spy.neverCalledWithMatch(3, 4));17assert(spy.alwaysCalledWith(1, 2));18assert(spy.alwaysCalledWithMatch(2));19assert(spy.alwaysCalledWithMatch(1, 2));20assert(spy.alwaysCalledWithMatch(1, 2, 3) === false);21assert(spy.calledWithExactly(1, 2));22assert(spy.calledWithExactly(1, 2, 3) === false);23assert(spy.calledWithExactly(1, 2, 3, 4) === false);24assert(spy.calledWithExactly(1, 2, 3, 4, 5) === false);25assert(spy.calledWithExactly(1, 2, 3, 4, 5, 6) === false);26assert(spy.calledWithExactly(1, 2, 3, 4, 5, 6, 7) === false);27assert(spy.calledWithExactly(1, 2, 3, 4, 5, 6, 7, 8) === false);28assert(spy.calledWithExactly(1, 2, 3, 4, 5, 6, 7, 8, 9) === false);29assert(spy.calledWithExactly(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) === false);30assert(spy.calledWithExactly(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) === false);31assert(s

Full Screen

Using AI Code Generation

copy

Full Screen

1var sinon = require('sinon');2var assert = require('chai').assert;3var myObj = {4 myMethod: function() {5 console.log('myMethod called');6 }7};8var spy = sinon.spy(myObj, 'myMethod');9myObj.myMethod();10assert(spy.calledOnce);11assert(spy.calledWith());12assert(spy.calledOn(myObj));13assert(spy.calledWithExactly());14assert(spy.calledWithNew());15assert(spy.alwaysCalledOn(myObj));16assert(spy.called);17assert(spy.callCount === 1);18assert(spy.neverCalledWith('foo'));19assert(spy.calledBefore(spy));20assert(spy.calledAfter(spy));21assert(spy.calledImmediatelyBefore(spy));22assert(spy.calledImmediatelyAfter(spy));23assert(spy.firstCall.calledWithExactly());24assert(spy.secondCall.calledWithExactly());25assert(spy.thirdCall.calledWithExactly());26assert(spy.lastCall.calledWithExactly());27assert(spy.calledWithMatch('foo'));28assert(spy.alwaysCalledWithMatch('foo'));29assert(spy.calledWithExactly('foo'));30assert(spy.alwaysCalledWithExactly('foo'));31assert(spy.calledWithNew());32assert(spy.alwaysCalledWithNew());33assert(spy.calledWithNew(myObj.myMethod));34assert(spy.alwaysCalledWithNew(myObj.myMethod));35assert(spy.returned('bar'));36assert(spy.alwaysReturned('bar'));37assert(spy.threw());38assert(spy.threw('TypeError'));39assert(spy.alwaysThrew());40assert(spy.alwaysThrew('TypeError'));41assert(spy.calledWithNew());42assert(spy.alwaysCalledWithNew());43assert(spy.calledWithNew(myObj.myMethod));44assert(spy.alwaysCalledWithNew(myObj.myMethod));45assert(spy.returned('bar'));46assert(spy.alwaysReturned('bar'));47assert(spy.threw());48assert(spy.threw('TypeError'));49assert(spy.alwaysThrew());50assert(spy.alwaysThrew('TypeError'));51assert(spy.calledWithNew());52assert(spy.alwaysCalledWithNew());53assert(spy.calledWithNew(myObj.myMethod));54assert(spy.alwaysCalledWithNew(myObj.myMethod));55assert(spy.returned('bar'));56assert(spy.alwaysReturned('bar'));57assert(spy.threw());58assert(spy.threw('TypeError'));59assert(spy.alwaysThrew());60assert(spy.alwaysTh

Full Screen

Using AI Code Generation

copy

Full Screen

1var sinon = require('sinon');2var assert = require('assert');3var obj = { testFunc: function(){} };4var spy = sinon.spy(obj, "testFunc");5obj.testFunc(42);6assert(spy.calledWith(42));7var sinon = require('sinon');8var assert = require('assert');9var obj = { testFunc: function(){} };10var stub = sinon.stub(obj, "testFunc");11obj.testFunc(42);12assert(stub.calledWith(42));13var sinon = require('sinon');14var assert = require('assert');15var obj = { testFunc: function(){} };16var spy = sinon.spy(obj, "testFunc");17var stub = sinon.stub(obj, "testFunc");18obj.testFunc(42);19assert(spy.calledWith(42));20assert(stub.calledWith(42));21var sinon = require('sinon');22var clock = sinon.useFakeTimers();23var callback = sinon.spy();24var interval = setInterval(callback, 1000);25clock.tick(1001);26assert(callback.called);27clearInterval(interval);28var sinon = require('sinon');29var assert = require('assert');30var obj = { testFunc: function(){} };31var mock = sinon.mock(obj);32mock.expects("testFunc").once().withArgs(42);33obj.testFunc(42);34mock.verify();35var sinon = require('sinon');36var server = sinon.fakeServer.create();37server.respondWith(38 [200, { "Content-Type": "text/plain" }, "Hello, world!"]39);40var request = new XMLHttpRequest();41request.open("GET",

Full Screen

Using AI Code Generation

copy

Full Screen

1var sinon = require('sinon');2var assert = require('chai').assert;3var obj = {4 method: function () {5 return "Hello World";6 }7}8var spy = sinon.spy(obj, "method");9var result = obj.method();10assert.equal(result, "Hello World");11var sinon = require('sinon');12var assert = require('chai').assert;13var obj = {14 method: function () {15 return "Hello World";16 }17}18var spy = sinon.spy(obj, "method");19var result = obj.method();20assert.equal(result, "Hello World");21spy.restore();22var sinon = require('sinon');23var assert = require('chai').assert;24var obj = {25 method: function () {26 return "Hello World";27 }28}29var spy = sinon.spy(obj, "method");30var result = obj.method();31assert.equal(result, "Hello World");32spy.restore();33var sinon = require('sinon');34var assert = require('chai').assert;35var obj = {36 method: function (a, b) {37 return a + b;38 }39}40var spy = sinon.spy(obj, "method");41var result = obj.method(1, 2);42assert.equal(result, 3);43spy.restore();44var sinon = require('sinon');45var assert = require('chai').assert;46var obj = {47 method1: function () {48 return "Hello World";49 },50 method2: function () {51 return "Hello World";52 }53}54var spy1 = sinon.spy(obj, "method1");55var spy2 = sinon.spy(obj, "method2");

Full Screen

Using AI Code Generation

copy

Full Screen

1var assert = require('assert');2var sinon = require('sinon');3var myObj = {4 myMethod: function() {5 return 'Hello';6 }7};8describe('myObj', function() {9 it('should return "Hello" when myMethod is called', function() {10 var spy = sinon.spy(myObj, 'myMethod');11 var result = myObj.myMethod();12 assert(spy.calledOnce);13 assert(spy.calledWith());14 assert.equal(result, 'Hello');15 myObj.myMethod.restore();16 });17});18var assert = require('assert');19var sinon = require('sinon');20var myObj = {21 myMethod: function() {22 return 'Hello';23 }24};25describe('myObj', function() {26 it('should return "Hello" when myMethod is called', function() {27 var spy = sinon.spy(myObj, 'myMethod');28 var result = myObj.myMethod();29 assert(spy.calledOnce);30 assert(spy.calledWith());31 assert.equal(result, 'Hello');32 myObj.myMethod.restore();33 });34});35var assert = require('assert');36var sinon = require('sinon');37var myObj = {38 myMethod: function() {39 return 'Hello';40 }41};42describe('myObj', function() {43 it('should return "Hello" when myMethod is called', function() {44 var spy = sinon.spy(myObj, 'myMethod');45 var result = myObj.myMethod();46 assert(spy.calledOnce);47 assert(spy.calledWith());48 assert.equal(result, 'Hello');49 myObj.myMethod.restore();50 });51});52var assert = require('assert');53var sinon = require('sinon');54var myObj = {55 myMethod: function() {56 return 'Hello';57 }58};59describe('myObj', function() {60 it('should return "Hello" when myMethod is called', function() {61 var spy = sinon.spy(myObj, 'myMethod');62 var result = myObj.myMethod();63 assert(spy.calledOnce);64 assert(spy.calledWith());65 assert.equal(result, 'Hello');66 myObj.myMethod.restore();

Full Screen

Using AI Code Generation

copy

Full Screen

1var sinon = require('sinon');2var assert = require('assert');3var fs = require('fs');4var file = fs.readFileSync('test.js');5var stub = sinon.stub(fs, 'readFileSync');6stub.returns('Hello World');7var file = fs.readFileSync('test.js');8assert.equal(file, 'Hello World');9var sinon = require('sinon');10var assert = require('assert');11var fs = require('fs');12var spy = sinon.spy(fs, 'readFileSync');13var file = fs.readFileSync('test.js');14assert(spy.calledOnce);15var sinon = require('sinon');16var assert = require('assert');17var fs = require('fs');18var mock = sinon.mock(fs);19mock.expects('readFileSync').once().withArgs('test.js').returns('Hello World');20var file = fs.readFileSync('test.js');21assert.equal(file, 'Hello World');22mock.verify();23var assert = require('assert');24describe('Array', function() {25 describe('#indexOf()', function() {26 it('should return -1 when the value is not present', function() {27 assert.equal(-1, [1,2,3].indexOf(4));28 });29 });30});31var assert = require('assert');32describe('Array', function() {33 describe('#indexOf()', function() {34 it('should return -1 when the value is not present', function(done) {35 setTimeout(function() {36 assert.equal(-1, [1,2,3].indexOf(4));37 done();38 }, 1000);39 });40 });41});

Full Screen

Using AI Code Generation

copy

Full Screen

1sinon.assert.calledWithMatch(spy, {a: 1});2## sinon.assert.notCalled(spy)3sinon.assert.notCalled(spy);4## sinon.assert.neverCalledWith(spy, ...args)5sinon.assert.neverCalledWith(spy, 1, 2, 3);6## sinon.assert.neverCalledWithMatch(spy, ...args)7sinon.assert.neverCalledWithMatch(spy, {a: 1});8## sinon.assert.calledOnce(spy)9sinon.assert.calledOnce(spy);10## sinon.assert.calledTwice(spy)11sinon.assert.calledTwice(spy);12## sinon.assert.calledThrice(spy)13sinon.assert.calledThrice(spy);14## sinon.assert.callCount(spy, count)15sinon.assert.callCount(spy, 3);16## sinon.assert.callOrder(...spies)17sinon.assert.callOrder(spy1, spy2, spy3);18## sinon.assert.alwaysCalledOn(spy, obj)

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run sinon automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful