Best JavaScript code snippet using unexpected
counter.js
Source:counter.js
1import { LIST_STYLE_TYPE } from '../../property-descriptors/list-style-type';2import { fromCodePoint } from 'css-line-break';3import { contains } from '../../../core/bitwise';4export class CounterState {5 constructor() {6 this.counters = {};7 }8 getCounterValue(name) {9 const counter = this.counters[name];10 if (counter && counter.length) {11 return counter[counter.length - 1];12 }13 return 1;14 }15 getCounterValues(name) {16 const counter = this.counters[name];17 return counter ? counter : [];18 }19 pop(counters) {20 counters.forEach(counter => this.counters[counter].pop());21 }22 parse(style) {23 const counterIncrement = style.counterIncrement;24 const counterReset = style.counterReset;25 let canReset = true;26 if (counterIncrement !== null) {27 counterIncrement.forEach(entry => {28 const counter = this.counters[entry.counter];29 if (counter && entry.increment !== 0) {30 canReset = false;31 counter[Math.max(0, counter.length - 1)] += entry.increment;32 }33 });34 }35 const counterNames = [];36 if (canReset) {37 counterReset.forEach(entry => {38 let counter = this.counters[entry.counter];39 counterNames.push(entry.counter);40 if (!counter) {41 counter = this.counters[entry.counter] = [];42 }43 counter.push(entry.reset);44 });45 }46 return counterNames;47 }48}49const ROMAN_UPPER = {50 integers: [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1],51 values: ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']52};53const ARMENIAN = {54 integers: [55 9000,56 8000,57 7000,58 6000,59 5000,60 4000,61 3000,62 2000,63 1000,64 900,65 800,66 700,67 600,68 500,69 400,70 300,71 200,72 100,73 90,74 80,75 70,76 60,77 50,78 40,79 30,80 20,81 10,82 9,83 8,84 7,85 6,86 5,87 4,88 3,89 2,90 191 ],92 values: [93 'Õ',94 'Õ',95 'Õ',96 'Õ',97 'Õ',98 'Õ',99 'Õ',100 'Õ',101 'Õ',102 'Õ',103 'Õ',104 'Õ',105 'Õ',106 'Õ',107 'Õ',108 'Õ
',109 'Õ',110 'Õ',111 'Õ',112 'Õ',113 'Õ',114 'Ô¿',115 'Ô¾',116 'Ô½',117 'Ô¼',118 'Ô»',119 'Ôº',120 'Ô¹',121 'Ô¸',122 'Ô·',123 'Ô¶',124 'Ôµ',125 'Ô´',126 'Ô³',127 'Ô²',128 'Ô±'129 ]130};131const HEBREW = {132 integers: [133 10000,134 9000,135 8000,136 7000,137 6000,138 5000,139 4000,140 3000,141 2000,142 1000,143 400,144 300,145 200,146 100,147 90,148 80,149 70,150 60,151 50,152 40,153 30,154 20,155 19,156 18,157 17,158 16,159 15,160 10,161 9,162 8,163 7,164 6,165 5,166 4,167 3,168 2,169 1170 ],171 values: [172 '×׳',173 '×׳',174 '×׳',175 '×׳',176 '×׳',177 '×׳',178 '×׳',179 '×׳',180 '×׳',181 '×׳',182 'ת',183 'ש',184 'ר',185 'ק',186 'צ',187 'פ',188 '×¢',189 'ס',190 '× ',191 '×',192 '×',193 '×',194 '××',195 '××',196 '××',197 '××',198 '××',199 '×',200 '×',201 '×',202 '×',203 '×',204 '×',205 '×',206 '×',207 '×',208 '×'209 ]210};211const GEORGIAN = {212 integers: [213 10000,214 9000,215 8000,216 7000,217 6000,218 5000,219 4000,220 3000,221 2000,222 1000,223 900,224 800,225 700,226 600,227 500,228 400,229 300,230 200,231 100,232 90,233 80,234 70,235 60,236 50,237 40,238 30,239 20,240 10,241 9,242 8,243 7,244 6,245 5,246 4,247 3,248 2,249 1250 ],251 values: [252 'áµ',253 'á°',254 'á¯',255 'á´',256 'á®',257 'á',258 'á¬',259 'á«',260 'áª',261 'á©',262 'á¨',263 'á§',264 'á¦',265 'á¥',266 'á¤',267 'á³',268 'á¢',269 'á¡',270 'á ',271 'á',272 'á',273 'á',274 'á²',275 'á',276 'á',277 'á',278 'á',279 'á',280 'á',281 'á±',282 'á',283 'á',284 'á',285 'á',286 'á',287 'á',288 'á'289 ]290};291const createAdditiveCounter = (value, min, max, symbols, fallback, suffix) => {292 if (value < min || value > max) {293 return createCounterText(value, fallback, suffix.length > 0);294 }295 return (symbols.integers.reduce((string, integer, index) => {296 while (value >= integer) {297 value -= integer;298 string += symbols.values[index];299 }300 return string;301 }, '') + suffix);302};303const createCounterStyleWithSymbolResolver = (value, codePointRangeLength, isNumeric, resolver) => {304 let string = '';305 do {306 if (!isNumeric) {307 value--;308 }309 string = resolver(value) + string;310 value /= codePointRangeLength;311 } while (value * codePointRangeLength >= codePointRangeLength);312 return string;313};314const createCounterStyleFromRange = (value, codePointRangeStart, codePointRangeEnd, isNumeric, suffix) => {315 const codePointRangeLength = codePointRangeEnd - codePointRangeStart + 1;316 return ((value < 0 ? '-' : '') +317 (createCounterStyleWithSymbolResolver(Math.abs(value), codePointRangeLength, isNumeric, codePoint => fromCodePoint(Math.floor(codePoint % codePointRangeLength) + codePointRangeStart)) +318 suffix));319};320const createCounterStyleFromSymbols = (value, symbols, suffix = '. ') => {321 const codePointRangeLength = symbols.length;322 return (createCounterStyleWithSymbolResolver(Math.abs(value), codePointRangeLength, false, codePoint => symbols[Math.floor(codePoint % codePointRangeLength)]) + suffix);323};324const CJK_ZEROS = 1 << 0;325const CJK_TEN_COEFFICIENTS = 1 << 1;326const CJK_TEN_HIGH_COEFFICIENTS = 1 << 2;327const CJK_HUNDRED_COEFFICIENTS = 1 << 3;328const createCJKCounter = (value, numbers, multipliers, negativeSign, suffix, flags) => {329 if (value < -9999 || value > 9999) {330 return createCounterText(value, LIST_STYLE_TYPE.CJK_DECIMAL, suffix.length > 0);331 }332 let tmp = Math.abs(value);333 let string = suffix;334 if (tmp === 0) {335 return numbers[0] + string;336 }337 for (let digit = 0; tmp > 0 && digit <= 4; digit++) {338 let coefficient = tmp % 10;339 if (coefficient === 0 && contains(flags, CJK_ZEROS) && string !== '') {340 string = numbers[coefficient] + string;341 }342 else if (coefficient > 1 ||343 (coefficient === 1 && digit === 0) ||344 (coefficient === 1 && digit === 1 && contains(flags, CJK_TEN_COEFFICIENTS)) ||345 (coefficient === 1 && digit === 1 && contains(flags, CJK_TEN_HIGH_COEFFICIENTS) && value > 100) ||346 (coefficient === 1 && digit > 1 && contains(flags, CJK_HUNDRED_COEFFICIENTS))) {347 string = numbers[coefficient] + (digit > 0 ? multipliers[digit - 1] : '') + string;348 }349 else if (coefficient === 1 && digit > 0) {350 string = multipliers[digit - 1] + string;351 }352 tmp = Math.floor(tmp / 10);353 }354 return (value < 0 ? negativeSign : '') + string;355};356const CHINESE_INFORMAL_MULTIPLIERS = 'åç¾åè¬';357const CHINESE_FORMAL_MULTIPLIERS = 'æ¾ä½°ä»è¬';358const JAPANESE_NEGATIVE = 'ãã¤ãã¹';359const KOREAN_NEGATIVE = 'ë§ì´ëì¤';360export const createCounterText = (value, type, appendSuffix) => {361 const defaultSuffix = appendSuffix ? '. ' : '';362 const cjkSuffix = appendSuffix ? 'ã' : '';363 const koreanSuffix = appendSuffix ? ', ' : '';364 const spaceSuffix = appendSuffix ? ' ' : '';365 switch (type) {366 case LIST_STYLE_TYPE.DISC:367 return 'â¢' + spaceSuffix;368 case LIST_STYLE_TYPE.CIRCLE:369 return 'â¦' + spaceSuffix;370 case LIST_STYLE_TYPE.SQUARE:371 return 'â¾' + spaceSuffix;372 case LIST_STYLE_TYPE.DECIMAL_LEADING_ZERO:373 const string = createCounterStyleFromRange(value, 48, 57, true, defaultSuffix);374 return string.length < 4 ? `0${string}` : string;375 case LIST_STYLE_TYPE.CJK_DECIMAL:376 return createCounterStyleFromSymbols(value, 'ãä¸äºä¸åäºå
ä¸å
«ä¹', cjkSuffix);377 case LIST_STYLE_TYPE.LOWER_ROMAN:378 return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, LIST_STYLE_TYPE.DECIMAL, defaultSuffix).toLowerCase();379 case LIST_STYLE_TYPE.UPPER_ROMAN:380 return createAdditiveCounter(value, 1, 3999, ROMAN_UPPER, LIST_STYLE_TYPE.DECIMAL, defaultSuffix);381 case LIST_STYLE_TYPE.LOWER_GREEK:382 return createCounterStyleFromRange(value, 945, 969, false, defaultSuffix);383 case LIST_STYLE_TYPE.LOWER_ALPHA:384 return createCounterStyleFromRange(value, 97, 122, false, defaultSuffix);385 case LIST_STYLE_TYPE.UPPER_ALPHA:386 return createCounterStyleFromRange(value, 65, 90, false, defaultSuffix);387 case LIST_STYLE_TYPE.ARABIC_INDIC:388 return createCounterStyleFromRange(value, 1632, 1641, true, defaultSuffix);389 case LIST_STYLE_TYPE.ARMENIAN:390 case LIST_STYLE_TYPE.UPPER_ARMENIAN:391 return createAdditiveCounter(value, 1, 9999, ARMENIAN, LIST_STYLE_TYPE.DECIMAL, defaultSuffix);392 case LIST_STYLE_TYPE.LOWER_ARMENIAN:393 return createAdditiveCounter(value, 1, 9999, ARMENIAN, LIST_STYLE_TYPE.DECIMAL, defaultSuffix).toLowerCase();394 case LIST_STYLE_TYPE.BENGALI:395 return createCounterStyleFromRange(value, 2534, 2543, true, defaultSuffix);396 case LIST_STYLE_TYPE.CAMBODIAN:397 case LIST_STYLE_TYPE.KHMER:398 return createCounterStyleFromRange(value, 6112, 6121, true, defaultSuffix);399 case LIST_STYLE_TYPE.CJK_EARTHLY_BRANCH:400 return createCounterStyleFromSymbols(value, 'åä¸å¯
å¯è¾°å·³åæªç³é
æ亥', cjkSuffix);401 case LIST_STYLE_TYPE.CJK_HEAVENLY_STEM:402 return createCounterStyleFromSymbols(value, 'ç²ä¹ä¸ä¸æå·±åºè¾å£¬ç¸', cjkSuffix);403 case LIST_STYLE_TYPE.CJK_IDEOGRAPHIC:404 case LIST_STYLE_TYPE.TRAD_CHINESE_INFORMAL:405 return createCJKCounter(value, 'é¶ä¸äºä¸åäºå
ä¸å
«ä¹', CHINESE_INFORMAL_MULTIPLIERS, 'è² ', cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);406 case LIST_STYLE_TYPE.TRAD_CHINESE_FORMAL:407 return createCJKCounter(value, 'é¶å£¹è²³åèä¼é¸ææç', CHINESE_FORMAL_MULTIPLIERS, 'è² ', cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);408 case LIST_STYLE_TYPE.SIMP_CHINESE_INFORMAL:409 return createCJKCounter(value, 'é¶ä¸äºä¸åäºå
ä¸å
«ä¹', CHINESE_INFORMAL_MULTIPLIERS, 'è´', cjkSuffix, CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);410 case LIST_STYLE_TYPE.SIMP_CHINESE_FORMAL:411 return createCJKCounter(value, 'é¶å£¹è´°åèä¼éææç', CHINESE_FORMAL_MULTIPLIERS, 'è´', cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS | CJK_HUNDRED_COEFFICIENTS);412 case LIST_STYLE_TYPE.JAPANESE_INFORMAL:413 return createCJKCounter(value, 'ãä¸äºä¸åäºå
ä¸å
«ä¹', 'åç¾åä¸', JAPANESE_NEGATIVE, cjkSuffix, 0);414 case LIST_STYLE_TYPE.JAPANESE_FORMAL:415 return createCJKCounter(value, 'é¶å£±å¼ååä¼å
ä¸å
«ä¹', 'æ¾ç¾åä¸', JAPANESE_NEGATIVE, cjkSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);416 case LIST_STYLE_TYPE.KOREAN_HANGUL_FORMAL:417 return createCJKCounter(value, 'ìì¼ì´ì¼ì¬ì¤ì¡ì¹ í구', 'ìë°±ì²ë§', KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);418 case LIST_STYLE_TYPE.KOREAN_HANJA_INFORMAL:419 return createCJKCounter(value, 'é¶ä¸äºä¸åäºå
ä¸å
«ä¹', 'åç¾åè¬', KOREAN_NEGATIVE, koreanSuffix, 0);420 case LIST_STYLE_TYPE.KOREAN_HANJA_FORMAL:421 return createCJKCounter(value, 'é¶å£¹è²³ååäºå
ä¸å
«ä¹', 'æ¾ç¾å', KOREAN_NEGATIVE, koreanSuffix, CJK_ZEROS | CJK_TEN_COEFFICIENTS | CJK_TEN_HIGH_COEFFICIENTS);422 case LIST_STYLE_TYPE.DEVANAGARI:423 return createCounterStyleFromRange(value, 0x966, 0x96f, true, defaultSuffix);424 case LIST_STYLE_TYPE.GEORGIAN:425 return createAdditiveCounter(value, 1, 19999, GEORGIAN, LIST_STYLE_TYPE.DECIMAL, defaultSuffix);426 case LIST_STYLE_TYPE.GUJARATI:427 return createCounterStyleFromRange(value, 0xae6, 0xaef, true, defaultSuffix);428 case LIST_STYLE_TYPE.GURMUKHI:429 return createCounterStyleFromRange(value, 0xa66, 0xa6f, true, defaultSuffix);430 case LIST_STYLE_TYPE.HEBREW:431 return createAdditiveCounter(value, 1, 10999, HEBREW, LIST_STYLE_TYPE.DECIMAL, defaultSuffix);432 case LIST_STYLE_TYPE.HIRAGANA:433 return createCounterStyleFromSymbols(value, 'ããããããããããããããããã¡ã¤ã¦ã¨ãªã«ã¬ãã®ã¯ã²ãµã¸ã»ã¾ã¿ãããããããããããããããã');434 case LIST_STYLE_TYPE.HIRAGANA_IROHA:435 return createCounterStyleFromSymbols(value, 'ããã¯ã«ã»ã¸ã¨ã¡ãã¬ããããããããã¤ããªããããã®ãããã¾ããµããã¦ãããããã¿ããã²ããã');436 case LIST_STYLE_TYPE.KANNADA:437 return createCounterStyleFromRange(value, 0xce6, 0xcef, true, defaultSuffix);438 case LIST_STYLE_TYPE.KATAKANA:439 return createCounterStyleFromSymbols(value, 'ã¢ã¤ã¦ã¨ãªã«ãã¯ã±ã³ãµã·ã¹ã»ã½ã¿ããããããããããããããããã ã¡ã¢ã¤ã¦ã¨ã©ãªã«ã¬ãã¯ã°ã±ã²ã³', cjkSuffix);440 case LIST_STYLE_TYPE.KATAKANA_IROHA:441 return createCounterStyleFromSymbols(value, 'ã¤ããããããããªãã«ã²ã¯ã«ã¨ã¿ã¬ã½ãããã©ã ã¦ã°ããªã¯ã¤ãã±ãã³ã¨ãã¢ãµãã¦ã¡ãã·ã±ãã¢ã»ã¹', cjkSuffix);442 case LIST_STYLE_TYPE.LAO:443 return createCounterStyleFromRange(value, 0xed0, 0xed9, true, defaultSuffix);444 case LIST_STYLE_TYPE.MONGOLIAN:445 return createCounterStyleFromRange(value, 0x1810, 0x1819, true, defaultSuffix);446 case LIST_STYLE_TYPE.MYANMAR:447 return createCounterStyleFromRange(value, 0x1040, 0x1049, true, defaultSuffix);448 case LIST_STYLE_TYPE.ORIYA:449 return createCounterStyleFromRange(value, 0xb66, 0xb6f, true, defaultSuffix);450 case LIST_STYLE_TYPE.PERSIAN:451 return createCounterStyleFromRange(value, 0x6f0, 0x6f9, true, defaultSuffix);452 case LIST_STYLE_TYPE.TAMIL:453 return createCounterStyleFromRange(value, 0xbe6, 0xbef, true, defaultSuffix);454 case LIST_STYLE_TYPE.TELUGU:455 return createCounterStyleFromRange(value, 0xc66, 0xc6f, true, defaultSuffix);456 case LIST_STYLE_TYPE.THAI:457 return createCounterStyleFromRange(value, 0xe50, 0xe59, true, defaultSuffix);458 case LIST_STYLE_TYPE.TIBETAN:459 return createCounterStyleFromRange(value, 0xf20, 0xf29, true, defaultSuffix);460 case LIST_STYLE_TYPE.DECIMAL:461 default:462 return createCounterStyleFromRange(value, 48, 57, true, defaultSuffix);463 }...
statesManagement.js
Source:statesManagement.js
1$(document).ready(function(){2 $('select#id_country').change(function(){3 updateState();4 updateNeedIDNumber();5 updateZipCode();6 });7 updateState();8 updateNeedIDNumber();9 updateZipCode();10 11 if ($('select#id_country_invoice').length != 0)12 {13 $('select#id_country_invoice').change(function(){14 updateState('invoice');15 updateNeedIDNumber('invoice');16 updateZipCode();17 });18 if ($('select#id_country_invoice:visible').length != 0)19 {20 updateState('invoice');21 updateNeedIDNumber('invoice');22 updateZipCode('invoice');23 }24 }25});26function updateState(suffix)27{28 $('select#id_state'+(suffix !== undefined ? '_'+suffix : '')+' option:not(:first-child)').remove();29 var states = countries[$('select#id_country'+(suffix !== undefined ? '_'+suffix : '')).val()];30 if(typeof(states) != 'undefined')31 {32 $(states).each(function (key, item){33 $('select#id_state'+(suffix !== undefined ? '_'+suffix : '')).append('<option value="'+item.id+'"'+ (idSelectedCountry == item.id ? ' selected="selected"' : '') + '>'+item.name+'</option>');34 });35 36 $('p.id_state'+(suffix !== undefined ? '_'+suffix : '')+':hidden').slideDown('slow');37 }38 else39 $('p.id_state'+(suffix !== undefined ? '_'+suffix : '')).slideUp('fast');40}41function updateNeedIDNumber(suffix)42{43 var idCountry = parseInt($('select#id_country'+(suffix !== undefined ? '_'+suffix : '')).val());44 if ($.inArray(idCountry, countriesNeedIDNumber) >= 0)45 $('.dni'+(suffix !== undefined ? '_'+suffix : '')).slideDown('slow');46 else47 $('.dni'+(suffix !== undefined ? '_'+suffix : '')).slideUp('fast');48}49function updateZipCode(suffix)50{51 var idCountry = parseInt($('select#id_country'+(suffix !== undefined ? '_'+suffix : '')).val());52 53 if (countriesNeedZipCode[idCountry] != 0)54 $('.postcode'+(suffix !== undefined ? '_'+suffix : '')).slideDown('slow');55 else56 $('.postcode'+(suffix !== undefined ? '_'+suffix : '')).slideUp('fast');...
Using AI Code Generation
1const {expect} = require('unexpected');2expect('foo', 'to end with', 'oo');3const {expect} = require('unexpected');4expect('foo', 'to end with', 'oo');5const {expect} = require('unexpected');6expect('foo', 'to end with', 'oo');7const {expect} = require('unexpected');8expect('foo', 'to end with', 'oo');9const {expect} = require('unexpected');10expect('foo', 'to end with', 'oo');11const {expect} = require('unexpected');12expect('foo', 'to end with', 'oo');13const {expect} = require('unexpected');14expect('foo', 'to end with', 'oo');15const {expect} = require('unexpected');16expect('foo', 'to end with', 'oo');17const {expect} = require('unexpected');18expect('foo', 'to end with', 'oo');19const {expect} = require('unexpected');20expect('foo', 'to end with', 'oo');21const {expect} = require('unexpected');22expect('foo', 'to end with', 'oo');23const {expect} = require('unexpected');24expect('foo', 'to end with', 'oo');25const {expect} = require('unexpected');26expect('foo', 'to end with', 'oo');27const {expect} = require('unexpected');28expect('foo', 'to end with', 'oo');
Using AI Code Generation
1const expect = require('unexpected')2 .clone()3 .use(require('unexpected-sinon'));4const sinon = require('sinon');5const nock = require('nock');6const chai = require('chai');7const chaiAsPromised = require('chai-as-promised');8chai.use(chaiAsPromised);9const expectChai = chai.expect;10const chaiHttp = require('chai-http');11chai.use(chaiHttp);12const mocha = require('mocha');13const it = mocha.it;14const describe = mocha.describe;15const chaiAsPromised = require('chai-as-promised');16chai.use(chaiAsPromised);17const chaiArrays = require('chai-arrays');18chai.use(chaiArrays);19const chaiDatetime = require('chai-datetime');20chai.use(chaiDatetime);21const chaiJquery = require('chai-jquery');22chai.use(chaiJquery);23const chaiString = require('chai-string');24chai.use(chaiString);25const chaiThings = require('chai-things');26chai.use(chaiThings);27const chaiXml = require('chai-xml');28chai.use(chaiXml);29const chaiSpies = require('chai-spies');30chai.use(chaiSpies);31const chaiFs = require('chai-fs');32chai.use(chaiFs);33const chaiLike = require('chai-like');34chai.use(chaiLike);35const chaiJsonSchema = require('chai-json-schema');36chai.use(chaiJsonSchema);37const chaiFuzzy = require('chai-fuzzy');38chai.use(chaiFuzzy);39const chaiHttp = require('chai-http');40chai.use(chaiHttp);41const chaiXml = require('chai-xml');42chai.use(chaiXml);
Using AI Code Generation
1const expect = require('unexpected').clone();2const unexpectedSinon = require('unexpected-sinon');3const sinon = require('sinon');4expect.use(unexpectedSinon);5describe('test', () => {6 it('test', () => {7 const spy = sinon.spy();8 spy('test');9 expect(spy, 'was called once');10 });11});12module.exports = (unexpected, sinon) => {13 unexpected.addAssertion('<spy> [not] was called [once]', (expect, subject) => {14 expect(subject, '[not] to have calls satisfying', () => {});15 });16};
Using AI Code Generation
1const unexpected = require('unexpected');2const unexpectedSinon = require('unexpected-sinon');3const sinon = require('sinon');4const expect = unexpected.clone()5 .use(unexpectedSinon);6const myFn = sinon.spy();7myFn('foo');8expect(myFn, 'was called');9const unexpected = require('unexpected');10const unexpectedSinon = require('unexpected-sinon');11const sinon = require('sinon');12const expect = unexpected.clone()13 .use(unexpectedSinon);14const myFn = sinon.spy();15myFn('foo');16expect(myFn, 'was called');17const unexpected = require('unexpected');18const unexpectedSinon = require('unexpected-sinon');19const sinon = require('sinon');20const expect = unexpected.clone()21 .use(unexpectedSinon);22const myFn = sinon.spy();23myFn('foo');24expect(myFn, 'was called');25const unexpected = require('unexpected');26const unexpectedSinon = require('unexpected-sinon');27const sinon = require('sinon');28const expect = unexpected.clone()29 .use(unexpectedSinon);30const myFn = sinon.spy();31myFn('foo');32expect(myFn, 'was called');33const unexpected = require('unexpected');34const unexpectedSinon = require('unexpected-sinon');35const sinon = require('sinon');36const expect = unexpected.clone()37 .use(unexpectedSinon);38const myFn = sinon.spy();39myFn('foo');40expect(myFn, 'was called');41const unexpected = require('unexpected');42const unexpectedSinon = require('unexpected-sinon');43const sinon = require('sinon');44const expect = unexpected.clone()45 .use(unexpectedSinon);46const myFn = sinon.spy();47myFn('foo');48expect(myFn, 'was called');49const unexpected = require('unexpected');50const unexpectedSinon = require('unexpected-sinon');51const sinon = require('sinon');52const expect = unexpected.clone()53 .use(unexpectedSinon);54const myFn = sinon.spy();55myFn('foo');56expect(myFn, 'was called');57const unexpected = require('unexpected');
Using AI Code Generation
1var expect = require('unexpected');2var unexpected = require('unexpected');3var unexpectedSinon = require('unexpected-sinon');4var sinon = require('sinon');5var unexpected = require('unexpected');6var unexpectedSinon = require('unexpected-sinon');7var sinon = require('sinon');8var unexpected = require('unexpected');9var unexpectedSinon = require('unexpected-sinon');10var sinon = require('sinon');11var unexpected = require('unexpected');12var unexpectedSinon = require('unexpected-sinon');13var sinon = require('sinon');14var expect = require('unexpected');15var unexpected = require('unexpected');16var unexpectedSinon = require('unexpected-sinon');17var sinon = require('sinon');18var unexpected = require('unexpected');19var unexpectedSinon = require('unexpected-sinon');20var sinon = require('sinon');21var unexpected = require('unexpected');22var unexpectedSinon = require('unexpected-sinon');23var sinon = require('sinon');24var unexpected = require('unexpected');25var unexpectedSinon = require('unexpected-sinon');26var sinon = require('sinon');27var expect = require('unexpected');28var unexpected = require('unexpected');29var unexpectedSinon = require('unexpected-sinon');30var sinon = require('sinon');31var unexpected = require('unexpected');32var unexpectedSinon = require('unexpected-sinon');33var sinon = require('sinon');34var unexpected = require('unexpected');35var unexpectedSinon = require('unexpected-sinon');36var sinon = require('sinon');37var unexpected = require('unexpected');38var unexpectedSinon = require('unexpected-sinon');39var sinon = require('sinon');40var expect = require('unexpected');41var unexpected = require('unexpected');42var unexpectedSinon = require('unexpected-sinon');43var sinon = require('sinon');44var unexpected = require('unexpected');45var unexpectedSinon = require('unexpected-sinon');46var sinon = require('sinon');47var unexpected = require('unexpected');48var unexpectedSinon = require('unexpected-sinon');49var sinon = require('sinon');50var unexpected = require('unexpected');51var unexpectedSinon = require('unexpected-sinon');52var sinon = require('sinon');53var expect = require('unexpected');54var unexpected = require('unexpected');55var unexpectedSinon = require('unexpected-sinon');
Using AI Code Generation
1const expect = require('unexpected').clone();2expect.addAssertion('<string> to be a string', (expect, subject) => {3 expect(subject, 'to be a', 'string');4});5expect('test', 'to be a string');6const expect = require('unexpected').clone();7expect.addAssertion('<string> to be a string', (expect, subject) => {8 expect(subject, 'to be a', 'string');9});10expect('test', 'to be a string');11const expect = require('unexpected').clone();12expect.addAssertion('<string> to be a string', (expect, subject) => {13 expect(subject, 'to be a', 'string');14});15expect('test', 'to be a string');16const expect = require('unexpected').clone();17expect.addAssertion('<string> to be a string', (expect, subject) => {18 expect(subject, 'to be a', 'string');19});20expect('test', 'to be a string');21const expect = require('unexpected').clone();22expect.addAssertion('<string> to be a string', (expect, subject) => {23 expect(subject, 'to be a', 'string');24});25expect('test', 'to be a string');26const expect = require('unexpected').clone();27expect.addAssertion('<string> to be a string', (expect, subject) => {28 expect(subject, 'to be a', 'string');29});30expect('test', 'to be a string');31const expect = require('unexpected').clone();32expect.addAssertion('<string> to be a string', (expect, subject) => {33 expect(subject
Using AI Code Generation
1var expect = require('unexpected')2 .clone()3 .use(require('unexpected-sinon'));4var sinon = require('sinon');5describe('test', function () {6 it('should spy on a function', function () {7 var spy = sinon.spy();8 spy('hello');9 expect(spy, 'to have a call satisfying', ['hello']);10 });11});12 at Object.<anonymous> (test.js:14:18)13> var expect = require('unexpected')14> .clone()15> .use(require('unexpected-sinon'));16> var sinon = require('sinon');17> describe('test', function () {18> it('should spy on a function', function () {19> var spy = sinon.spy();20> spy('hello');21> expect(spy, 'to have a c
Using AI Code Generation
1const expect = require('unexpected');2const suffix = require('unexpected-suffix');3expect.installPlugin(suffix);4describe('test', function(){5 it('should have suffix', function(){6 expect('test', 'to have suffix', 'st');7 });8});9TypeError: expect(...).to.have.suffix is not a function
Using AI Code Generation
1const { expect } = require('unexpected');2const { createUnsandboxedChildProcess } = require('unexpected-sinon');3const sinon = require('sinon');4const childProcess = createUnsandboxedChildProcess(expect);5expect.addAssertion('<any> to have been called with <any>', function (expect, subject, value) {6 return expect(subject, 'was called with', value);7});8expect.addAssertion('<string> to be the expected <string>', function (expect, subject, value) {9 return expect(subject, 'to be', value);10});11expect.addAssertion('<string> to match the expected <string>', function (expect, subject, value) {12 return expect(subject, 'to match', value);13});14describe('test', () => {15 it('should pass', () => {16 const stub = sinon.stub();17 stub('foo');18 return expect(stub, 'to have been called with', 'foo');19 });20 it('should fail', () => {21 const stub = sinon.stub();22 stub('foo');23 return expect(stub, 'to have been called with', 'bar');24 });25 it('should pass', () => {26 const stub = sinon.stub();27 stub('foo');28 return expect(stub, 'to be the expected', 'foo');29 });30 it('should fail', () => {31 const stub = sinon.stub();32 stub('foo');33 return expect(stub, 'to be the expected', 'bar');34 });35 it('should pass', () => {36 const stub = sinon.stub();37 stub('foo');38 return expect(stub, 'to match the expected', 'foo');39 });40 it('should fail', () => {41 const stub = sinon.stub();42 stub('foo');43 return expect(stub, 'to match the expected', 'bar');44 });45});
Using AI Code Generation
1expect('hello!', 'to end with', '!');2expect.addAssertion('<string> to end with <string>', function(3) {4 expect(subject.slice(-value.length), 'to equal', value);5});6expect('hello!', 'to end with', '!');7expect.addAssertion('<string> to end with <string>', function(8) {9 expect(subject.slice(-value.length), 'to equal', value);10});11expect('hello!', 'to end with', '!');12expect.addAssertion('<string> to end with <string>', function(13) {14 expect(subject.slice(-value.length), 'to equal', value);15});16expect('hello!', 'to end with', '!');17expect.addAssertion('<string> to end with <string>', function(18) {19 expect(subject.slice(-value.length), 'to equal', value);20});21expect('hello!', 'to end with', '!');22expect.addAssertion('<string> to end with <string>', function23expect('hello!', 'to end with', '!');24expect.addAssertion('<string> to end with <string>', function(25) {26 expect(subject.slice(-value.length), 'to equal', value);27});28expect('hello!', 'to end with', '!');29expect.addAssertion('<string> to end with <string>', function(30) {31 expect(subject.slice(-value.length), 'to equal', value);32});33expect('hello!', 'to end with', '!');34expect.addAssertion('<string> to end with <string>', function(35) {36 expect(subject.slice(-value.length), 'to equal', value);37});38expect('hello!', 'to end with', '!');39expect.addAssertion('<string> to end with <string>', function(40) {41 expect(subject.slice(-value.length), 'to equal', value);42});43expect('hello!', 'to end with', '!');44expect.addAssertion('<string> to end with <string>', function
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!!