How to use findAll method in pyatom

Best Python code snippet using pyatom_python

table-sorting.spec.js

Source:table-sorting.spec.js Github

copy

Full Screen

...16 items: testItems17 }18 })19 expect(wrapper).toBeDefined()20 expect(wrapper.findAll('tbody > tr').exists()).toBe(true)21 expect(wrapper.findAll('tbody > tr').length).toBe(3)22 await waitNT(wrapper.vm)23 expect(wrapper.emitted('input')).toBeDefined()24 expect(wrapper.emitted('input').length).toBe(1)25 expect(wrapper.emitted('input')[0][0]).toEqual(testItems)26 const $rows = wrapper.findAll('tbody > tr').wrappers27 expect($rows.length).toBe(3)28 // Map the rows to the first column text value29 const columnA = $rows.map(row => {30 return row31 .findAll('td')32 .at(0)33 .text()34 })35 expect(columnA[0]).toBe('3')36 expect(columnA[1]).toBe('1')37 expect(columnA[2]).toBe('2')38 wrapper.destroy()39 })40 it('should sort column descending when sortBy set and sortDesc changed, with proper attributes', async () => {41 const wrapper = mount(BTable, {42 propsData: {43 fields: testFields,44 items: testItems,45 sortBy: 'a',46 sortDesc: false47 }48 })49 expect(wrapper).toBeDefined()50 expect(wrapper.findAll('tbody > tr').exists()).toBe(true)51 expect(wrapper.findAll('tbody > tr').length).toBe(3)52 let $rows53 let columnA54 await waitNT(wrapper.vm)55 expect(wrapper.emitted('input')).toBeDefined()56 expect(wrapper.emitted('input').length).toBe(1)57 $rows = wrapper.findAll('tbody > tr').wrappers58 expect($rows.length).toBe(3)59 // Map the rows to the first column text value60 columnA = $rows.map(row => {61 return row62 .findAll('td')63 .at(0)64 .text()65 })66 expect(columnA[0]).toBe('1')67 expect(columnA[1]).toBe('2')68 expect(columnA[2]).toBe('3')69 let $ths = wrapper.findAll('thead > tr > th')70 // Currently sorted as ascending71 expect($ths.at(0).attributes('aria-sort')).toBe('ascending')72 // For switching to descending73 expect(74 $ths75 .at(0)76 .find('.sr-only')77 .text()78 ).toContain(wrapper.vm.labelSortDesc)79 // Not sorted by this column80 expect($ths.at(1).attributes('aria-sort')).toBe('none')81 // For sorting by ascending82 expect(83 $ths84 .at(1)85 .find('.sr-only')86 .text()87 ).toContain(wrapper.vm.labelSortAsc)88 // Not a sortable column89 expect($ths.at(2).attributes('aria-sort')).not.toBeDefined()90 // For clearing sorting91 expect(92 $ths93 .at(2)94 .find('.sr-only')95 .text()96 ).toContain(wrapper.vm.labelSortClear)97 // Change sort direction98 await wrapper.setProps({ sortDesc: true })99 expect(wrapper.emitted('input').length).toBe(2)100 $rows = wrapper.findAll('tbody > tr').wrappers101 expect($rows.length).toBe(3)102 // Map the rows to the first column text value103 columnA = $rows.map(row => {104 return row105 .findAll('td')106 .at(0)107 .text()108 })109 expect(columnA[0]).toBe('3')110 expect(columnA[1]).toBe('2')111 expect(columnA[2]).toBe('1')112 $ths = wrapper.findAll('thead > tr > th')113 // Currently sorted as descending114 expect($ths.at(0).attributes('aria-sort')).toBe('descending')115 // For switching to ascending116 expect(117 $ths118 .at(0)119 .find('.sr-only')120 .text()121 ).toContain(wrapper.vm.labelSortAsc)122 // Not sorted by this column123 expect($ths.at(1).attributes('aria-sort')).toBe('none')124 // For sorting by ascending125 expect(126 $ths127 .at(1)128 .find('.sr-only')129 .text()130 ).toContain(wrapper.vm.labelSortAsc)131 // Not a sortable column132 expect($ths.at(2).attributes('aria-sort')).not.toBeDefined()133 // For clearing sorting134 expect(135 $ths136 .at(2)137 .find('.sr-only')138 .text()139 ).toContain(wrapper.vm.labelSortClear)140 // Clear sort141 await wrapper.setProps({142 sortBy: null,143 sortDesc: false144 })145 expect(wrapper.emitted('input').length).toBe(4)146 $rows = wrapper.findAll('tbody > tr').wrappers147 expect($rows.length).toBe(3)148 // Map the rows to the first column text value149 columnA = $rows.map(row => {150 return row151 .findAll('td')152 .at(0)153 .text()154 })155 expect(columnA[0]).toBe('3')156 expect(columnA[1]).toBe('1')157 expect(columnA[2]).toBe('2')158 $ths = wrapper.findAll('thead > tr > th')159 // Currently not sorted160 expect($ths.at(0).attributes('aria-sort')).toBe('none')161 // For sorting by ascending162 expect(163 $ths164 .at(0)165 .find('.sr-only')166 .text()167 ).toContain(wrapper.vm.labelSortAsc)168 // Not sorted by this column169 expect($ths.at(1).attributes('aria-sort')).toBe('none')170 // For sorting by ascending171 expect(172 $ths173 .at(1)174 .find('.sr-only')175 .text()176 ).toContain(wrapper.vm.labelSortAsc)177 // Not a sortable column178 expect($ths.at(2).attributes('aria-sort')).not.toBeDefined()179 // For clearing sorting180 expect(181 $ths182 .at(2)183 .find('.sr-only')184 .exists()185 ).toBe(false)186 wrapper.destroy()187 })188 it('should accept custom sort compare', async () => {189 const wrapper = mount(BTable, {190 propsData: {191 fields: testFields,192 items: testItems,193 sortBy: 'a',194 sortDesc: false,195 sortCompare: (a, b, sortBy) => {196 // We just use our default sort compare to test passing a function197 return defaultSortCompare(a, b, sortBy)198 }199 }200 })201 expect(wrapper).toBeDefined()202 expect(wrapper.findAll('tbody > tr').exists()).toBe(true)203 expect(wrapper.findAll('tbody > tr').length).toBe(3)204 await waitNT(wrapper.vm)205 expect(wrapper.emitted('input')).toBeDefined()206 expect(wrapper.emitted('input').length).toBe(1)207 const $rows = wrapper.findAll('tbody > tr').wrappers208 expect($rows.length).toBe(3)209 // Map the rows to the first column text value210 const columnA = $rows.map(row => {211 return row212 .findAll('td')213 .at(0)214 .text()215 })216 expect(columnA[0]).toBe('1')217 expect(columnA[1]).toBe('2')218 expect(columnA[2]).toBe('3')219 wrapper.destroy()220 })221 it('should sort columns when clicking headers', async () => {222 const wrapper = mount(BTable, {223 propsData: {224 fields: testFields,225 items: testItems226 }227 })228 expect(wrapper).toBeDefined()229 expect(wrapper.findAll('tbody > tr').exists()).toBe(true)230 expect(wrapper.findAll('tbody > tr').length).toBe(3)231 let $rows232 let columnA233 // Should not be sorted234 await waitNT(wrapper.vm)235 expect(wrapper.emitted('input')).toBeDefined()236 expect(wrapper.emitted('sort-changed')).not.toBeDefined()237 $rows = wrapper.findAll('tbody > tr').wrappers238 expect($rows.length).toBe(3)239 // Map the rows to the first column text value240 columnA = $rows.map(row => {241 return row242 .findAll('td')243 .at(0)244 .text()245 })246 expect(columnA[0]).toBe('3')247 expect(columnA[1]).toBe('1')248 expect(columnA[2]).toBe('2')249 // Sort by first column250 await wrapper251 .findAll('thead > tr > th')252 .at(0)253 .trigger('click')254 expect(wrapper.emitted('sort-changed')).toBeDefined()255 expect(wrapper.emitted('sort-changed').length).toBe(1)256 expect(wrapper.emitted('sort-changed')[0][0]).toEqual(wrapper.vm.context)257 $rows = wrapper.findAll('tbody > tr').wrappers258 expect($rows.length).toBe(3)259 // Map the rows to the column text value260 columnA = $rows.map(row => {261 return row262 .findAll('td')263 .at(0)264 .text()265 })266 expect(columnA[0]).toBe('1')267 expect(columnA[1]).toBe('2')268 expect(columnA[2]).toBe('3')269 // Click first column header again to reverse sort270 await wrapper271 .findAll('thead > tr > th')272 .at(0)273 .trigger('click')274 expect(wrapper.emitted('sort-changed').length).toBe(2)275 expect(wrapper.emitted('sort-changed')[1][0]).toEqual(wrapper.vm.context)276 $rows = wrapper.findAll('tbody > tr').wrappers277 expect($rows.length).toBe(3)278 // Map the rows to the column text value279 columnA = $rows.map(row => {280 return row281 .findAll('td')282 .at(0)283 .text()284 })285 expect(columnA[0]).toBe('3')286 expect(columnA[1]).toBe('2')287 expect(columnA[2]).toBe('1')288 // Click second column header to sort by it (by using keydown.enter)289 await wrapper290 .findAll('thead > tr > th')291 .at(1)292 .trigger('keydown.enter')293 expect(wrapper.emitted('sort-changed').length).toBe(3)294 expect(wrapper.emitted('sort-changed')[2][0]).toEqual(wrapper.vm.context)295 $rows = wrapper.findAll('tbody > tr').wrappers296 expect($rows.length).toBe(3)297 // Map the rows to the column text value298 const columnB = $rows.map(row => {299 return row300 .findAll('td')301 .at(1)302 .text()303 })304 expect(columnB[0]).toBe('a')305 expect(columnB[1]).toBe('b')306 expect(columnB[2]).toBe('c')307 // Click third column header to clear sort308 await wrapper309 .findAll('thead > tr > th')310 .at(2)311 .trigger('click')312 expect(wrapper.emitted('sort-changed').length).toBe(4)313 expect(wrapper.emitted('sort-changed')[3][0]).toEqual(wrapper.vm.context)314 $rows = wrapper.findAll('tbody > tr').wrappers315 expect($rows.length).toBe(3)316 // Map the rows to the column text value317 columnA = $rows.map(row => {318 return row319 .findAll('td')320 .at(0)321 .text()322 })323 expect(columnA[0]).toBe('3')324 expect(columnA[1]).toBe('1')325 expect(columnA[2]).toBe('2')326 wrapper.destroy()327 })328 it('should sort columns when clicking footers', async () => {329 const wrapper = mount(BTable, {330 propsData: {331 fields: testFields,332 items: testItems,333 footClone: true334 }335 })336 expect(wrapper).toBeDefined()337 expect(wrapper.findAll('tbody > tr').exists()).toBe(true)338 expect(wrapper.findAll('tbody > tr').length).toBe(3)339 let $rows340 let columnA341 // Should not be sorted342 await waitNT(wrapper.vm)343 expect(wrapper.emitted('input')).toBeDefined()344 expect(wrapper.emitted('sort-changed')).not.toBeDefined()345 $rows = wrapper.findAll('tbody > tr').wrappers346 expect($rows.length).toBe(3)347 // Map the rows to the first column text value348 columnA = $rows.map(row => {349 return row350 .findAll('td')351 .at(0)352 .text()353 })354 expect(columnA[0]).toBe('3')355 expect(columnA[1]).toBe('1')356 expect(columnA[2]).toBe('2')357 // Should have aria-* labels358 expect(wrapper.findAll('tfoot > tr > th[aria-sort]').length).toBe(2)359 expect(wrapper.findAll('tfoot > tr > th > .sr-only').length).toBe(2)360 // Sort by first column361 await wrapper362 .findAll('tfoot > tr > th')363 .at(0)364 .trigger('click')365 expect(wrapper.emitted('sort-changed')).toBeDefined()366 expect(wrapper.emitted('sort-changed').length).toBe(1)367 expect(wrapper.emitted('sort-changed')[0][0]).toEqual(wrapper.vm.context)368 $rows = wrapper.findAll('tbody > tr').wrappers369 expect($rows.length).toBe(3)370 // Map the rows to the column text value371 columnA = $rows.map(row => {372 return row373 .findAll('td')374 .at(0)375 .text()376 })377 expect(columnA[0]).toBe('1')378 expect(columnA[1]).toBe('2')379 expect(columnA[2]).toBe('3')380 // Should have aria-* labels381 expect(wrapper.findAll('tfoot > tr > th[aria-sort]').length).toBe(2)382 expect(wrapper.findAll('tfoot > tr > th > .sr-only').length).toBe(3)383 // Click first column header again to reverse sort384 await wrapper385 .findAll('tfoot > tr > th')386 .at(0)387 .trigger('click')388 expect(wrapper.emitted('sort-changed').length).toBe(2)389 expect(wrapper.emitted('sort-changed')[1][0]).toEqual(wrapper.vm.context)390 $rows = wrapper.findAll('tbody > tr').wrappers391 expect($rows.length).toBe(3)392 // Map the rows to the column text value393 columnA = $rows.map(row => {394 return row395 .findAll('td')396 .at(0)397 .text()398 })399 expect(columnA[0]).toBe('3')400 expect(columnA[1]).toBe('2')401 expect(columnA[2]).toBe('1')402 // Should have aria-* labels403 expect(wrapper.findAll('tfoot > tr > th[aria-sort]').length).toBe(2)404 expect(wrapper.findAll('tfoot > tr > th > .sr-only').length).toBe(3)405 // Click second column header to sort by it (by using keydown.enter)406 await wrapper407 .findAll('tfoot > tr > th')408 .at(1)409 .trigger('keydown.enter')410 expect(wrapper.emitted('sort-changed').length).toBe(3)411 expect(wrapper.emitted('sort-changed')[2][0]).toEqual(wrapper.vm.context)412 $rows = wrapper.findAll('tbody > tr').wrappers413 expect($rows.length).toBe(3)414 // Map the rows to the column text value415 const columnB = $rows.map(row => {416 return row417 .findAll('td')418 .at(1)419 .text()420 })421 expect(columnB[0]).toBe('a')422 expect(columnB[1]).toBe('b')423 expect(columnB[2]).toBe('c')424 // Click third column header to clear sort425 await wrapper426 .findAll('tfoot > tr > th')427 .at(2)428 .trigger('click')429 expect(wrapper.emitted('sort-changed').length).toBe(4)430 expect(wrapper.emitted('sort-changed')[3][0]).toEqual(wrapper.vm.context)431 $rows = wrapper.findAll('tbody > tr').wrappers432 expect($rows.length).toBe(3)433 // Map the rows to the column text value434 columnA = $rows.map(row => {435 return row436 .findAll('td')437 .at(0)438 .text()439 })440 expect(columnA[0]).toBe('3')441 expect(columnA[1]).toBe('1')442 expect(columnA[2]).toBe('2')443 // Should have aria-* labels444 expect(wrapper.findAll('tfoot > tr > th[aria-sort]').length).toBe(2)445 expect(wrapper.findAll('tfoot > tr > th > .sr-only').length).toBe(2)446 wrapper.destroy()447 })448 it('should not sort columns when clicking footers and no-footer-sorting set', async () => {449 const wrapper = mount(BTable, {450 propsData: {451 fields: testFields,452 items: testItems,453 footClone: true,454 noFooterSorting: true455 }456 })457 expect(wrapper).toBeDefined()458 expect(wrapper.findAll('tbody > tr').exists()).toBe(true)459 expect(wrapper.findAll('tbody > tr').length).toBe(3)460 let $rows461 let columnA462 // Should not be sorted463 await waitNT(wrapper.vm)464 expect(wrapper.emitted('input')).toBeDefined()465 expect(wrapper.emitted('sort-changed')).not.toBeDefined()466 $rows = wrapper.findAll('tbody > tr').wrappers467 expect($rows.length).toBe(3)468 // Map the rows to the first column text value469 columnA = $rows.map(row => {470 return row471 .findAll('td')472 .at(0)473 .text()474 })475 expect(columnA[0]).toBe('3')476 expect(columnA[1]).toBe('1')477 expect(columnA[2]).toBe('2')478 // Shouldn't have aria-* labels479 expect(wrapper.findAll('tfoot > tr > th[aria-sort]').length).toBe(0)480 expect(wrapper.findAll('tfoot > tr > th > .sr-only').length).toBe(0)481 // Click first column482 await wrapper483 .findAll('tfoot > tr > th')484 .at(0)485 .trigger('click')486 expect(wrapper.emitted('sort-changed')).not.toBeDefined()487 $rows = wrapper.findAll('tbody > tr').wrappers488 expect($rows.length).toBe(3)489 // Map the rows to the column text value490 columnA = $rows.map(row => {491 return row492 .findAll('td')493 .at(0)494 .text()495 })496 expect(columnA[0]).toBe('3')497 expect(columnA[1]).toBe('1')498 expect(columnA[2]).toBe('2')499 // Shouldn't have aria-* labels500 expect(wrapper.findAll('tfoot > tr > th[aria-sort]').length).toBe(0)501 expect(wrapper.findAll('tfoot > tr > th > .sr-only').length).toBe(0)502 // Click third column header503 await wrapper504 .findAll('tfoot > tr > th')505 .at(2)506 .trigger('click')507 expect(wrapper.emitted('sort-changed')).not.toBeDefined()508 $rows = wrapper.findAll('tbody > tr').wrappers509 expect($rows.length).toBe(3)510 // Map the rows to the column text value511 columnA = $rows.map(row => {512 return row513 .findAll('td')514 .at(0)515 .text()516 })517 expect(columnA[0]).toBe('3')518 expect(columnA[1]).toBe('1')519 expect(columnA[2]).toBe('2')520 // Shouldn't have aria-* labels521 expect(wrapper.findAll('tfoot > tr > th[aria-sort]').length).toBe(0)522 expect(wrapper.findAll('tfoot > tr > th > .sr-only').length).toBe(0)523 wrapper.destroy()524 })525 it('should sort column descending first, when sort-direction=desc', async () => {526 const wrapper = mount(BTable, {527 propsData: {528 fields: testFields,529 items: testItems,530 sortDesc: false,531 sortDirection: 'desc'532 }533 })534 expect(wrapper).toBeDefined()535 expect(wrapper.findAll('tbody > tr').exists()).toBe(true)536 expect(wrapper.findAll('tbody > tr').length).toBe(3)537 let $rows538 let columnA539 await waitNT(wrapper.vm)540 $rows = wrapper.findAll('tbody > tr').wrappers541 expect($rows.length).toBe(3)542 // Map the rows to the first column text value543 columnA = $rows.map(row => {544 return row545 .findAll('td')546 .at(0)547 .text()548 })549 expect(columnA[0]).toBe('3')550 expect(columnA[1]).toBe('1')551 expect(columnA[2]).toBe('2')552 let $ths = wrapper.findAll('thead > tr > th')553 // Currently not sorted554 expect($ths.at(0).attributes('aria-sort')).toBe('none')555 // For switching to descending556 expect(557 $ths558 .at(0)559 .find('.sr-only')560 .text()561 ).toContain(wrapper.vm.labelSortDesc)562 // Not sorted by this column563 expect($ths.at(1).attributes('aria-sort')).toBe('none')564 // For sorting by ascending565 expect(566 $ths567 .at(1)568 .find('.sr-only')569 .text()570 ).toContain(wrapper.vm.labelSortDesc)571 // Not a sortable column572 expect($ths.at(2).attributes('aria-sort')).not.toBeDefined()573 // For clearing sorting574 expect(575 $ths576 .at(2)577 .find('.sr-only')578 .exists()579 ).toBe(false)580 // Change sort direction (should be descending first)581 await wrapper582 .findAll('thead > tr > th')583 .at(0)584 .trigger('click')585 $rows = wrapper.findAll('tbody > tr').wrappers586 expect($rows.length).toBe(3)587 // Map the rows to the first column text value588 columnA = $rows.map(row => {589 return row590 .findAll('td')591 .at(0)592 .text()593 })594 expect(columnA[0]).toBe('3')595 expect(columnA[1]).toBe('2')596 expect(columnA[2]).toBe('1')597 $ths = wrapper.findAll('thead > tr > th')598 // Currently sorted as descending599 expect($ths.at(0).attributes('aria-sort')).toBe('descending')600 // For switching to ascending601 expect(602 $ths603 .at(0)604 .find('.sr-only')605 .text()606 ).toContain(wrapper.vm.labelSortAsc)607 // Not sorted by this column608 expect($ths.at(1).attributes('aria-sort')).toBe('none')609 // For sorting by ascending610 expect(611 $ths612 .at(1)613 .find('.sr-only')614 .text()615 ).toContain(wrapper.vm.labelSortDesc)616 // Not a sortable column617 expect($ths.at(2).attributes('aria-sort')).not.toBeDefined()618 // For clearing sorting619 expect(620 $ths621 .at(2)622 .find('.sr-only')623 .text()624 ).toContain(wrapper.vm.labelSortClear)625 wrapper.destroy()626 })627 it('non-sortable header th should not emit a sort-changed event when clicked and prop no-sort-reset is set', async () => {628 const wrapper = mount(BTable, {629 propsData: {630 fields: testFields,631 items: testItems,632 noSortReset: true633 }634 })635 expect(wrapper).toBeDefined()636 expect(wrapper.findAll('tbody > tr').exists()).toBe(true)637 expect(wrapper.findAll('tbody > tr').length).toBe(3)638 let $rows639 let columnA640 // Should not be sorted641 await waitNT(wrapper.vm)642 expect(wrapper.emitted('input')).toBeDefined()643 expect(wrapper.emitted('sort-changed')).not.toBeDefined()644 $rows = wrapper.findAll('tbody > tr').wrappers645 expect($rows.length).toBe(3)646 // Map the rows to the first column text value647 columnA = $rows.map(row => {648 return row649 .findAll('td')650 .at(0)651 .text()652 })653 expect(columnA[0]).toBe('3')654 expect(columnA[1]).toBe('1')655 expect(columnA[2]).toBe('2')656 // Click first column to sort657 await wrapper658 .findAll('thead > tr > th')659 .at(0)660 .trigger('click')661 expect(wrapper.emitted('sort-changed')).toBeDefined()662 expect(wrapper.emitted('sort-changed').length).toBe(1)663 $rows = wrapper.findAll('tbody > tr').wrappers664 expect($rows.length).toBe(3)665 // Map the rows to the column text value666 columnA = $rows.map(row => {667 return row668 .findAll('td')669 .at(0)670 .text()671 })672 expect(columnA[0]).toBe('1')673 expect(columnA[1]).toBe('2')674 expect(columnA[2]).toBe('3')675 // Click third column header (should not clear sorting)676 await wrapper677 .findAll('thead > tr > th')678 .at(2)679 .trigger('click')680 expect(wrapper.emitted('sort-changed').length).toBe(1)681 $rows = wrapper.findAll('tbody > tr').wrappers682 expect($rows.length).toBe(3)683 // Map the rows to the column text value684 columnA = $rows.map(row => {685 return row686 .findAll('td')687 .at(0)688 .text()689 })690 expect(columnA[0]).toBe('1')691 expect(columnA[1]).toBe('2')692 expect(columnA[2]).toBe('3')693 wrapper.destroy()694 })695 it('sorting by virtual column formatter works', async () => {696 const wrapper = mount(BTable, {697 propsData: {698 items: [{ a: 5, b: 2 }, { a: 10, b: 9 }],699 fields: [700 'a',701 'b',702 {703 key: 'c',704 sortable: true,705 formatter(value, key, item) {706 return item.a - item.b707 },708 sortByFormatted: true709 }710 ],711 // Initially unsorted712 sortBy: ''713 }714 })715 expect(wrapper).toBeDefined()716 let $trs = wrapper.findAll('tbody > tr')717 expect($trs.length).toBe(2)718 // First Row - unsorted719 let $tds = $trs.at(0).findAll('td')720 expect($tds.length).toBe(3)721 expect($tds.at(0).text()).toBe('5')722 expect($tds.at(1).text()).toBe('2')723 expect($tds.at(2).text()).toBe('3') // 5 - 2724 await wrapper.setProps({725 sortBy: 'c',726 sortDesc: false727 })728 // Grab the sorted TRs729 $trs = wrapper.findAll('tbody > tr')730 expect($trs.length).toBe(2)731 // First Row - sorted (smallest first)732 $tds = $trs.at(0).findAll('td')733 expect($tds.length).toBe(3)734 expect($tds.at(0).text()).toBe('10')735 expect($tds.at(1).text()).toBe('9')736 expect($tds.at(2).text()).toBe('1') // 10 - 9737 wrapper.destroy()738 })...

Full Screen

Full Screen

equality.js

Source:equality.js Github

copy

Full Screen

1// TODO: write `findAll(..)`2const findAll = (value, array) => {3 let response = [];4 array.forEach(item => {5 if (Object.is(value, item)) {6 response.push(item)7 } else if (typeof value == 'string'8 && value.trim().length > 09 && typeof item == 'number'10 && value == item) {11 if (!Object.is(item, -0)) {12 response.push(item)13 }14 } else if (typeof value == 'number'15 && !Number.isNaN(value)16 && Number.isFinite(value)17 && typeof item == 'string'18 && item.trim().length > 019 && value == item) {20 if (!Object.is(value, -0)) {21 response.push(item)22 }23 } else if (typeof value == 'boolean' && typeof item == 'boolean' && value == item) {24 response.push(item)25 } else if (value == null && item == null) {26 response.push(item);27 }28 })29 return response;30}31// tests:32var myObj = { a: 2 };33var values = [34 null, undefined, -0, 0, 13, 42, NaN, -Infinity, Infinity,35 "", "0", "42", "42hello", "true", "NaN", true, false, myObj36];37console.log(setsMatch(findAll(null, values), [null, undefined]) === true);38console.log(setsMatch(findAll(undefined, values), [null, undefined]) === true);39console.log(setsMatch(findAll(0, values), [0, "0"]) === true);40console.log(setsMatch(findAll(-0, values), [-0]) === true);41console.log(setsMatch(findAll(13, values), [13]) === true);42console.log(setsMatch(findAll(42, values), [42, "42"]) === true);43console.log(setsMatch(findAll(NaN, values), [NaN]) === true);44console.log(setsMatch(findAll(-Infinity, values), [-Infinity]) === true);45console.log(setsMatch(findAll(Infinity, values), [Infinity]) === true);46console.log(setsMatch(findAll("", values), [""]) === true);47console.log(setsMatch(findAll("0", values), [0, "0"]) === true);48console.log(setsMatch(findAll("42", values), [42, "42"]) === true);49console.log(setsMatch(findAll("42hello", values), ["42hello"]) === true);50console.log(setsMatch(findAll("true", values), ["true"]) === true);51console.log(setsMatch(findAll(true, values), [true]) === true);52console.log(setsMatch(findAll(false, values), [false]) === true);53console.log(setsMatch(findAll(myObj, values), [myObj]) === true);54console.log(setsMatch(findAll(null, values), [null, 0]) === false);55console.log(setsMatch(findAll(undefined, values), [NaN, 0]) === false);56console.log(setsMatch(findAll(0, values), [0, -0]) === false);57console.log(setsMatch(findAll(42, values), [42, "42hello"]) === false);58console.log(setsMatch(findAll(25, values), [25]) === false);59console.log(setsMatch(findAll(Infinity, values), [Infinity, -Infinity]) === false);60console.log(setsMatch(findAll("", values), ["", 0]) === false);61console.log(setsMatch(findAll("false", values), [false]) === false);62console.log(setsMatch(findAll(true, values), [true, "true"]) === false);63console.log(setsMatch(findAll(true, values), [true, 1]) === false);64console.log(setsMatch(findAll(false, values), [false, 0]) === false);65// ***************************66function setsMatch(arr1, arr2) {67 if (Array.isArray(arr1) && Array.isArray(arr2) && arr1.length == arr2.length) {68 for (let v of arr1) {69 if (!arr2.includes(v)) return false;70 }71 return true;72 }73 return false;...

Full Screen

Full Screen

t465.py

Source:t465.py Github

copy

Full Screen

1import re2print "\nSyntax: ."3print re.findall(".","")4print re.findall(".","a")5print re.findall(".a","a")6print re.findall("a","a")7print re.findall("a.","a\n")8print re.findall(".a","ba")9print "\nSyntax: ^"10print re.findall("^","")11print re.findall("a^","")12print re.findall("^a","ba")13print re.findall("^a","ab")14print re.findall("^a","\na")15print re.findall("a^","a")16print "\nSyntax: $"17print re.findall("$","")18print re.findall("$a","a")19print re.findall("a$","a")20print re.findall("a$","ab")21print re.findall("a$","a\nb")22print re.findall("a$","a\n")23print "\nSyntax: *"24print re.findall("a*","")25print re.findall("ab*","a")26print re.findall("ab*","ab")27print re.findall("ab*","abbbbb")28print re.findall("ab*","ba")29print re.findall("ab*","bbbb")30print "\nSyntax: +"31print re.findall("a+","")32print re.findall("ab+","a")33print re.findall("ab+","ab")34print re.findall("ab+","abbbbb")35print re.findall("ab+","ba")36print re.findall("ab+","bbbb")37print "\nSyntax: ?"38print re.findall("a?","")39print re.findall("ab?","a")40print re.findall("ab?","ab")41print re.findall("ab?","abbbbb")42print re.findall("ab?","ba")43print re.findall("ab?","bbbb")44print "\nSyntax: *?"45print re.findall("a*?","a")46print re.findall("ab*?","abbbb")47print re.findall("ab*?","a")48print re.findall("ab*?","")49print "\nSyntax: +?"50print re.findall("a+?","a")51print re.findall("ab+?","abbbb")52print re.findall("ab+?","a")53print re.findall("ab+?","")54print "\nSyntax: ??"55print re.findall("a??","a")56print re.findall("ab??","abbbb")57print re.findall("ab??","a")58print re.findall("ab??","")59print "\nSyntax: {m}"60print re.findall("a{2}","a")61print re.findall("a{2}","aa")62print re.findall("a{2}","aaa")63print "\nSyntax: {m,n}"64print re.findall("a{1,2}b","b")65print re.findall("a{1,2}b","ab")66print re.findall("a{1,2}b","aab")67print re.findall("a{1,2}b","aaab")68print re.findall("a{,2}b","b")69print re.findall("a{,2}b","ab")70print re.findall("a{,2}b","aab")71print re.findall("a{,2}b","aaab")72print re.findall("a{2,}b","b")73print re.findall("a{2,}b","ab")74print re.findall("a{2,}b","aab")75print re.findall("a{2,}b","aaab")76print re.findall("a{3,5}","aaaaaaaaaa")77print re.findall("a{,5}","aaaaaaaaaa")78print re.findall("a{3,}","aaaaaaaaaa")79print "\nSyntax: {m,n}?"80print re.findall("a{1,2}?b","b")81print re.findall("a{1,2}?b","ab")82print re.findall("a{1,2}?b","aab")83print re.findall("a{1,2}?b","aaab")84print re.findall("a{,2}?b","b")85print re.findall("a{,2}?b","ab")86print re.findall("a{,2}?b","aab")87print re.findall("a{,2}?b","aaab")88print re.findall("a{2,}?b","b")89print re.findall("a{2,}?b","ab")90print re.findall("a{2,}?b","aab")91print re.findall("a{2,}?b","aaab")92print re.findall("a{3,5}?","aaaaaaaaaa")93print re.findall("a{,5}?","aaaaaaaaaa")94print re.findall("a{3,}?","aaaaaaaaaa")95print "\nSyntax: []"96print re.findall("[a,b,c]","abc")97print re.findall("[a-z]","bc")98print re.findall("[A-Z,0-9]","abcdefg")99print re.findall("[^A-Z]","ABCDEFGaHIJKL")100print re.findall("[a*bc]","*")101print "\nSyntax: |"102print re.findall("|","")103print re.findall("|a","")104print re.findall("a|b","ba")105print re.findall("h|ello","hello")106print "\nSyntax: (...)"107print re.findall("(b*)","bbbba") 108print "\nSyntax: (?...)"109print re.findall("(?:b*)","bbbba")110print re.findall("a(?=b)","a")111print re.findall("a(?=b)","ab")112print re.findall("a(?!b)","a")...

Full Screen

Full Screen

ex.js

Source:ex.js Github

copy

Full Screen

1// TODO: write `findAll(..)`2// tests:3var myObj = { a: 2 };4var values = [5 null, undefined, -0, 0, 13, 42, NaN, -Infinity, Infinity,6 "", "0", "42", "42hello", "true", "NaN", true, false, myObj7];8console.log(setsMatch(findAll(null,values),[null,undefined]) === true);9console.log(setsMatch(findAll(undefined,values),[null,undefined]) === true);10console.log(setsMatch(findAll(0,values),[0,"0"]) === true);11console.log(setsMatch(findAll(-0,values),[-0]) === true);12console.log(setsMatch(findAll(13,values),[13]) === true);13console.log(setsMatch(findAll(42,values),[42,"42"]) === true);14console.log(setsMatch(findAll(NaN,values),[NaN]) === true);15console.log(setsMatch(findAll(-Infinity,values),[-Infinity]) === true);16console.log(setsMatch(findAll(Infinity,values),[Infinity]) === true);17console.log(setsMatch(findAll("",values),[""]) === true);18console.log(setsMatch(findAll("0",values),[0,"0"]) === true);19console.log(setsMatch(findAll("42",values),[42,"42"]) === true);20console.log(setsMatch(findAll("42hello",values),["42hello"]) === true);21console.log(setsMatch(findAll("true",values),["true"]) === true);22console.log(setsMatch(findAll(true,values),[true]) === true);23console.log(setsMatch(findAll(false,values),[false]) === true);24console.log(setsMatch(findAll(myObj,values),[myObj]) === true);25console.log(setsMatch(findAll(null,values),[null,0]) === false);26console.log(setsMatch(findAll(undefined,values),[NaN,0]) === false);27console.log(setsMatch(findAll(0,values),[0,-0]) === false);28console.log(setsMatch(findAll(42,values),[42,"42hello"]) === false);29console.log(setsMatch(findAll(25,values),[25]) === false);30console.log(setsMatch(findAll(Infinity,values),[Infinity,-Infinity]) === false);31console.log(setsMatch(findAll("",values),["",0]) === false);32console.log(setsMatch(findAll("false",values),[false]) === false);33console.log(setsMatch(findAll(true,values),[true,"true"]) === false);34console.log(setsMatch(findAll(true,values),[true,1]) === false);35console.log(setsMatch(findAll(false,values),[false,0]) === false);36// ***************************37function setsMatch(arr1,arr2) {38 if (Array.isArray(arr1) && Array.isArray(arr2) && arr1.length == arr2.length) {39 for (let v of arr1) {40 if (!arr2.includes(v)) return false;41 }42 return true;43 }44 return false;...

Full Screen

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