How to use isAlternation method in unexpected

Best JavaScript code snippet using unexpected

CONG_TY_CUNG_NGANH.js

Source:CONG_TY_CUNG_NGANH.js Github

copy

Full Screen

1function CafeF_CongtyCungNganh(instanceName)2{3 this.host = 'http://solieu.cafef.vn';4 //this.host = 'http://localhost:8084';5 this.script_folder = this.host + '/www/cafef/';6 this.script_object = null;7 this.instance_name = instanceName;8 this.Symbol = '';9 10 this.default_page_size = 10;11 12 this.page_size = this.default_page_size;13 this.page_index = 1;14 this.record_count = 0;15 this.page_count = 1;16 this.GetSymbol = function()17 {18// var query = window.location.href;19// query = query.toLowerCase();20// 21// if (query.indexOf('hose') > 0 || query.indexOf('hastc') > 0)22// {23// if (query.indexOf('hose') > 0)24// {25// query = query.substring(query.indexOf('hose/') + 5);26// }27// else28// {29// query = query.substring(query.indexOf('hastc/') + 6);30// }31// if (query.indexOf('thong-tin-tai-chinh') >= 0 || 32// query.indexOf('thong-tin-chung') >= 0 || 33// query.indexOf('ban-lanh-dao') >= 0 || 34// query.indexOf('bao-cao-tai-chinh') >= 0)35// {36// query = query.substring(0, query.indexOf('/'));37// }38// else39// {40// query = query.substring(0, query.indexOf('-'));41// }42// }43// else44// {45// query = query.substring(query.indexOf('thong-tin-cong-ty/') + 18);46// query = query.substring(0, query.indexOf('.chn'));47// }48// return query.toUpperCase();49 var query = window.location.href;50 query = query.toLowerCase();51 if(query.indexOf('thong-tin-chung/')<0 && query.indexOf('thong-tin-tai-chinh/')<0 && query.indexOf('ban-lanh-dao/')<0 && query.indexOf('bao-cao-tai-chinh/')<0)52 {53 if (query.indexOf('hose') > 0 || query.indexOf('hastc') > 0)54 {55 if (query.indexOf('hose') > 0)56 {57 query = query.substring(query.indexOf('hose/') + 5);58 }59 else60 {61 query = query.substring(query.indexOf('hastc/') + 6);62 }63 if (query.indexOf('thong-tin-tai-chinh') >= 0 || 64 query.indexOf('thong-tin-chung') >= 0 || 65 query.indexOf('ban-lanh-dao') >= 0 || 66 query.indexOf('bao-cao-tai-chinh') >= 0)67 {68 query = query.substring(0, query.indexOf('/'));69 }70 else71 {72 query = query.substring(0, query.indexOf('-'));73 }74 }75 else76 {77 query = query.substring(query.indexOf('thong-tin-cong-ty/') + 18);78 query = query.substring(0, query.indexOf('.chn'));79 }80 }81 else82 {83 if(query.indexOf('thong-tin-chung/')>0)84 {85 query = query.substring(query.indexOf('thong-tin-chung/') + 16);86 }87 if(query.indexOf('thong-tin-tai-chinh/')>0)88 {89 //i=length('thong-tin-tai-chinh/');90 query = query.substring(query.indexOf('thong-tin-tai-chinh/') + 20);91 }92 if(query.indexOf('ban-lanh-dao/')>0)93 {94 query = query.substring(query.indexOf('ban-lanh-dao/') + 13);95 }96 if(query.indexOf('bao-cao-tai-chinh/')>0)97 {98 query = query.substring(query.indexOf('bao-cao-tai-chinh/') + 18);99 }100 query = query.substring(0, query.indexOf('-'));101 }102 return query.toUpperCase();103 }104 105 this.CreateCssLink = function(href)106 {107 var css = document.createElement('link');108 css.type = 'text/css';109 css.rel = 'stylesheet';110 css.href = href;111 var head = document.getElementsByTagName('head')[0];112 head.appendChild(css);113 }114 115 this.InitScript = function()116 {117 this.Symbol = this.GetSymbol();118 this.CreateCssLink(this.script_folder + 'css/cafef.css');119 120 document.getElementById('CafeF_CongtyCungNganh').innerHTML = '<div class="cf_WCBox"><div class="cf_BoxHeader"><div></div></div><div class="cf_BoxContent" style="padding: 5px 10px 5px 10px;"><table class="Cafef_RelatedCompany" cellpadding="0" cellspacing="0"><tr><td style="font-weight: bold; font-size: 15px; text-align:left;">CÔNG TY CÙNG NGÀNH</td></tr><tr><td style="font-weight: bold; font-size: 13px;" id="CafeF_SameIndustry_Name"></td></tr><tr><td id="CafeF_SameIndustry_Dulieu" class="Dulieu"></td></tr><tr><td id="CafeF_SameIndustry_Phantrang" class="Phantrang"></td></tr><tr><td id="CafeF_SameIndustry_GhiChu" class="Ghichu"></td></tr></table></div><div class="cf_BoxFooter"><div></div></div></div>';121 }122 123 this.LoadData = function(pageIndex)124 {125 this.page_index = pageIndex;126 this.CreateScriptObject(this.host + '/ProxyHandler.ashx?RequestName=SameIndustry&CallBack=' + this.instance_name + '.OnLoaded&RequestType=json&Symbol=' + this.Symbol + '&PageSize=' + this.page_size + '&PageIndex=' + this.page_index);127 }128 129 this.OnLoaded = function(data, methodName)130 {131 var json = eval(data);132 var output = '<table cellpadding="3" cellspacing="0"><tr><th style="border-right: solid 1px #fff;text-align:left;">Mã CK</th><th style="border-right: solid 1px #fff;text-align:right;">Giá</th><th style="border-right: solid 1px #fff;text-align:right;">Thay đổi</th><th style="width:110px;">Vốn hóa thị trường<br />(Tỷ đồng)</th></tr>';133 var isAlternation = false;134 for (var i = 0; i < json.FinanceStatements.length; i++)135 {136 output += '<tr' + (isAlternation ? ' class="Alternation"' : '') + '><td class="Symbol"><a href="' + CafeF_JSLibrary.GetCompanyInfoLink(json.FinanceStatements[i].Symbol) + '">' + json.FinanceStatements[i].Symbol + '</a></td><td>' + this.FormatNumber(json.FinanceStatements[i].Price, true) + '</td><td>' + this.FormatChangeValue(json.FinanceStatements[i].Change, json.FinanceStatements[i].Percent) + '</td><td>' + this.FormatNumber(json.FinanceStatements[i].Capital, true) + '</td></tr>';137 isAlternation = !isAlternation;138 }139 output += '</table>';140 141 document.getElementById('CafeF_SameIndustry_Dulieu').innerHTML = output;142 document.getElementById('CafeF_SameIndustry_GhiChu').innerHTML = 'Trang ' + json.PageIndex + '/' + json.PageCount + ' (Tổng số: ' + json.RecordCount + ' công ty)';143 144 var page = '';145 if (json.PageCount > 1)146 {147 if (json.PageIndex > 1)148 {149 page += '<img alt="" onclick="' + this.instance_name + '.LoadData(' + (json.PageIndex - 1) + ')" src="images/paging_prev_enable.png" />';150 }151 else152 {153 page += '<img alt="" src="images/paging_prev_disable.png" />';154 }155 156 for (var j = 1; j <= json.PageCount; j++)157 {158 if (j == json.PageIndex)159 {160 page += '&nbsp;[' + j + ']&nbsp;';161 }162 else163 {164 page += '&nbsp;<a href="javascript:void(0)" onclick="' + this.instance_name + '.LoadData(' + j + ')">' + j + '</a>&nbsp;';165 }166 }167 168 if (json.PageIndex < json.PageCount)169 {170 page += '<img alt="" onclick="' + this.instance_name + '.LoadData(' + (json.PageIndex + 1) + ')" src="images/paging_next_enable.png" />';171 }172 else173 {174 page += '<img alt="" src="images/paging_next_disable.png" />';175 }176 }177 document.getElementById('CafeF_SameIndustry_Phantrang').innerHTML = page;178 if (json.OtherData) document.getElementById('CafeF_SameIndustry_Name').innerHTML = json.OtherData;179 180 this.record_count = json.RecordCount;181 this.page_index = json.PageIndex;182 this.page_count = json.PageCount;183 }184 185 this.CreateScriptObject = function(src)186 {187 if (this.script_object != null)188 {189 this.RemoveScriptObject();190 }191 192 this.script_object = document.createElement('script');193 this.script_object.setAttribute('type','text/javascript');194 this.script_object.setAttribute('src', src);195 196 var head = document.getElementsByTagName('head')[0];197 head.appendChild(this.script_object);198 }199 this.RemoveScriptObject = function()200 {201 this.script_object.parentNode.removeChild(this.script_object) ;202 this.script_object = null ;203 }204 205 this.FormatChangeValue = function(value, percent)206 {207 var output = '';208 if (value > 0)209 {210 output = '<span style="color: #008000">+' + this.FormatNumber(value, true) + '(+' + this.FormatNumber(percent, true) + '%)</span>';211 }212 else if (value < 0)213 {214 output = '<span style="color: #cc0000">' + this.FormatNumber(value, true) + '(' + this.FormatNumber(percent, true) + '%)</span>';215 }216 else217 {218 output = '<span style="color: #ff9900">0(0%)</span>';219 }220 return output;221 }222 this.FormatNumber = function(value, displayZero)223 {224 if (value == '') return (displayZero ? '0' : '');225 try226 {227 var number = parseFloat(value);228 value = this.FormatNumber1(number, 2, '.', ',');229 return (value);230 }231 catch (err)232 {233 return (displayZero ? '0' : '');234 }235 }236 this.FormatNumber1 = function(number, decimals, decimalSeparator, thousandSeparator) 237 {238 var number = number.toFixed(decimals);239 240 var temp = number.toString();241 242 var f = temp.substr(temp.length - decimals, decimals);243 244 while (f != '' && f.charAt(f.length - 1) == '0') f = f.substr(0, f.length - 1);245 246 if (f != '') f = decimalSeparator + f;247 248 var t = temp.substr(0, temp.length - 3);249 250 if (thousandSeparator != '' && t.length > 3) 251 {252 h = t;253 t = '';254 255 for (j = 3; j < h.length; j += 3) 256 {257 i = h.slice(h.length - j, h.length - j + 3);258 t = thousandSeparator + i + t + '';259 }260 261 j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));262 t = j + t;263 }264 265 temp = t + f;266 267 return temp;268 }269}270//document.write('<div id="CafeF_CongtyCungNganh"></div>');271var container = document.getElementById('CafeF_CongtyCungNganh');272if (container)273{274 var cafef_cong_ty_cung_nganh = new CafeF_CongtyCungNganh('cafef_cong_ty_cung_nganh');275 cafef_cong_ty_cung_nganh.InitScript();276 277 if (container.delay)278 {279 setTimeout('cafef_cong_ty_cung_nganh.LoadData(1)', parseInt(container.delay));280 }281 else282 {283 cafef_cong_ty_cung_nganh.LoadData(1);284 }...

Full Screen

Full Screen

CONG_TY_CO_EPS_TUONG_DUONG.js

Source:CONG_TY_CO_EPS_TUONG_DUONG.js Github

copy

Full Screen

1function CafeF_CongtyCoEPSTuongduong(instanceName)2{3 this.host = 'http://solieu.cafef.vn';4 //this.host = 'http://localhost:8084';5 this.script_folder = this.host + '/www/cafef/';6 this.script_object = null;7 this.instance_name = instanceName;8 this.Symbol = '';9 10 this.default_page_size = 10;11 12 this.page_size = this.default_page_size;13 this.page_index = 1;14 this.record_count = 0;15 this.page_count = 1;16 this.GetSymbol = function()17 {18 var query = window.location.href;19 query = query.toLowerCase();20 if(query.indexOf('thong-tin-chung/')<0 && query.indexOf('thong-tin-tai-chinh/')<0 && query.indexOf('ban-lanh-dao/')<0 && query.indexOf('bao-cao-tai-chinh/')<0)21 {22 if (query.indexOf('hose') > 0 || query.indexOf('hastc') > 0)23 {24 if (query.indexOf('hose') > 0)25 {26 query = query.substring(query.indexOf('hose/') + 5);27 }28 else29 {30 query = query.substring(query.indexOf('hastc/') + 6);31 }32 if (query.indexOf('thong-tin-tai-chinh') >= 0 || 33 query.indexOf('thong-tin-chung') >= 0 || 34 query.indexOf('ban-lanh-dao') >= 0 || 35 query.indexOf('bao-cao-tai-chinh') >= 0)36 {37 query = query.substring(0, query.indexOf('/'));38 }39 else40 {41 query = query.substring(0, query.indexOf('-'));42 }43 }44 else45 {46 query = query.substring(query.indexOf('thong-tin-cong-ty/') + 18);47 query = query.substring(0, query.indexOf('.chn'));48 }49 }50 else51 {52 if(query.indexOf('thong-tin-chung/')>0)53 {54 query = query.substring(query.indexOf('thong-tin-chung/') + 16);55 }56 if(query.indexOf('thong-tin-tai-chinh/')>0)57 {58 //i=length('thong-tin-tai-chinh/');59 query = query.substring(query.indexOf('thong-tin-tai-chinh/') + 20);60 }61 if(query.indexOf('ban-lanh-dao/')>0)62 {63 query = query.substring(query.indexOf('ban-lanh-dao/') + 13);64 }65 if(query.indexOf('bao-cao-tai-chinh/')>0)66 {67 query = query.substring(query.indexOf('bao-cao-tai-chinh/') + 18);68 }69 query = query.substring(0, query.indexOf('-'));70 }71 return query.toUpperCase();72 }73 this.CreateCssLink = function(href)74 {75 var css = document.createElement('link');76 css.type = 'text/css';77 css.rel = 'stylesheet';78 css.href = href;79 var head = document.getElementsByTagName('head')[0];80 head.appendChild(css);81 }82 83 this.InitScript = function()84 {85 this.Symbol = this.GetSymbol();86 this.CreateCssLink(this.script_folder + 'css/cafef.css');87 88 document.getElementById('CafeF_CongtyCoEPSTuongduong').innerHTML = '<div class="cf_WCBox"><div class="cf_BoxHeader"><div></div></div><div class="cf_BoxContent" style="padding: 5px 10px 5px 10px;"><table class="Cafef_RelatedCompany" cellpadding="0" cellspacing="0"><tr><td style="font-weight: bold; font-size: 15px; text-align:left;">CÔNG TY CÓ EPS TƯƠNG ĐƯƠNG</td></tr><tr><td id="CafeF_EquivalentEPS_Dulieu" class="Dulieu"></td></tr><tr><td id="CafeF_EquivalentEPS_Phantrang" class="Phantrang"></td></tr><tr><td id="CafeF_EquivalentEPS_Note" class="Note"></td><tr><td id="CafeF_EquivalentEPS_GhiChu" class="Ghichu"></td></tr></table></div><div class="cf_BoxFooter"><div></div></div></div>';89 }90 91 this.LoadData = function(pageIndex)92 {93 this.page_index = pageIndex;94 this.CreateScriptObject(this.host + '/ProxyHandler.ashx?RequestName=EquivalentEPS&CallBack=' + this.instance_name + '.OnLoaded&RequestType=json&Symbol=' + this.Symbol + '&PageSize=' + this.page_size + '&PageIndex=' + this.page_index);95 }96 97 this.OnLoaded = function(data, methodName)98 {99 var json = eval(data);100 var output = '<table cellpadding="3" cellspacing="0"><tr><th style="border-right: solid 1px #fff;text-align:left;">Mã CK</th><th style="border-right: solid 1px #fff;text-align:right;">EPS</th><th style="border-right: solid 1px #fff;text-align:right;">Giá</th><th style="text-align:right;">Thay đổi</th></tr>';101 var isAlternation = false;102 for (var i = 0; i < json.FinanceStatements.length; i++)103 {104 output += '<tr' + (isAlternation ? ' class="Alternation"' : '') + '><td class="Symbol"><a href="' + CafeF_JSLibrary.GetCompanyInfoLink(json.FinanceStatements[i].Symbol) + '">' + json.FinanceStatements[i].Symbol + '</a></td><td>' + (json.FinanceStatements[i].EPS > 0 ? this.FormatNumber(json.FinanceStatements[i].EPS, true) : 'N/A') + '</td><td>' + this.FormatNumber(json.FinanceStatements[i].Price, true) + '</td><td>' + this.FormatChangeValue(json.FinanceStatements[i].Change, json.FinanceStatements[i].Percent) + '</td></tr>';105 isAlternation = !isAlternation;106 }107 output += '</table>';108 109 document.getElementById('CafeF_EquivalentEPS_Dulieu').innerHTML = output;110 document.getElementById('CafeF_EquivalentEPS_Note').innerHTML = 'Các công ty có EPS tương đương trên sàn ' + (json.OtherData == 1 ? 'HoSE' : 'HaSTC') + '<br>EPS lấy từ Bản tin ' + (json.OtherData == 1 ? 'HoSE' : 'HaSTC') + '<br>(EPS +/- 0.5)';111 document.getElementById('CafeF_EquivalentEPS_GhiChu').innerHTML = 'Trang ' + json.PageIndex + '/' + json.PageCount + ' (Tổng số: ' + json.RecordCount + ' công ty)';112 113 var page = '';114 if (json.PageCount > 1)115 {116 if (json.PageIndex > 1)117 {118 page += '<img alt="" onclick="' + this.instance_name + '.LoadData(' + (json.PageIndex - 1) + ')" src="images/paging_prev_enable.png" />';119 }120 else121 {122 page += '<img alt="" src="images/paging_prev_disable.png" />';123 }124 125 for (var j = 1; j <= json.PageCount; j++)126 {127 if (j == json.PageIndex)128 {129 page += '&nbsp;[' + j + ']&nbsp;';130 }131 else132 {133 page += '&nbsp;<a href="javascript:void(0)" onclick="' + this.instance_name + '.LoadData(' + j + ')">' + j + '</a>&nbsp;';134 }135 }136 137 if (json.PageIndex < json.PageCount)138 {139 page += '<img alt="" onclick="' + this.instance_name + '.LoadData(' + (json.PageIndex + 1) + ')" src="images/paging_next_enable.png" />';140 }141 else142 {143 page += '<img alt="" src="images/paging_next_disable.png" />';144 }145 }146 document.getElementById('CafeF_EquivalentEPS_Phantrang').innerHTML = page;147 //document.getElementById('CafeF_EquivalentEPS_Name').innerHTML = json.OtherData;148 149 this.record_count = json.RecordCount;150 this.page_index = json.PageIndex;151 this.page_count = json.PageCount;152 }153 154 this.CreateScriptObject = function(src)155 {156 if (this.script_object != null)157 {158 this.RemoveScriptObject();159 }160 161 this.script_object = document.createElement('script');162 this.script_object.setAttribute('type','text/javascript');163 this.script_object.setAttribute('src', src);164 165 var head = document.getElementsByTagName('head')[0];166 head.appendChild(this.script_object);167 }168 this.RemoveScriptObject = function()169 {170 this.script_object.parentNode.removeChild(this.script_object) ;171 this.script_object = null ;172 }173 174 this.FormatChangeValue = function(value, percent)175 {176 var output = '';177 if (value > 0)178 {179 output = '<span style="color: #008000">+' + this.FormatNumber(value, true) + '(+' + this.FormatNumber(percent, true) + '%)</span>';180 }181 else if (value < 0)182 {183 output = '<span style="color: #cc0000">' + this.FormatNumber(value, true) + '(' + this.FormatNumber(percent, true) + '%)</span>';184 }185 else186 {187 output = '<span style="color: #ff9900">0(0%)</span>';188 }189 return output;190 }191 this.FormatNumber = function(value, displayZero)192 {193 if (value == '') return (displayZero ? '0' : '');194 try195 {196 var number = parseFloat(value);197 value = this.FormatNumber1(number, 2, '.', ',');198 return (value);199 }200 catch (err)201 {202 return (displayZero ? '0' : '');203 }204 }205 this.FormatNumber1 = function(number, decimals, decimalSeparator, thousandSeparator) 206 {207 var number = number.toFixed(decimals);208 209 var temp = number.toString();210 211 var f = temp.substr(temp.length - decimals, decimals);212 213 while (f != '' && f.charAt(f.length - 1) == '0') f = f.substr(0, f.length - 1);214 215 if (f != '') f = decimalSeparator + f;216 217 var t = temp.substr(0, temp.length - 3);218 219 if (thousandSeparator != '' && t.length > 3) 220 {221 h = t;222 t = '';223 224 for (j = 3; j < h.length; j += 3) 225 {226 i = h.slice(h.length - j, h.length - j + 3);227 t = thousandSeparator + i + t + '';228 }229 230 j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));231 t = j + t;232 }233 234 temp = t + f;235 236 return temp;237 }238}239//document.write('<div id="CafeF_CongtyCoEPSTuongduong"></div>');240var container = document.getElementById('CafeF_CongtyCoEPSTuongduong');241if (container)242{243 var cafef_cong_ty_co_eps_tuong_duong = new CafeF_CongtyCoEPSTuongduong('cafef_cong_ty_co_eps_tuong_duong');244 cafef_cong_ty_co_eps_tuong_duong.InitScript();245 246 if (container.delay)247 {248 setTimeout('cafef_cong_ty_co_eps_tuong_duong.LoadData(1)', parseInt(container.delay));249 }250 else251 {252 cafef_cong_ty_co_eps_tuong_duong.LoadData(1);253 }...

Full Screen

Full Screen

expandAssertion.js

Source:expandAssertion.js Github

copy

Full Screen

1const extend = require('./utils').extend;2function isFlag(token) {3 return token.slice(0, 1) === '[' && token.slice(-1) === ']';4}5function isAlternation(token) {6 return token.slice(0, 1) === '(' && token.slice(-1) === ')';7}8function removeEmptyStrings(texts) {9 return texts.filter((text) => text !== '');10}11function createPermutations(tokens, index) {12 if (index === tokens.length) {13 return [{ text: '', flags: {}, alternations: [] }];14 }15 const token = tokens[index];16 const tail = createPermutations(tokens, index + 1);17 if (isFlag(token)) {18 const flag = token.slice(1, -1);19 return tail20 .map((pattern) => {21 const flags = {};22 flags[flag] = true;23 return {24 text: `${flag} ${pattern.text}`,25 flags: extend(flags, pattern.flags),26 alternations: pattern.alternations,27 };28 })29 .concat(30 tail.map((pattern) => {31 const flags = {};32 flags[flag] = false;33 return {34 text: pattern.text,35 flags: extend(flags, pattern.flags),36 alternations: pattern.alternations,37 };38 })39 );40 } else if (isAlternation(token)) {41 return token42 .substr(1, token.length - 2) // Remove parentheses43 .split(/\|/)44 .reduce(45 (result, alternation) =>46 result.concat(47 tail.map(({ text, flags, alternations }) => ({48 // Make sure that an empty alternation doesn't produce two spaces:49 text: alternation ? alternation + text : text.replace(/^ /, ''),50 flags,51 alternations: [alternation, ...alternations],52 }))53 ),54 []...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const unexpected = require('unexpected');2const unexpectedHtmlLike = require('unexpected-htmllike-assertions');3const unexpectedReact = require('unexpected-react');4const expect = unexpected.clone()5 .use(unexpectedHtmlLike)6 .use(unexpectedReact);7const React = require('react');8const ReactDOMServer = require('react-dom/server');9const App = React.createClass({10 render() {11 return (12 );13 }14});15const app = ReactDOMServer.renderToStaticMarkup(16);17expect(app, 'to have rendered',18);19expect(app, 'to have rendered',20);21expect(app, 'to have rendered',22);23expect(app, 'to have rendered',24);25expect(app, 'to have rendered',26);27expect(app, 'to have rendered',28);29expect(app, 'to have rendered',30);31expect(app, 'to have rendered',32);33expect(app, 'to have rendered',34);

Full Screen

Using AI Code Generation

copy

Full Screen

1expect('foo', 'to be one of', ['bar', 'baz']);2expect('foo', 'to be one of', ['bar', 'baz', 'foo']);3expect('foo', 'to be one of', ['bar', 'baz']);4expect('foo', 'to be one of', ['bar', 'baz', 'foo']);5expect('foo', 'to be one of', ['bar', 'baz']);6expect('foo', 'to be one of', ['bar', 'baz', 'foo']);7expect('foo', 'to be one of', ['bar', 'baz']);8expect('foo', 'to be one of', ['bar', 'baz', 'foo']);9expect('foo', 'to be one of', ['bar', 'baz']);10expect('foo', 'to be one of', ['bar', 'baz', 'foo']);11expect('foo', 'to be one of', ['bar', 'baz']);12expect('foo', 'to be one of', ['bar', 'baz', 'foo']);13expect('foo', 'to be one of', ['bar', 'baz']);14expect('foo', 'to be one of', ['bar', 'baz', 'foo']);15expect('foo', 'to be one of', ['bar', 'baz']);16expect('foo', 'to be one of', ['bar', 'baz', 'foo']);17expect('foo', 'to be one of', ['bar', 'baz']);18expect('foo', 'to be one of', ['bar', 'baz', 'foo']);19expect('foo', 'to be one of', ['bar', 'baz']);20expect('foo', 'to be one of', ['bar', '

Full Screen

Using AI Code Generation

copy

Full Screen

1var expect = require('unexpected').clone();2var isAlternation = require('unexpected-htmllike/isAlternation');3expect.output.preferredWidth = 80;4expect.addAssertion('<array> to have an alternation', function (expect, subject) {5 expect(isAlternation(subject), 'to be true');6});7expect([1, 2, 3, 4], 'to have an alternation');8expect([1, 2, 2, 3, 4], 'to have an alternation');9expect([1, 2, 3, 2, 4], 'to have an alternation');10expect([1, 2, 2, 3, 2, 4], 'to have an alternation');11expect([1, 2, 3, 3, 2, 4], 'to have an alternation');12expect([1, 2, 2, 3, 3, 2, 4], 'to have an alternation');13expect([1, 2, 2, 3, 2, 4, 4], 'to have an alternation');14expect([1, 2, 3, 3, 2, 4, 4], '

Full Screen

Using AI Code Generation

copy

Full Screen

1var expect = require('unexpected').clone().use(require('unexpected-sinon'));2var sinon = require('sinon');3var obj = {4 method: function () {5 console.log('called original method');6 }7};8var spy = sinon.spy(obj, 'method');9obj.method();10expect(spy, 'was called once');11obj.method();12expect(spy, 'was called twice');13obj.method();14expect(spy, 'was called thrice');15obj.method();16expect(spy, 'was called at least once');17obj.method();18expect(spy, 'was called at least twice');19obj.method();20expect(spy, 'was called at least thrice');21obj.method();22expect(spy, 'was called at least four times');23obj.method();24expect(spy, 'was called at least five times');25obj.method();26expect(spy, 'was called at least six times');27obj.method();28expect(spy, 'was called at least seven times');29obj.method();30expect(spy, 'was called at least eight times');31obj.method();32expect(spy, 'was called at least nine times');33obj.method();34expect(spy, 'was called at least ten times');35obj.method();36expect(spy, 'was called

Full Screen

Using AI Code Generation

copy

Full Screen

1const expect = require('unexpected')2 .clone()3 .use(require('unexpected-sinon'));4function isAlternation(str) {5 return (6 .split('')7 .every((char, index) => index % 2 === 0 ? char === 'a' : char === 'b')8 );9}10describe('isAlternation', () => {11 it('should return true if string is alternation of a and b', () => {12 expect(isAlternation('abab'), 'to be true');13 });14 it('should return false if string is not alternation of a and b', () => {15 expect(isAlternation('ababab'), 'to be false');16 });17});18it('should resolve to true', () => {19 return expect(myFunction()).to.eventually.equal(true);20});21it('should resolve to true', () => {22 return expect(myFunction()).to.eventually.be.fulfilled;23});24it('should resolve to true', () => {25 return expect(myFunction()).to.eventually.be.fulfilledWith(true);26});27it('should return a promise', () => {28 expect(myFunction()).to.be.a('promise');29});

Full Screen

Using AI Code Generation

copy

Full Screen

1var unexpected = require('unexpected');2var expect = unexpected.clone();3var unexpectedString = require('unexpected-string');4expect.installPlugin(unexpectedString);5describe('test', function () {6 it('should return true', function () {7 expect('abc', 'to be one of', ['abc', 'def']);8 });9});

Full Screen

Using AI Code Generation

copy

Full Screen

1var expect = require('unexpected');2var unexpected = new expect.AssertionLibrary();3var a = 'a';4var b = 'b';5var c = 'c';6var result = unexpected.isAlternation(a, b, c);7console.log(result);8var expect = require('unexpected');9var unexpected = new expect.AssertionLibrary();10var a = 'a';11var b = 'b';12var c = 'c';13var result = unexpected.isAlternation(a, b, c);14console.log(result);15var expect = require('unexpected');16var unexpected = new expect.AssertionLibrary();17var a = 'a';18var b = 'b';19var c = 'c';20var result = unexpected.isAlternation(a, b, c);21console.log(result);22var expect = require('unexpected');23var unexpected = new expect.AssertionLibrary();24var a = 'a';25var b = 'b';26var c = 'c';27var result = unexpected.isAlternation(a, b, c);28console.log(result);29var expect = require('unexpected');30var unexpected = new expect.AssertionLibrary();31var a = 'a';32var b = 'b';33var c = 'c';34var result = unexpected.isAlternation(a, b, c);35console.log(result);36var expect = require('unexpected');37var unexpected = new expect.AssertionLibrary();38var a = 'a';39var b = 'b';40var c = 'c';41var result = unexpected.isAlternation(a, b, c);42console.log(result);43var expect = require('unexpected');44var unexpected = new expect.AssertionLibrary();45var a = 'a';46var b = 'b';47var c = 'c';48var result = unexpected.isAlternation(a, b, c);49console.log(result);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { expect } = require('chai');2const { isAlternation } = require('unexpected');3const { describe, it } = require('mocha');4describe('isAlternation', () => {5 it('should be an alternation of the expected value', () => {6 expect('hello world', 'to be an alternation of', 'hlo wrd');7 expect('hello world', 'not to be an alternation of', 'hlo wrd');8 });9});10const { expect } = require('chai');11const { isAlternation } = require('unexpected');12const { describe, it } = require('mocha');13describe('isAlternation', () => {14 it('should be an alternation of the expected value', () => {15 expect('hello world', 'to be an alternation of', 'hlo wrd');16 expect('hello world', 'not to be an alternation of', 'hlo wrd');17 });18});19const { expect } = require('chai');20const { isAlternation } = require('unexpected');21const { describe, it } = require('mocha');22describe('isAlternation', () => {23 it('should be an alternation of the expected value', () => {24 expect('hello world', 'to be an alternation of', 'hlo wrd');25 expect('hello world', 'not to be an alternation of', 'hlo wrd');26 });27});28const { expect } = require('chai');29const { isAlternation } = require('unexpected');30const { describe, it } = require('mocha');31describe('isAlternation', () => {32 it('should be an alternation of the expected value', () => {33 expect('hello world', 'to be an alternation of', 'hlo wrd');34 expect('

Full Screen

Using AI Code Generation

copy

Full Screen

1const unexpectedString = require('unexpected-string');2const { isAlternation } = unexpectedString;3const str = 'madam';4if (isAlternation(str)) {5 console.log('It is a palindrome');6} else {7 console.log('It is not a palindrome');8}9const unexpectedString = require('unexpected-string');10const { isAlternation } = unexpectedString;11const str = 'madam';12if (isAlternation(str)) {13 console.log('It is a palindrome');14} else {15 console.log('It is not a palindrome');16}17const unexpectedString = require('unexpected-string');18const { isAlternation } = unexpectedString;19const str = 'madam';20if (isAlternation(str)) {21 console.log('It is a palindrome');22} else {23 console.log('It is not a palindrome');24}25const unexpectedString = require('unexpected-string');26const { isAlternation } = unexpectedString;27const str = 'madam';28if (isAlternation(str)) {29 console.log('It is a palindrome');30} else {31 console.log('It is not a palindrome');32}33const unexpectedString = require('unexpected-string');34const { isAlternation } = unexpectedString;35const str = 'madam';36if (isAlternation(str)) {37 console.log('It is a palindrome');38} else {39 console.log('It is not a palindrome');40}41const unexpectedString = require('unexpected-string');42const { isAlternation } = unexpectedString;

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 unexpected 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