Best JavaScript code snippet using stryker-parent
templates.test.js
Source:templates.test.js
1import { expect } from 'chai';2import templates from './templates';3import { strToEl } from './lib/utils';4/**5 *6 * @param {HTMLElement} element17 * @param {HTMLElement} element28 */9function expectEqualElements(element1, element2) {10 expect(element1.tagName).to.equal(element2.tagName);11 expect(element1.attributes.length).to.equal(element2.attributes.length);12 expect(Object.keys(element1.dataset)).to.have.members(13 Object.keys(element2.dataset),14 );15 expect(element1.classList).to.include(element2.classList);16 // compare attributes values17 for (const attribute of Object.values(element1.attributes)) {18 expect(element1.getAttribute(attribute)).to.equal(19 element2.getAttribute(attribute),20 );21 }22}23describe('templates', () => {24 describe('containerOuter', () => {25 const classes = {26 containerOuter: 'class-1',27 };28 const direction = 'rtl';29 describe('select element', () => {30 describe('search enabled', () => {31 it('returns expected html', () => {32 const isSelectElement = true;33 const isSelectOneElement = false;34 const searchEnabled = true;35 const passedElementType = 'select-multiple';36 const expectedOutput = strToEl(`37 <div38 class="${classes.containerOuter}"39 data-type="${passedElementType}"40 role="combobox"41 aria-autocomplete="list"42 aria-haspopup="true"43 aria-expanded="false"44 dir="${direction}"45 >46 </div>47 `);48 const actualOutput = templates.containerOuter(49 classes,50 direction,51 isSelectElement,52 isSelectOneElement,53 searchEnabled,54 passedElementType,55 );56 expectEqualElements(actualOutput, expectedOutput);57 });58 });59 describe('search disabled', () => {60 it('returns expected html', () => {61 const isSelectElement = true;62 const isSelectOneElement = false;63 const searchEnabled = false;64 const passedElementType = 'select-multiple';65 const expectedOutput = strToEl(`66 <div67 class="${classes.containerOuter}"68 data-type="${passedElementType}"69 role="listbox"70 aria-haspopup="true"71 aria-expanded="false"72 dir="${direction}"73 >74 </div>75 `);76 const actualOutput = templates.containerOuter(77 classes,78 direction,79 isSelectElement,80 isSelectOneElement,81 searchEnabled,82 passedElementType,83 );84 expectEqualElements(actualOutput, expectedOutput);85 });86 });87 describe('select one element', () => {88 it('returns expected html', () => {89 const isSelectElement = true;90 const isSelectOneElement = true;91 const searchEnabled = false;92 const passedElementType = 'select-one';93 const expectedOutput = strToEl(`94 <div95 class="${classes.containerOuter}"96 data-type="${passedElementType}"97 role="listbox"98 tabindex="0"99 aria-haspopup="true"100 aria-expanded="false"101 dir="${direction}"102 >103 </div>104 `);105 const actualOutput = templates.containerOuter(106 classes,107 direction,108 isSelectElement,109 isSelectOneElement,110 searchEnabled,111 passedElementType,112 );113 expectEqualElements(actualOutput, expectedOutput);114 });115 });116 });117 describe('non select element', () => {118 it('returns expected html', () => {119 const isSelectElement = false;120 const isSelectOneElement = false;121 const searchEnabled = false;122 const passedElementType = 'text';123 const expectedOutput = strToEl(`124 <div125 class="${classes.containerOuter}"126 data-type="${passedElementType}"127 aria-haspopup="true"128 aria-expanded="false"129 dir="${direction}"130 >131 </div>132 `);133 const actualOutput = templates.containerOuter(134 classes,135 direction,136 isSelectElement,137 isSelectOneElement,138 searchEnabled,139 passedElementType,140 );141 expectEqualElements(actualOutput, expectedOutput);142 });143 });144 });145 describe('containerInner', () => {146 it('returns expected html', () => {147 const classes = {148 containerInner: 'class-1',149 };150 const expectedOutput = strToEl(151 `<div class="${classes.containerInner}"></div>`,152 );153 const actualOutput = templates.containerInner(classes);154 expectEqualElements(actualOutput, expectedOutput);155 });156 });157 describe('itemList', () => {158 const classes = {159 list: 'class-1',160 listSingle: 'class-2',161 listItems: 'class-3',162 };163 describe('select one element', () => {164 it('returns expected html', () => {165 const expectedOutput = strToEl(166 `<div class="${classes.list} ${classes.listSingle}"></div>`,167 );168 const actualOutput = templates.itemList(classes, true);169 expectEqualElements(actualOutput, expectedOutput);170 });171 });172 describe('non select one element', () => {173 it('returns expected html', () => {174 const expectedOutput = strToEl(175 `<div class="${classes.list} ${classes.listItems}"></div>`,176 );177 const actualOutput = templates.itemList(classes, false);178 expectEqualElements(actualOutput, expectedOutput);179 });180 });181 });182 describe('placeholder', () => {183 it('returns expected html', () => {184 const classes = {185 placeholder: 'class-1',186 };187 const value = 'test';188 const expectedOutput = strToEl(`189 <div class="${classes.placeholder}">${value}</div>`);190 const actualOutput = templates.placeholder(classes, value);191 expectEqualElements(actualOutput, expectedOutput);192 });193 });194 describe('choiceList', () => {195 const classes = {196 list: 'class-1',197 };198 describe('select one element', () => {199 it('returns expected html', () => {200 const expectedOutput = strToEl(`201 <div202 class="${classes.list}"203 role="listbox"204 >205 </div>206 `);207 const actualOutput = templates.choiceList(classes, true);208 expectEqualElements(actualOutput, expectedOutput);209 });210 });211 describe('non select one element', () => {212 it('returns expected html', () => {213 const expectedOutput = strToEl(`214 <div215 class="${classes.list}"216 role="listbox"217 aria-multiselectable="true"218 >219 </div>220 `);221 const actualOutput = templates.choiceList(classes, false);222 expectEqualElements(actualOutput, expectedOutput);223 });224 });225 });226 describe('choiceGroup', () => {227 const classes = {228 group: 'class-1',229 groupHeading: 'class-2',230 itemDisabled: 'class-3',231 };232 let data;233 beforeEach(() => {234 data = {235 id: 1,236 value: 'test',237 disabled: false,238 };239 });240 describe('enabled state', () => {241 it('returns expected html', () => {242 const expectedOutput = strToEl(`243 <div244 class="${classes.group}"245 data-group246 data-id="${data.id}"247 data-value="${data.value}"248 role="group"249 >250 <div class="${classes.groupHeading}">${data.value}</div>251 </div>252 `);253 const actualOutput = templates.choiceGroup(classes, data);254 expectEqualElements(actualOutput, expectedOutput);255 });256 });257 describe('disabled state', () => {258 beforeEach(() => {259 data = {260 ...data,261 disabled: true,262 };263 });264 it('returns expected html', () => {265 const expectedOutput = strToEl(`266 <div267 class="${classes.group} ${classes.itemDisabled}"268 data-group269 data-id="${data.id}"270 data-value="${data.value}"271 role="group"272 aria-disabled="true"273 >274 <div class="${classes.groupHeading}">${data.value}</div>275 </div>276 `);277 const actualOutput = templates.choiceGroup(classes, data);278 expectEqualElements(actualOutput, expectedOutput);279 });280 });281 });282 describe('choice', () => {283 const classes = {284 item: 'class-1',285 itemChoice: 'class-2',286 itemDisabled: 'class-3',287 itemSelectable: 'class-4',288 placeholder: 'class-5',289 selectedState: 'class-6',290 };291 const itemSelectText = 'test 6';292 let data;293 beforeEach(() => {294 data = {295 id: 1,296 groupId: -1,297 disabled: false,298 elementId: 'test',299 label: 'test',300 value: 'test',301 selected: false,302 };303 });304 describe('enabled state', () => {305 it('returns expected html', () => {306 const expectedOutput = strToEl(`307 <div308 class="${classes.item} ${classes.itemChoice} ${classes.itemSelectable}"309 data-select-text="${itemSelectText}"310 data-choice311 data-id="${data.id}"312 data-value="${data.value}"313 data-choice-selectable314 id="${data.elementId}"315 role="option"316 >317 ${data.label}318 </div>319 `);320 const actualOutput = templates.choice(classes, data, itemSelectText);321 expectEqualElements(actualOutput, expectedOutput);322 });323 });324 describe('disabled state', () => {325 beforeEach(() => {326 data = {327 ...data,328 disabled: true,329 };330 });331 it('returns expected html', () => {332 const expectedOutput = strToEl(`333 <div334 class="${classes.item} ${classes.itemChoice} ${classes.itemDisabled}"335 data-select-text="${itemSelectText}"336 data-choice337 data-id="${data.id}"338 data-value="${data.value}"339 data-choice-disabled340 aria-disabled="true"341 id="${data.elementId}"342 role="option"343 >344 ${data.label}345 </div>346 `);347 const actualOutput = templates.choice(classes, data, itemSelectText);348 expectEqualElements(actualOutput, expectedOutput);349 });350 });351 describe('selected state', () => {352 beforeEach(() => {353 data = {354 ...data,355 selected: true,356 };357 });358 it('returns expected html', () => {359 const expectedOutput = strToEl(`360 <div361 class="${classes.item} ${classes.itemChoice} ${classes.selectedState} ${classes.itemSelectable}"362 data-select-text="${itemSelectText}"363 data-choice364 data-id="${data.id}"365 data-value="${data.value}"366 data-choice-selectable367 id="${data.elementId}"368 role="option"369 >370 ${data.label}371 </div>372 `);373 const actualOutput = templates.choice(classes, data, itemSelectText);374 expectEqualElements(actualOutput, expectedOutput);375 });376 });377 describe('placeholder', () => {378 beforeEach(() => {379 data = {380 ...data,381 placeholder: true,382 };383 });384 it('returns expected html', () => {385 const expectedOutput = strToEl(`386 <div387 class="${classes.item} ${classes.itemChoice} ${classes.placeholder} ${classes.itemSelectable}"388 data-select-text="${itemSelectText}"389 data-choice390 data-id="${data.id}"391 data-value="${data.value}"392 data-choice-selectable393 id="${data.elementId}"394 role="option"395 >396 ${data.label}397 </div>398 `);399 const actualOutput = templates.choice(classes, data, itemSelectText);400 expectEqualElements(actualOutput, expectedOutput);401 });402 });403 describe('child of group', () => {404 beforeEach(() => {405 data = {406 ...data,407 groupId: 1,408 };409 });410 it('returns expected html', () => {411 const expectedOutput = strToEl(`412 <div413 class="${classes.item} ${classes.itemChoice} ${classes.itemSelectable}"414 data-select-text="${itemSelectText}"415 data-choice416 data-id="${data.id}"417 data-value="${data.value}"418 data-choice-selectable419 id="${data.elementId}"420 role="treeitem"421 >422 ${data.label}423 </div>424 `);425 const actualOutput = templates.choice(classes, data, itemSelectText);426 expectEqualElements(actualOutput, expectedOutput);427 });428 });429 });430 describe('input', () => {431 const classes = {432 input: 'class-1',433 inputCloned: 'class-2',434 };435 it('returns expected html', () => {436 /*437 Following attributes are not supported by JSDOM, so, can't compare438 autocapitalize="off"439 spellcheck="false"440 */441 const expectedOutput = strToEl(`442 <input443 type="text"444 class="${classes.input} ${classes.inputCloned}"445 autocomplete="off"446 role="textbox"447 aria-autocomplete="list"448 aria-label="test placeholder"449 >450 `);451 const actualOutput = templates.input(classes, 'test placeholder');452 expectEqualElements(actualOutput, expectedOutput);453 });454 });455 describe('dropdown', () => {456 const classes = {457 list: 'class-1',458 listDropdown: 'class-2',459 };460 it('returns expected html', () => {461 const value = 'test';462 const expectedOutput = strToEl(463 `<div class="${classes.list} ${classes.listDropdown}" aria-expanded="false"></div>`,464 );465 const actualOutput = templates.dropdown(classes, value);466 expectEqualElements(actualOutput, expectedOutput);467 });468 });469 describe('notice', () => {470 const classes = {471 item: 'class-1',472 itemChoice: 'class-2',473 noResults: 'class-3',474 noChoices: 'class-4',475 };476 const label = 'test';477 it('returns expected html', () => {478 const expectedOutput = strToEl(`479 <div class="${classes.item} ${classes.itemChoice}">480 ${label}481 </div>482 `);483 const actualOutput = templates.notice(classes, label);484 expectEqualElements(actualOutput, expectedOutput);485 });486 describe('passing a notice type', () => {487 describe('no results', () => {488 it('adds no results classname', () => {489 const expectedOutput = strToEl(`490 <div class="${classes.item} ${classes.itemChoice} ${classes.noResults}">491 ${label}492 </div>493 `);494 const actualOutput = templates.notice(classes, label, 'no-results');495 expectEqualElements(actualOutput, expectedOutput);496 });497 });498 describe('no choices', () => {499 it('adds no choices classname', () => {500 const expectedOutput = strToEl(`501 <div class="${classes.item} ${classes.itemChoice} ${classes.noChoices}">502 ${label}503 </div>504 `);505 const actualOutput = templates.notice(classes, label, 'no-choices');506 expectEqualElements(actualOutput, expectedOutput);507 });508 });509 });510 });511 describe('option', () => {512 let data;513 beforeEach(() => {514 data = {515 disabled: false,516 selected: false,517 value: 'test value',518 label: 'test label',519 };520 });521 it('returns expected html', () => {522 const expectedOutput = strToEl(523 `<option value="${data.value}" ${data.selected ? 'selected' : ''} ${524 data.disabled ? 'disabled' : ''525 }>${data.label}</option>`,526 );527 const actualOutput = templates.option(data);528 expectEqualElements(actualOutput, expectedOutput);529 });530 describe('when selected', () => {531 beforeEach(() => {532 data = {533 ...data,534 active: true,535 };536 });537 it('sets selected attr to true', () => {538 const output = templates.option(data);539 expect(output.selected).to.equal(true);540 });541 });542 describe('when disabled', () => {543 beforeEach(() => {544 data = {545 ...data,546 disabled: true,547 };548 });549 it('sets disabled attr to true', () => {550 const output = templates.option(data);551 expect(output.disabled).to.equal(true);552 });553 });554 });...
templates.test.ts
Source:templates.test.ts
1import { expect } from 'chai';2import templates from './templates';3import { strToEl } from './lib/utils';4/**5 * @param {HTMLElement} element16 * @param {HTMLElement} element27 */8function expectEqualElements(element1, element2): void {9 expect(element1.tagName).to.equal(element2.tagName);10 expect(element1.attributes.length).to.equal(element2.attributes.length);11 expect(Object.keys(element1.dataset)).to.have.members(12 Object.keys(element2.dataset),13 );14 expect(element1.classList).to.include(element2.classList);15 // compare attributes values16 for (const attribute of Object.values(element1.attributes)) {17 expect(element1.getAttribute(attribute)).to.equal(18 element2.getAttribute(attribute),19 );20 }21}22describe('templates', () => {23 describe('containerOuter', () => {24 const classes = {25 containerOuter: 'class-1',26 };27 const direction = 'rtl';28 describe('select element', () => {29 describe('search enabled', () => {30 it('returns expected html', () => {31 const isSelectElement = true;32 const isSelectOneElement = false;33 const searchEnabled = true;34 const passedElementType = 'select-multiple';35 const expectedOutput = strToEl(`36 <div37 class="${classes.containerOuter}"38 data-type="${passedElementType}"39 role="combobox"40 aria-autocomplete="list"41 aria-haspopup="true"42 aria-expanded="false"43 dir="${direction}"44 >45 </div>46 `);47 const actualOutput = templates.containerOuter(48 classes,49 direction,50 isSelectElement,51 isSelectOneElement,52 searchEnabled,53 passedElementType,54 );55 expectEqualElements(actualOutput, expectedOutput);56 });57 });58 describe('search disabled', () => {59 it('returns expected html', () => {60 const isSelectElement = true;61 const isSelectOneElement = false;62 const searchEnabled = false;63 const passedElementType = 'select-multiple';64 const expectedOutput = strToEl(`65 <div66 class="${classes.containerOuter}"67 data-type="${passedElementType}"68 role="listbox"69 aria-haspopup="true"70 aria-expanded="false"71 dir="${direction}"72 >73 </div>74 `);75 const actualOutput = templates.containerOuter(76 classes,77 direction,78 isSelectElement,79 isSelectOneElement,80 searchEnabled,81 passedElementType,82 );83 expectEqualElements(actualOutput, expectedOutput);84 });85 });86 describe('select one element', () => {87 it('returns expected html', () => {88 const isSelectElement = true;89 const isSelectOneElement = true;90 const searchEnabled = false;91 const passedElementType = 'select-one';92 const expectedOutput = strToEl(`93 <div94 class="${classes.containerOuter}"95 data-type="${passedElementType}"96 role="listbox"97 tabindex="0"98 aria-haspopup="true"99 aria-expanded="false"100 dir="${direction}"101 >102 </div>103 `);104 const actualOutput = templates.containerOuter(105 classes,106 direction,107 isSelectElement,108 isSelectOneElement,109 searchEnabled,110 passedElementType,111 );112 expectEqualElements(actualOutput, expectedOutput);113 });114 });115 });116 describe('non select element', () => {117 it('returns expected html', () => {118 const isSelectElement = false;119 const isSelectOneElement = false;120 const searchEnabled = false;121 const passedElementType = 'text';122 const expectedOutput = strToEl(`123 <div124 class="${classes.containerOuter}"125 data-type="${passedElementType}"126 aria-haspopup="true"127 aria-expanded="false"128 dir="${direction}"129 >130 </div>131 `);132 const actualOutput = templates.containerOuter(133 classes,134 direction,135 isSelectElement,136 isSelectOneElement,137 searchEnabled,138 passedElementType,139 );140 expectEqualElements(actualOutput, expectedOutput);141 });142 });143 });144 describe('containerInner', () => {145 it('returns expected html', () => {146 const classes = {147 containerInner: 'class-1',148 };149 const expectedOutput = strToEl(150 `<div class="${classes.containerInner}"></div>`,151 );152 const actualOutput = templates.containerInner(classes);153 expectEqualElements(actualOutput, expectedOutput);154 });155 });156 describe('itemList', () => {157 const classes = {158 list: 'class-1',159 listSingle: 'class-2',160 listItems: 'class-3',161 };162 describe('select one element', () => {163 it('returns expected html', () => {164 const expectedOutput = strToEl(165 `<div class="${classes.list} ${classes.listSingle}"></div>`,166 );167 const actualOutput = templates.itemList(classes, true);168 expectEqualElements(actualOutput, expectedOutput);169 });170 });171 describe('non select one element', () => {172 it('returns expected html', () => {173 const expectedOutput = strToEl(174 `<div class="${classes.list} ${classes.listItems}"></div>`,175 );176 const actualOutput = templates.itemList(classes, false);177 expectEqualElements(actualOutput, expectedOutput);178 });179 });180 });181 describe('placeholder', () => {182 it('returns expected html', () => {183 const classes = {184 placeholder: 'class-1',185 };186 const value = 'test';187 const expectedOutput = strToEl(`188 <div class="${classes.placeholder}">${value}</div>`);189 const actualOutput = templates.placeholder(classes, value);190 expectEqualElements(actualOutput, expectedOutput);191 });192 });193 describe('choiceList', () => {194 const classes = {195 list: 'class-1',196 };197 describe('select one element', () => {198 it('returns expected html', () => {199 const expectedOutput = strToEl(`200 <div201 class="${classes.list}"202 role="listbox"203 >204 </div>205 `);206 const actualOutput = templates.choiceList(classes, true);207 expectEqualElements(actualOutput, expectedOutput);208 });209 });210 describe('non select one element', () => {211 it('returns expected html', () => {212 const expectedOutput = strToEl(`213 <div214 class="${classes.list}"215 role="listbox"216 aria-multiselectable="true"217 >218 </div>219 `);220 const actualOutput = templates.choiceList(classes, false);221 expectEqualElements(actualOutput, expectedOutput);222 });223 });224 });225 describe('choiceGroup', () => {226 const classes = {227 group: 'class-1',228 groupHeading: 'class-2',229 itemDisabled: 'class-3',230 };231 let data;232 beforeEach(() => {233 data = {234 id: 1,235 value: 'test',236 disabled: false,237 };238 });239 describe('enabled state', () => {240 it('returns expected html', () => {241 const expectedOutput = strToEl(`242 <div243 class="${classes.group}"244 data-group245 data-id="${data.id}"246 data-value="${data.value}"247 role="group"248 >249 <div class="${classes.groupHeading}">${data.value}</div>250 </div>251 `);252 const actualOutput = templates.choiceGroup(classes, data);253 expectEqualElements(actualOutput, expectedOutput);254 });255 });256 describe('disabled state', () => {257 beforeEach(() => {258 data = {259 ...data,260 disabled: true,261 };262 });263 it('returns expected html', () => {264 const expectedOutput = strToEl(`265 <div266 class="${classes.group} ${classes.itemDisabled}"267 data-group268 data-id="${data.id}"269 data-value="${data.value}"270 role="group"271 aria-disabled="true"272 >273 <div class="${classes.groupHeading}">${data.value}</div>274 </div>275 `);276 const actualOutput = templates.choiceGroup(classes, data);277 expectEqualElements(actualOutput, expectedOutput);278 });279 });280 });281 describe('choice', () => {282 const classes = {283 item: 'class-1',284 itemChoice: 'class-2',285 itemDisabled: 'class-3',286 itemSelectable: 'class-4',287 placeholder: 'class-5',288 selectedState: 'class-6',289 };290 const itemSelectText = 'test 6';291 let data;292 beforeEach(() => {293 data = {294 id: 1,295 groupId: -1,296 disabled: false,297 elementId: 'test',298 label: 'test',299 value: 'test',300 selected: false,301 };302 });303 describe('enabled state', () => {304 it('returns expected html', () => {305 const expectedOutput = strToEl(`306 <div307 class="${classes.item} ${classes.itemChoice} ${classes.itemSelectable}"308 data-select-text="${itemSelectText}"309 data-choice310 data-id="${data.id}"311 data-value="${data.value}"312 data-choice-selectable313 id="${data.elementId}"314 role="option"315 >316 ${data.label}317 </div>318 `);319 const actualOutput = templates.choice(classes, data, itemSelectText);320 expectEqualElements(actualOutput, expectedOutput);321 });322 });323 describe('disabled state', () => {324 beforeEach(() => {325 data = {326 ...data,327 disabled: true,328 };329 });330 it('returns expected html', () => {331 const expectedOutput = strToEl(`332 <div333 class="${classes.item} ${classes.itemChoice} ${classes.itemDisabled}"334 data-select-text="${itemSelectText}"335 data-choice336 data-id="${data.id}"337 data-value="${data.value}"338 data-choice-disabled339 aria-disabled="true"340 id="${data.elementId}"341 role="option"342 >343 ${data.label}344 </div>345 `);346 const actualOutput = templates.choice(classes, data, itemSelectText);347 expectEqualElements(actualOutput, expectedOutput);348 });349 });350 describe('selected state', () => {351 beforeEach(() => {352 data = {353 ...data,354 selected: true,355 };356 });357 it('returns expected html', () => {358 const expectedOutput = strToEl(`359 <div360 class="${classes.item} ${classes.itemChoice} ${classes.selectedState} ${classes.itemSelectable}"361 data-select-text="${itemSelectText}"362 data-choice363 data-id="${data.id}"364 data-value="${data.value}"365 data-choice-selectable366 id="${data.elementId}"367 role="option"368 >369 ${data.label}370 </div>371 `);372 const actualOutput = templates.choice(classes, data, itemSelectText);373 expectEqualElements(actualOutput, expectedOutput);374 });375 });376 describe('placeholder', () => {377 beforeEach(() => {378 data = {379 ...data,380 placeholder: true,381 };382 });383 it('returns expected html', () => {384 const expectedOutput = strToEl(`385 <div386 class="${classes.item} ${classes.itemChoice} ${classes.placeholder} ${classes.itemSelectable}"387 data-select-text="${itemSelectText}"388 data-choice389 data-id="${data.id}"390 data-value="${data.value}"391 data-choice-selectable392 id="${data.elementId}"393 role="option"394 >395 ${data.label}396 </div>397 `);398 const actualOutput = templates.choice(classes, data, itemSelectText);399 expectEqualElements(actualOutput, expectedOutput);400 });401 });402 describe('child of group', () => {403 beforeEach(() => {404 data = {405 ...data,406 groupId: 1,407 };408 });409 it('returns expected html', () => {410 const expectedOutput = strToEl(`411 <div412 class="${classes.item} ${classes.itemChoice} ${classes.itemSelectable}"413 data-select-text="${itemSelectText}"414 data-choice415 data-id="${data.id}"416 data-value="${data.value}"417 data-choice-selectable418 id="${data.elementId}"419 role="treeitem"420 >421 ${data.label}422 </div>423 `);424 const actualOutput = templates.choice(classes, data, itemSelectText);425 expectEqualElements(actualOutput, expectedOutput);426 });427 });428 });429 describe('input', () => {430 const classes = {431 input: 'class-1',432 inputCloned: 'class-2',433 };434 it('returns expected html', () => {435 /*436 Following attributes are not supported by JSDOM, so, can't compare437 autocapitalize="off"438 spellcheck="false"439 */440 const expectedOutput = strToEl(`441 <input442 type="text"443 class="${classes.input} ${classes.inputCloned}"444 autocomplete="off"445 role="textbox"446 aria-autocomplete="list"447 aria-label="test placeholder"448 >449 `);450 const actualOutput = templates.input(classes, 'test placeholder');451 expectEqualElements(actualOutput, expectedOutput);452 });453 });454 describe('dropdown', () => {455 const classes = {456 list: 'class-1',457 listDropdown: 'class-2',458 };459 it('returns expected html', () => {460 const expectedOutput = strToEl(461 `<div class="${classes.list} ${classes.listDropdown}" aria-expanded="false"></div>`,462 );463 const actualOutput = templates.dropdown(classes);464 expectEqualElements(actualOutput, expectedOutput);465 });466 });467 describe('notice', () => {468 const classes = {469 item: 'class-1',470 itemChoice: 'class-2',471 noResults: 'class-3',472 noChoices: 'class-4',473 };474 const label = 'test';475 it('returns expected html', () => {476 const expectedOutput = strToEl(`477 <div class="${classes.item} ${classes.itemChoice}">478 ${label}479 </div>480 `);481 const actualOutput = templates.notice(classes, label);482 expectEqualElements(actualOutput, expectedOutput);483 });484 describe('passing a notice type', () => {485 describe('no results', () => {486 it('adds no results classname', () => {487 const expectedOutput = strToEl(`488 <div class="${classes.item} ${classes.itemChoice} ${classes.noResults}">489 ${label}490 </div>491 `);492 const actualOutput = templates.notice(classes, label, 'no-results');493 expectEqualElements(actualOutput, expectedOutput);494 });495 });496 describe('no choices', () => {497 it('adds no choices classname', () => {498 const expectedOutput = strToEl(`499 <div class="${classes.item} ${classes.itemChoice} ${classes.noChoices}">500 ${label}501 </div>502 `);503 const actualOutput = templates.notice(classes, label, 'no-choices');504 expectEqualElements(actualOutput, expectedOutput);505 });506 });507 });508 });509 describe('option', () => {510 let data;511 beforeEach(() => {512 data = {513 disabled: false,514 selected: false,515 value: 'test value',516 label: 'test label',517 };518 });519 it('returns expected html', () => {520 const expectedOutput = strToEl(521 `<option value="${data.value}" ${data.selected ? 'selected' : ''} ${522 data.disabled ? 'disabled' : ''523 }>${data.label}</option>`,524 );525 const actualOutput = templates.option(data);526 expectEqualElements(actualOutput, expectedOutput);527 });528 describe('when selected', () => {529 beforeEach(() => {530 data = {531 ...data,532 active: true,533 };534 });535 it('sets selected attr to true', () => {536 const output = templates.option(data);537 expect(output.selected).to.equal(true);538 });539 });540 describe('when disabled', () => {541 beforeEach(() => {542 data = {543 ...data,544 disabled: true,545 };546 });547 it('sets disabled attr to true', () => {548 const output = templates.option(data);549 expect(output.disabled).to.equal(true);550 });551 });552 });...
Using AI Code Generation
1var actualOutput = require('stryker-parent').actualOutput;2var actualOutput = require('stryker-parent').actualOutput;3var actualOutput = require('stryker-parent').actualOutput;4var actualOutput = require('stryker-parent').actualOutput;5var actualOutput = require('stryker-parent').actualOutput;6var actualOutput = require('stryker-parent').actualOutput;7var actualOutput = require('stryker-parent').actualOutput;8var actualOutput = require('stryker-parent').actualOutput;9var actualOutput = require('stryker-parent').actualOutput;10var actualOutput = require('stryker-parent').actualOutput;11var actualOutput = require('stryker-parent').actualOutput;12var actualOutput = require('stryker-parent').actualOutput;13var actualOutput = require('stryker-parent').actualOutput;14var actualOutput = require('stryker-parent').actualOutput;15var actualOutput = require('stryker-parent').actualOutput;16var actualOutput = require('stryker-parent').actualOutput;17var actualOutput = require('stryker-parent').actualOutput;18var actualOutput = require('stryker-parent').actualOutput;
Using AI Code Generation
1var actualOutput = require('stryker-parent').actualOutput;2actualOutput('hello world');3var actualOutput = require('stryker-child').actualOutput;4actualOutput('hello world');5var actualOutput = require('stryker-sibling').actualOutput;6actualOutput('hello world');
Using AI Code Generation
1import { actualOutput } from 'stryker-parent';2import { actualOutput } from 'stryker-parent/actualOutput';3import { actualOutput } from 'stryker-parent';4import { actualOutput } from 'stryker-parent/actualOutput';5import { actualOutput } from 'stryker-parent';6import { actualOutput } from 'stryker-parent/actualOutput';7import { actualOutput } from 'stryker-parent';8import { actualOutput } from 'stryker-parent/actualOutput';9import { actualOutput } from 'stryker-parent';10import { actualOutput } from 'stryker-parent/actualOutput';11import { actualOutput } from 'stryker-parent';12import { actualOutput } from 'stryker-parent/actualOutput';13import { actualOutput } from 'stryker-parent';14import { actualOutput } from 'stryker-parent/actualOutput';15import { actualOutput } from 'stryker-parent';16import { actualOutput } from 'stryker-parent/actualOutput';17import { actualOutput } from 'stryker-parent';18import { actualOutput } from 'stryker-parent/actualOutput';
Using AI Code Generation
1var actualOutput = require('stryker-parent').actualOutput;2var assert = require('assert');3describe('test', function () {4 it('test', function () {5 var actual = actualOutput();6 assert.equal(actual, 'actual output');7 });8});9var expectedOutput = require('stryker-parent').expectedOutput;10var assert = require('assert');11describe('test', function () {12 it('test', function () {13 var expected = expectedOutput();14 assert.equal(expected, 'expected output');15 });16});17var expectedOutput = require('stryker-parent').expectedOutput;18var assert = require('assert');19describe('test', function () {20 it('test', function () {21 var expected = expectedOutput();22 assert.equal(expected, 'expected output');23 });24});25var expectedOutput = require('stryker-parent').expectedOutput;26var assert = require('assert');27describe('test', function () {28 it('test', function () {29 var expected = expectedOutput();30 assert.equal(expected, 'expected output');31 });32});33var expectedOutput = require('stryker-parent').expectedOutput;34var assert = require('assert');35describe('test', function () {36 it('test', function () {37 var expected = expectedOutput();38 assert.equal(expected, 'expected output');39 });40});41var expectedOutput = require('stryker-parent').expectedOutput;42var assert = require('assert');43describe('test', function () {44 it('test', function () {45 var expected = expectedOutput();46 assert.equal(expected, 'expected output');47 });48});49var expectedOutput = require('stryker-parent').expectedOutput;50var assert = require('assert');51describe('test', function () {52 it('test', function () {53 var expected = expectedOutput();
Using AI Code Generation
1const actualOutput = require("stryker-parent").actualOutput;2const child = require("child_process");3const path = require("path");4const childProcess = child.fork(path.resolve(__dirname, "child.js"));5childProcess.on("message", (data) => {6 console.log(actualOutput(data));7});8const actualOutput = require("stryker-parent").actualOutput;9const child = require("child_process");10const childProcess = child.exec("node --version");11childProcess.stdout.on("data", (data) => {12 process.send(actualOutput(data));13});14module.exports = function(config) {15 config.set({16 commandRunner: {17 },18 });19};20module.exports = function() {21 return "Hello World!";22};
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!!