How to use fromId method in storybook-root

Best JavaScript code snippet using storybook-root

simplifier.test.ts

Source:simplifier.test.ts Github

copy

Full Screen

1import {2 fullSimplify,3 simplify,4 transitiveClosure,5} from './simplifier';6import {7 MappingType,8 ExtractedOperationType,9} from './types';10describe('simplifier', () => {11 describe('simplify', () => {12 it('does nothing when nothing needs to be done', () => {13 const extracted: ExtractedOperationType = {14 name: 'foo',15 resources: [{16 id: 'foo',17 attributes: ['foo.par-0', 'foo.return-0'],18 }],19 required: [],20 generated: [],21 parameters: ['foo.par-0'],22 returns: ['foo.return-0'],23 mappings: [],24 };25 const expected: ExtractedOperationType = extracted;26 expect(simplify(extracted)).toStrictEqual(expected);27 });28 it('removes self arrows with wide mapping paths', () => {29 const extracted: ExtractedOperationType = {30 name: 'foo',31 resources: [{32 id: 'foo',33 attributes: ['foo.par-0', 'foo.par-1', 'foo.par-2', 'foo.local-0', 'foo.return-0', 'foo.return-1', 'foo.return-2'],34 }],35 required: ['foo.local-0', 'foo.par-2'],36 generated: ['foo'],37 parameters: ['foo.par-0', 'foo.par-1', 'foo.par-2'],38 returns: ['foo.return-0', 'foo.return-1', 'foo.return-2'],39 mappings: [{40 fromId: 'foo.par-0',41 toId: 'foo.local-0',42 }, {43 fromId: 'foo.local-0',44 toId: 'foo.return-0',45 }, {46 fromId: 'foo.par-1',47 toId: 'foo.local-0',48 }, {49 fromId: 'foo.local-0',50 toId: 'foo.return-1',51 }, {52 fromId: 'foo.par-2',53 toId: 'foo.return-2',54 }],55 };56 const expected: ExtractedOperationType = {57 name: 'foo',58 resources: [{59 id: 'foo',60 attributes: ['foo.par-0', 'foo.par-1', 'foo.par-2', 'foo.return-0', 'foo.return-1', 'foo.return-2'],61 }],62 required: ['foo.par-2'],63 generated: ['foo'],64 parameters: ['foo.par-0', 'foo.par-1', 'foo.par-2'],65 returns: ['foo.return-0', 'foo.return-1', 'foo.return-2'],66 mappings: [{67 fromId: 'foo.par-2',68 toId: 'foo.return-2',69 }, {70 fromId: 'foo.par-0',71 toId: 'foo.return-0',72 }, {73 fromId: 'foo.par-0',74 toId: 'foo.return-1',75 }, {76 fromId: 'foo.par-1',77 toId: 'foo.return-0',78 }, {79 fromId: 'foo.par-1',80 toId: 'foo.return-1',81 }],82 };83 expect(simplify(extracted)).toStrictEqual(expected);84 });85 it('removes self arrows with long mapping paths', () => {86 const extracted: ExtractedOperationType = {87 name: 'foo',88 resources: [{89 id: 'foo',90 attributes: ['foo.par-0', 'foo.local-0', 'foo.local-1', 'foo.local-2', 'foo.return-0'],91 }],92 required: ['foo.local-2'],93 generated: ['foo'],94 parameters: ['foo.par-0'],95 returns: ['foo.return-0'],96 mappings: [{97 fromId: 'foo.par-0',98 toId: 'foo.local-0',99 }, {100 fromId: 'foo.local-0',101 toId: 'foo.local-1',102 }, {103 fromId: 'foo.local-1',104 toId: 'foo.local-2',105 }, {106 fromId: 'foo.local-2',107 toId: 'foo.return-0',108 }],109 };110 const expected: ExtractedOperationType = {111 name: 'foo',112 resources: [{113 id: 'foo',114 attributes: ['foo.par-0', 'foo.return-0'],115 }],116 required: [],117 generated: ['foo'],118 parameters: ['foo.par-0'],119 returns: ['foo.return-0'],120 mappings: [{121 fromId: 'foo.par-0',122 toId: 'foo.return-0',123 }],124 };125 expect(simplify(extracted)).toStrictEqual(expected);126 });127 it('removes locals without corresponding parameters', () => {128 const extracted: ExtractedOperationType = {129 name: 'foo',130 resources: [{131 id: 'foo',132 attributes: ['foo.par-0', 'foo.local-0', 'foo.return-0'],133 }],134 required: [135 'foo.local-0',136 'foo.par-0',137 ],138 generated: [139 'foo',140 'foo.local-0',141 ],142 parameters: ['foo.par-0'],143 returns: ['foo.return-0'],144 mappings: [{145 fromId: 'foo.local-0',146 toId: 'foo.return-0',147 }],148 };149 const expected: ExtractedOperationType = {150 name: 'foo',151 resources: [{152 id: 'foo',153 attributes: ['foo.par-0', 'foo.return-0'],154 }],155 required: [156 'foo.par-0',157 ],158 generated: [159 'foo',160 ],161 parameters: ['foo.par-0'],162 returns: ['foo.return-0'],163 mappings: [],164 };165 expect(simplify(extracted)).toStrictEqual(expected);166 });167 it('removes chains of locals without corresponding parameters', () => {168 const extracted: ExtractedOperationType = {169 name: 'foo',170 resources: [{171 id: 'foo',172 attributes: ['foo.par-0', 'foo.local-0', 'foo.local-1', 'foo.return-0'],173 }],174 required: [175 'foo.local-0',176 'foo.par-0',177 ],178 generated: [179 'foo',180 'foo.local-0',181 ],182 parameters: ['foo.par-0'],183 returns: ['foo.return-0'],184 mappings: [{185 fromId: 'foo.local-0',186 toId: 'foo.local-1',187 }, {188 fromId: 'foo.local-1',189 toId: 'foo.return-0',190 }],191 };192 const expected: ExtractedOperationType = {193 name: 'foo',194 resources: [{195 id: 'foo',196 attributes: ['foo.par-0', 'foo.return-0'],197 }],198 required: [199 'foo.par-0',200 ],201 generated: [202 'foo',203 ],204 parameters: ['foo.par-0'],205 returns: ['foo.return-0'],206 mappings: [],207 };208 expect(simplify(extracted)).toStrictEqual(expected);209 });210 it('removes locals without corresponding returns', () => {211 const extracted: ExtractedOperationType = {212 name: 'foo',213 resources: [{214 id: 'foo',215 attributes: ['foo.par-0', 'foo.local-0', 'foo.return-0'],216 }],217 required: [218 'foo.local-0',219 'foo.par-0',220 ],221 generated: [222 'foo',223 'foo.local-0',224 ],225 parameters: ['foo.par-0'],226 returns: ['foo.return-0'],227 mappings: [{228 fromId: 'foo.par-0',229 toId: 'foo.local-0',230 }],231 };232 const expected: ExtractedOperationType = {233 name: 'foo',234 resources: [{235 id: 'foo',236 attributes: ['foo.par-0', 'foo.return-0'],237 }],238 required: [239 'foo.par-0',240 ],241 generated: [242 'foo',243 ],244 parameters: ['foo.par-0'],245 returns: ['foo.return-0'],246 mappings: [],247 };248 expect(simplify(extracted)).toStrictEqual(expected);249 });250 it('removes chains of locals without corresponding returns', () => {251 const extracted: ExtractedOperationType = {252 name: 'foo',253 resources: [{254 id: 'foo',255 attributes: ['foo.par-0', 'foo.local-0', 'foo.local-1', 'foo.return-0'],256 }],257 required: [258 'foo.local-0',259 'foo.par-0',260 ],261 generated: [262 'foo',263 'foo.local-0',264 ],265 parameters: ['foo.par-0'],266 returns: ['foo.return-0'],267 mappings: [{268 fromId: 'foo.par-0',269 toId: 'foo.local-0',270 }, {271 fromId: 'foo.local-0',272 toId: 'foo.local-1',273 }],274 };275 const expected: ExtractedOperationType = {276 name: 'foo',277 resources: [{278 id: 'foo',279 attributes: ['foo.par-0', 'foo.return-0'],280 }],281 required: [282 'foo.par-0',283 ],284 generated: [285 'foo',286 ],287 parameters: ['foo.par-0'],288 returns: ['foo.return-0'],289 mappings: [],290 };291 expect(simplify(extracted)).toStrictEqual(expected);292 });293 it('is the example we have in the dissertation', () => {294 const extracted: ExtractedOperationType = {295 name: 'foo',296 resources: [{297 id: 'foo',298 attributes: ['foo.par-0', 'foo.par-1', 'foo.par-2', 'foo.local-0', 'foo.return-0', 'foo.return-1'],299 }],300 required: [301 'foo.par-0', // used in declarator init302 'foo.local-0', // used in return303 'foo.par-1', // used in return304 'foo.par-2', // used in return305 ],306 generated: ['foo', 'foo.local-0'],307 parameters: ['foo.par-0', 'foo.par-1', 'foo.par-2'],308 returns: ['foo.return-0', 'foo.return-1'],309 mappings: [{310 fromId: 'foo.par-0',311 toId: 'foo.local-0',312 }, {313 fromId: 'foo.local-0',314 toId: 'foo.return-0',315 }, {316 fromId: 'foo.par-1',317 toId: 'foo.return-0',318 }, {319 fromId: 'foo.par-2',320 toId: 'foo.return-1',321 }],322 };323 const expected: ExtractedOperationType = {324 name: 'foo',325 resources: [{326 id: 'foo',327 attributes: ['foo.par-0', 'foo.par-1', 'foo.par-2', 'foo.return-0', 'foo.return-1'],328 }],329 required: [330 'foo.par-0', // used in declarator init331 'foo.par-1', // used in return332 'foo.par-2', // used in return333 ],334 generated: ['foo'],335 parameters: ['foo.par-0', 'foo.par-1', 'foo.par-2'],336 returns: ['foo.return-0', 'foo.return-1'],337 mappings: [{338 fromId: 'foo.par-1',339 toId: 'foo.return-0',340 }, {341 fromId: 'foo.par-2',342 toId: 'foo.return-1',343 }, {344 fromId: 'foo.par-0',345 toId: 'foo.return-0',346 }],347 };348 expect(simplify(extracted)).toStrictEqual(expected);349 });350 it('throws when parameters are targets of mappings', () => {351 const extracted: ExtractedOperationType = {352 name: 'foo',353 resources: [{354 id: 'foo',355 attributes: ['foo.par-0', 'foo.local-0', 'foo.return-0'],356 }],357 required: [],358 generated: [],359 parameters: ['foo.par-0'],360 returns: ['foo.return-0'],361 mappings: [{362 fromId: 'foo.local-0',363 toId: 'foo.par-0',364 }],365 };366 expect(() => simplify(extracted))367 .toThrow('parameter should not be target of mapping');368 });369 it('throws when returns are sources of mappings', () => {370 const extracted: ExtractedOperationType = {371 name: 'foo',372 resources: [{373 id: 'foo',374 attributes: ['foo.par-0', 'foo.local-0', 'foo.return-0'],375 }],376 required: [],377 generated: [],378 parameters: ['foo.par-0'],379 returns: ['foo.return-0'],380 mappings: [{381 fromId: 'foo.return-0',382 toId: 'foo.local-0',383 }],384 };385 expect(() => simplify(extracted))386 .toThrow('return should not be source of mapping');387 });388 it('throws when locals have self loops', () => {389 const extracted: ExtractedOperationType = {390 name: 'foo',391 resources: [{392 id: 'foo',393 attributes: ['foo.par-0', 'foo.local-0', 'foo.local-1', 'foo.local-2', 'foo.return-0'],394 }],395 required: ['foo.local-2'],396 generated: ['foo'],397 parameters: ['foo.par-0'],398 returns: ['foo.return-0'],399 mappings: [{400 fromId: 'foo.par-0',401 toId: 'foo.local-0',402 }, {403 fromId: 'foo.local-0',404 toId: 'foo.local-1',405 }, {406 fromId: 'foo.local-1',407 toId: 'foo.local-2',408 }, {409 fromId: 'foo.local-2',410 toId: 'foo.return-0',411 }, {412 fromId: 'foo.local-0',413 toId: 'foo.local-0',414 }, {415 fromId: 'foo.local-1',416 toId: 'foo.local-1',417 }, {418 fromId: 'foo.local-2',419 toId: 'foo.local-2',420 }],421 };422 expect(() => simplify(extracted))423 .toThrow('cannot simplify local self loops');424 });425 it('throws when parameters have self loops', () => {426 const extracted: ExtractedOperationType = {427 name: 'foo',428 resources: [{429 id: 'foo',430 attributes: ['foo.par-0'],431 }],432 required: [],433 generated: ['foo'],434 parameters: ['foo.par-0'],435 returns: [],436 mappings: [{437 fromId: 'foo.par-0',438 toId: 'foo.par-0',439 }],440 };441 expect(() => simplify(extracted))442 .toThrow('cannot simplify parameter self loops');443 });444 it('throws when returns have self loops', () => {445 const extracted: ExtractedOperationType = {446 name: 'foo',447 resources: [{448 id: 'foo',449 attributes: ['foo.return-0'],450 }],451 required: [],452 generated: ['foo'],453 parameters: [],454 returns: ['foo.return-0'],455 mappings: [{456 fromId: 'foo.return-0',457 toId: 'foo.return-0',458 }],459 };460 expect(() => simplify(extracted))461 .toThrow('cannot simplify return self loops');462 });463 });464 describe('transitiveClosure', () => {465 it('computes closure of long chains', () => {466 /**467 * a -> b -> c468 */469 const mappings: MappingType[] = [{470 fromId: 'a',471 toId: 'b'472 }, {473 fromId: 'b',474 toId: 'c'475 }];476 expect(transitiveClosure('c', mappings))477 .toStrictEqual([]);478 expect(transitiveClosure('b', mappings))479 .toStrictEqual(['c']);480 expect(transitiveClosure('a', mappings))481 .toStrictEqual(['b', 'c']);482 });483 it('computes closure of wide chains', () => {484 /**485 * a -> b -> c486 * -> f487 * -> d -> e488 * -> g489 */490 const mappings: MappingType[] = [{491 fromId: 'a',492 toId: 'b'493 }, {494 fromId: 'b',495 toId: 'c'496 }, {497 fromId: 'b',498 toId: 'f'499 }, {500 fromId: 'a',501 toId: 'd'502 }, {503 fromId: 'd',504 toId: 'e'505 }, {506 fromId: 'd',507 toId: 'g'508 }];509 expect(transitiveClosure('a', mappings))510 .toStrictEqual(['b', 'd', 'c', 'f', 'e', 'g']);511 expect(transitiveClosure('b', mappings))512 .toStrictEqual(['c', 'f']);513 expect(transitiveClosure('c', mappings))514 .toStrictEqual([]);515 expect(transitiveClosure('f', mappings))516 .toStrictEqual([]);517 expect(transitiveClosure('d', mappings))518 .toStrictEqual(['e', 'g']);519 expect(transitiveClosure('e', mappings))520 .toStrictEqual([]);521 expect(transitiveClosure('g', mappings))522 .toStrictEqual([]);523 });524 it('ignores loops of all kinds, but always filters out initial node', () => {525 /**526 * a -> a527 * c -> a528 * d -> b529 * a -> b -> c530 * -> f531 * -> d -> e532 * -> g533 */534 const mappings: MappingType[] = [{535 fromId: 'a',536 toId: 'a'537 }, {538 fromId: 'c',539 toId: 'a'540 }, {541 fromId: 'd',542 toId: 'b'543 }, {544 fromId: 'a',545 toId: 'b'546 }, {547 fromId: 'b',548 toId: 'c'549 }, {550 fromId: 'b',551 toId: 'f'552 }, {553 fromId: 'a',554 toId: 'd'555 }, {556 fromId: 'd',557 toId: 'e'558 }, {559 fromId: 'd',560 toId: 'g'561 }];562 expect(transitiveClosure('a', mappings))563 .toStrictEqual(['b', 'd', 'c', 'f', 'e', 'g']);564 expect(transitiveClosure('b', mappings))565 .toStrictEqual(['c', 'f', 'a', 'd', 'e', 'g']);566 expect(transitiveClosure('c', mappings))567 .toStrictEqual(['a', 'b', 'd', 'f', 'e', 'g']);568 expect(transitiveClosure('f', mappings))569 .toStrictEqual([]);570 expect(transitiveClosure('d', mappings))571 .toStrictEqual(['b', 'e', 'g', 'c', 'f', 'a']);572 expect(transitiveClosure('e', mappings))573 .toStrictEqual([]);574 expect(transitiveClosure('g', mappings))575 .toStrictEqual([]);576 });577 });578 describe('fullSimplify', () => {579 it('does nothing when nothing needs to be done', () => {580 const extracted: ExtractedOperationType = {581 name: 'foo',582 resources: [{583 id: 'foo',584 attributes: ['foo.par-0', 'foo.return-0'],585 }],586 required: [],587 generated: [],588 parameters: ['foo.par-0'],589 returns: ['foo.return-0'],590 mappings: [],591 };592 const expected: ExtractedOperationType = extracted;593 expect(fullSimplify(extracted)).toStrictEqual(expected);594 });595 it('removes self arrows with wide mapping paths', () => {596 /**597 * par-0 -> local-0 -> return-0598 * par-1 -> -> return-1599 * par-2 -> return-2600 */601 const extracted: ExtractedOperationType = {602 name: 'foo',603 resources: [{604 id: 'foo',605 attributes: ['foo.par-0', 'foo.par-1', 'foo.par-2', 'foo.local-0', 'foo.return-0', 'foo.return-1', 'foo.return-2'],606 }],607 required: ['foo.local-0', 'foo.par-2'],608 generated: ['foo'],609 parameters: ['foo.par-0', 'foo.par-1', 'foo.par-2'],610 returns: ['foo.return-0', 'foo.return-1', 'foo.return-2'],611 mappings: [{612 fromId: 'foo.par-0',613 toId: 'foo.local-0',614 }, {615 fromId: 'foo.local-0',616 toId: 'foo.return-0',617 }, {618 fromId: 'foo.par-1',619 toId: 'foo.local-0',620 }, {621 fromId: 'foo.local-0',622 toId: 'foo.return-1',623 }, {624 fromId: 'foo.par-2',625 toId: 'foo.return-2',626 }],627 };628 const expected: ExtractedOperationType = {629 name: 'foo',630 resources: [{631 id: 'foo',632 attributes: ['foo.par-0', 'foo.par-1', 'foo.par-2', 'foo.return-0', 'foo.return-1', 'foo.return-2'],633 }],634 required: ['foo.par-2', 'foo.par-0', 'foo.par-1'],635 generated: ['foo'],636 parameters: ['foo.par-0', 'foo.par-1', 'foo.par-2'],637 returns: ['foo.return-0', 'foo.return-1', 'foo.return-2'],638 mappings: [],639 };640 expect(fullSimplify(extracted)).toStrictEqual(expected);641 });642 it('removes self arrows with long mapping paths', () => {643 /**644 * par-0 -> local-0 -> local-1 -> local-2 -> return-0645 */646 const extracted: ExtractedOperationType = {647 name: 'foo',648 resources: [{649 id: 'foo',650 attributes: ['foo.par-0', 'foo.local-0', 'foo.local-1', 'foo.local-2', 'foo.return-0'],651 }],652 required: ['foo.local-2'],653 generated: ['foo'],654 parameters: ['foo.par-0'],655 returns: ['foo.return-0'],656 mappings: [{657 fromId: 'foo.par-0',658 toId: 'foo.local-0',659 }, {660 fromId: 'foo.local-0',661 toId: 'foo.local-1',662 }, {663 fromId: 'foo.local-1',664 toId: 'foo.local-2',665 }, {666 fromId: 'foo.local-2',667 toId: 'foo.return-0',668 }],669 };670 const expected: ExtractedOperationType = {671 name: 'foo',672 resources: [{673 id: 'foo',674 attributes: ['foo.par-0', 'foo.return-0'],675 }],676 required: ['foo.par-0'],677 generated: ['foo'],678 parameters: ['foo.par-0'],679 returns: ['foo.return-0'],680 mappings: [],681 };682 expect(fullSimplify(extracted)).toStrictEqual(expected);683 });684 it('removes locals without corresponding parameters', () => {685 /**686 * local-0 -> return-0687 */688 const extracted: ExtractedOperationType = {689 name: 'foo',690 resources: [{691 id: 'foo',692 attributes: ['foo.par-0', 'foo.local-0', 'foo.return-0'],693 }],694 required: [695 'foo.local-0',696 'foo.par-0',697 ],698 generated: [699 'foo',700 'foo.local-0',701 ],702 parameters: ['foo.par-0'],703 returns: ['foo.return-0'],704 mappings: [{705 fromId: 'foo.local-0',706 toId: 'foo.return-0',707 }],708 };709 const expected: ExtractedOperationType = {710 name: 'foo',711 resources: [{712 id: 'foo',713 attributes: ['foo.par-0', 'foo.return-0'],714 }],715 required: [716 'foo.par-0',717 ],718 generated: [719 'foo',720 ],721 parameters: ['foo.par-0'],722 returns: ['foo.return-0'],723 mappings: [],724 };725 expect(fullSimplify(extracted)).toStrictEqual(expected);726 });727 it('removes chains of locals without corresponding parameters', () => {728 /**729 * local-0 > local-1 -> return-0730 */731 const extracted: ExtractedOperationType = {732 name: 'foo',733 resources: [{734 id: 'foo',735 attributes: ['foo.par-0', 'foo.local-0', 'foo.local-1', 'foo.return-0'],736 }],737 required: [738 'foo.local-0',739 'foo.par-0',740 ],741 generated: [742 'foo',743 'foo.local-0',744 ],745 parameters: ['foo.par-0'],746 returns: ['foo.return-0'],747 mappings: [{748 fromId: 'foo.local-0',749 toId: 'foo.local-1',750 }, {751 fromId: 'foo.local-1',752 toId: 'foo.return-0',753 }],754 };755 const expected: ExtractedOperationType = {756 name: 'foo',757 resources: [{758 id: 'foo',759 attributes: ['foo.par-0', 'foo.return-0'],760 }],761 required: [762 'foo.par-0',763 ],764 generated: [765 'foo',766 ],767 parameters: ['foo.par-0'],768 returns: ['foo.return-0'],769 mappings: [],770 };771 expect(fullSimplify(extracted)).toStrictEqual(expected);772 });773 it('removes locals without corresponding returns', () => {774 /**775 * par-0 -> local-0776 */777 const extracted: ExtractedOperationType = {778 name: 'foo',779 resources: [{780 id: 'foo',781 attributes: ['foo.par-0', 'foo.local-0', 'foo.return-0'],782 }],783 required: [784 'foo.local-0',785 'foo.par-0',786 ],787 generated: [788 'foo',789 'foo.local-0',790 ],791 parameters: ['foo.par-0'],792 returns: ['foo.return-0'],793 mappings: [{794 fromId: 'foo.par-0',795 toId: 'foo.local-0',796 }],797 };798 const expected: ExtractedOperationType = {799 name: 'foo',800 resources: [{801 id: 'foo',802 attributes: ['foo.par-0', 'foo.return-0'],803 }],804 required: [805 'foo.par-0',806 ],807 generated: [808 'foo',809 ],810 parameters: ['foo.par-0'],811 returns: ['foo.return-0'],812 mappings: [],813 };814 expect(fullSimplify(extracted)).toStrictEqual(expected);815 });816 it('removes chains of locals without corresponding returns', () => {817 /**818 * par-0 -> local-0 -> local-1819 */820 const extracted: ExtractedOperationType = {821 name: 'foo',822 resources: [{823 id: 'foo',824 attributes: ['foo.par-0', 'foo.local-0', 'foo.local-1', 'foo.return-0'],825 }],826 required: [827 'foo.local-0',828 'foo.par-0',829 ],830 generated: [831 'foo',832 'foo.local-0',833 ],834 parameters: ['foo.par-0'],835 returns: ['foo.return-0'],836 mappings: [{837 fromId: 'foo.par-0',838 toId: 'foo.local-0',839 }, {840 fromId: 'foo.local-0',841 toId: 'foo.local-1',842 }],843 };844 const expected: ExtractedOperationType = {845 name: 'foo',846 resources: [{847 id: 'foo',848 attributes: ['foo.par-0', 'foo.return-0'],849 }],850 required: [851 'foo.par-0',852 ],853 generated: [854 'foo',855 ],856 parameters: ['foo.par-0'],857 returns: ['foo.return-0'],858 mappings: [],859 };860 expect(fullSimplify(extracted)).toStrictEqual(expected);861 });862 it('is the example we have in the dissertation', () => {863 /**864 * par-0 -> local-0 -> return-0865 * par-1 -> return-0866 * par-2 -> return-1867 */868 const extracted: ExtractedOperationType = {869 name: 'foo',870 resources: [{871 id: 'foo',872 attributes: ['foo.par-0', 'foo.par-1', 'foo.par-2', 'foo.local-0', 'foo.return-0', 'foo.return-1'],873 }],874 required: [875 'foo.par-0', // used in declarator init876 'foo.local-0', // used in return877 'foo.par-1', // used in return878 'foo.par-2', // used in return879 ],880 generated: ['foo', 'foo.local-0'],881 parameters: ['foo.par-0', 'foo.par-1', 'foo.par-2'],882 returns: ['foo.return-0', 'foo.return-1'],883 mappings: [{884 fromId: 'foo.par-0',885 toId: 'foo.local-0',886 }, {887 fromId: 'foo.local-0',888 toId: 'foo.return-0',889 }, {890 fromId: 'foo.par-1',891 toId: 'foo.return-0',892 }, {893 fromId: 'foo.par-2',894 toId: 'foo.return-1',895 }],896 };897 const expected: ExtractedOperationType = {898 name: 'foo',899 resources: [{900 id: 'foo',901 attributes: ['foo.par-0', 'foo.par-1', 'foo.par-2', 'foo.return-0', 'foo.return-1'],902 }],903 required: [904 'foo.par-0', // used in declarator init905 'foo.par-1', // used in return906 'foo.par-2', // used in return907 ],908 generated: ['foo'],909 parameters: ['foo.par-0', 'foo.par-1', 'foo.par-2'],910 returns: ['foo.return-0', 'foo.return-1'],911 mappings: [],912 };913 expect(fullSimplify(extracted)).toStrictEqual(expected);914 });915 it('does not throw when parameters are targets of mappings', () => {916 /**917 * local-0 -> par-0918 */919 const extracted: ExtractedOperationType = {920 name: 'foo',921 resources: [{922 id: 'foo',923 attributes: ['foo.par-0', 'foo.local-0', 'foo.return-0'],924 }],925 required: [],926 generated: [],927 parameters: ['foo.par-0'],928 returns: ['foo.return-0'],929 mappings: [{930 fromId: 'foo.local-0',931 toId: 'foo.par-0',932 }],933 };934 935 const expected: ExtractedOperationType = {936 name: 'foo',937 resources: [{938 id: 'foo',939 attributes: ['foo.par-0', 'foo.return-0'],940 }],941 required: [],942 generated: [],943 parameters: ['foo.par-0'],944 returns: ['foo.return-0'],945 mappings: [],946 };947 expect(fullSimplify(extracted)).toStrictEqual(expected);948 });949 it('does not throw when returns are sources of mappings', () => {950 /**951 * return-0 -> local-0952 */953 const extracted: ExtractedOperationType = {954 name: 'foo',955 resources: [{956 id: 'foo',957 attributes: ['foo.par-0', 'foo.local-0', 'foo.return-0'],958 }],959 required: [],960 generated: [],961 parameters: ['foo.par-0'],962 returns: ['foo.return-0'],963 mappings: [{964 fromId: 'foo.return-0',965 toId: 'foo.local-0',966 }],967 };968 969 const expected: ExtractedOperationType = {970 name: 'foo',971 resources: [{972 id: 'foo',973 attributes: ['foo.par-0', 'foo.return-0'],974 }],975 required: [],976 generated: [],977 parameters: ['foo.par-0'],978 returns: ['foo.return-0'],979 mappings: [],980 };981 expect(fullSimplify(extracted)).toStrictEqual(expected);982 });983 it('does not throw when locals have self loops', () => {984 /**985 * local-0 -> local-0986 * local-1 -> local-1987 * local-2 -> local-2988 * par-0 -> local-0 -> local-1 -> local-2 -> return-0989 */990 const extracted: ExtractedOperationType = {991 name: 'foo',992 resources: [{993 id: 'foo',994 attributes: ['foo.par-0', 'foo.local-0', 'foo.local-1', 'foo.local-2', 'foo.return-0'],995 }],996 required: ['foo.local-2'],997 generated: ['foo'],998 parameters: ['foo.par-0'],999 returns: ['foo.return-0'],1000 mappings: [{1001 fromId: 'foo.par-0',1002 toId: 'foo.local-0',1003 }, {1004 fromId: 'foo.local-0',1005 toId: 'foo.local-1',1006 }, {1007 fromId: 'foo.local-1',1008 toId: 'foo.local-2',1009 }, {1010 fromId: 'foo.local-2',1011 toId: 'foo.return-0',1012 }, {1013 fromId: 'foo.local-0',1014 toId: 'foo.local-0',1015 }, {1016 fromId: 'foo.local-1',1017 toId: 'foo.local-1',1018 }, {1019 fromId: 'foo.local-2',1020 toId: 'foo.local-2',1021 }],1022 };1023 1024 const expected: ExtractedOperationType = {1025 name: 'foo',1026 resources: [{1027 id: 'foo',1028 attributes: ['foo.par-0', 'foo.return-0'],1029 }],1030 required: ['foo.par-0'],1031 generated: ['foo'],1032 parameters: ['foo.par-0'],1033 returns: ['foo.return-0'],1034 mappings: [],1035 };1036 expect(fullSimplify(extracted)).toStrictEqual(expected);1037 });1038 it('does not throw when parameters have self loops', () => {1039 /**1040 * par-0 -> par-01041 */1042 const extracted: ExtractedOperationType = {1043 name: 'foo',1044 resources: [{1045 id: 'foo',1046 attributes: ['foo.par-0'],1047 }],1048 required: [],1049 generated: ['foo'],1050 parameters: ['foo.par-0'],1051 returns: [],1052 mappings: [{1053 fromId: 'foo.par-0',1054 toId: 'foo.par-0',1055 }],1056 };1057 1058 const expected: ExtractedOperationType = {1059 name: 'foo',1060 resources: [{1061 id: 'foo',1062 attributes: ['foo.par-0'],1063 }],1064 required: [],1065 generated: ['foo'],1066 parameters: ['foo.par-0'],1067 returns: [],1068 mappings: [],1069 };1070 expect(fullSimplify(extracted)).toStrictEqual(expected);1071 });1072 it('does not throw when returns have self loops', () => {1073 const extracted: ExtractedOperationType = {1074 name: 'foo',1075 resources: [{1076 id: 'foo',1077 attributes: ['foo.return-0'],1078 }],1079 required: [],1080 generated: ['foo'],1081 parameters: [],1082 returns: ['foo.return-0'],1083 mappings: [{1084 fromId: 'foo.return-0',1085 toId: 'foo.return-0',1086 }],1087 };1088 1089 const expected: ExtractedOperationType = {1090 name: 'foo',1091 resources: [{1092 id: 'foo',1093 attributes: ['foo.return-0'],1094 }],1095 required: [],1096 generated: ['foo'],1097 parameters: [],1098 returns: ['foo.return-0'],1099 mappings: [],1100 };1101 expect(fullSimplify(extracted)).toStrictEqual(expected);1102 });1103 });...

Full Screen

Full Screen

webmail.js

Source:webmail.js Github

copy

Full Screen

1var mails = [{2 MailID : 1,3 FromID : 1,4 From : "Ivo Nedkov",5 Date : "2/22/2009",6 Title : "RE: New version of Telerik Trainer"7}, {8 MailID : 2,9 FromID : 2,10 From : "Jytte Petersen",11 Date : "2/22/2009",12 Title : "RE: New version of Telerik Trainer"13}, {14 MailID : 3,15 FromID : 3,16 From : "Renate Messner",17 Date : "2/22/2009",18 Title : "RE: Conferences?"19}, {20 MailID : 4,21 FromID : 4,22 From : "Kevin Babcock",23 Date : "2/21/2009",24 Title : "RE: Conferences?"25}, {26 MailID : 5,27 FromID : 5,28 From : "Hari Kumar",29 Date : "2/21/2009",30 Title : "RE: New 'Your Links' menu on telerik.com"31}, {32 MailID : 6,33 FromID : 3,34 From : "Renate Messner",35 Date : "2/21/2009",36 Title : "RE: Conferences?"37}, {38 MailID : 7,39 FromID : 6,40 From : "Anne Dodsworth",41 Date : "2/21/2009",42 Title : "RE: New 'Your Links' menu on telerik.com"43}, {44 MailID : 8,45 FromID : 7,46 From : "Janet Leverling",47 Date : "2/21/2009",48 Title : "RE: New 'Your Links' menu on telerik.com"49}, {50 MailID : 9,51 FromID : 9,52 From : "Rober King",53 Date : "2/21/2009",54 Title : "RE: New 'Your Links' menu on telerik.com"55}, {56 MailID : 10,57 FromID : 8,58 From : "Laura Callahan",59 Date : "2/20/2009",60 Title : "RE: Telerik Enters the ORM Space"61},{62 MailID : 11,63 FromID : 5,64 From : "Hari Kumar",65 Date : "2/20/2009",66 Title : "RE: New version of Telerik Trainer"67}, {68 MailID : 12,69 FromID : 2,70 From : "Jytte Petersen",71 Date : "2/20/2009",72 Title : "RE: New version of Telerik Trainer"73}, {74 MailID : 13,75 FromID : 4,76 From : "Kevin Babcock",77 Date : "2/20/2009",78 Title : "RE: Conferences?"79}, {80 MailID : 14,81 FromID : 3,82 From : "Renate Messner",83 Date : "2/20/2009",84 Title : "RE: Conferences?"85}, {86 MailID : 15,87 FromID : 1,88 From : "Ivo Nedkov",89 Date : "2/20/2009",90 Title : "RE: New 'Your Links' menu on telerik.com"...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { fromId } = require('storybook-root');2const { toId } = require('storybook-root');3const { getStorybook } = require('storybook-root');4const { getStorybookUI } = require('storybook-root');5const { getStorybookUIParams } = require('storybook-root');6const { getStorybookUIOptions } = require('storybook-root');7const { getStorybookUIRoot } = require('storybook-root');8const { getStorybookUIRootParams } = require('storybook-root');9const { getStorybookUIRootOptions } = require('storybook-root');10const { getStorybookUIRootComponent } = require('storybook-root');11const { getStorybookUIRootComponentParams } = require('storybook-root');12const { getStorybookUIRootComponentOptions } = require('storybook-root');13const { getStorybookUIRootComponentProps } = require('storybook-root');14const { getStorybookUIRootComponentPropsParams } = require('storybook-root');15const { getStorybookUIRootComponentPropsOptions } = require('storybook-root');16const { getStorybookUIRootComponentPropsComponent } = require('storybook-root');17const { getStorybookUIRootComponentPropsComponent

Full Screen

Using AI Code Generation

copy

Full Screen

1import { fromId } from 'storybook-root';2const { fromId } = require('storybook-root');3import { fromId } from 'storybook-root';4const { fromId } = require('storybook-root');5import { fromId } from 'storybook-root';6const { fromId } = require('storybook-root');7import { fromId } from 'storybook-root';8const { fromId } = require('storybook-root');9import { fromId } from 'storybook-root';10const { fromId } = require('storybook-root');11import { fromId } from 'storybook-root';12const { fromId } = require('storybook-root');13import { fromId } from 'storybook-root';14const { fromId } = require('storybook-root');15import { fromId } from 'storybook-root';16const { fromId } = require('storybook-root');17import { fromId } from 'storybook-root';18const { fromId } = require('storybook-root');19import { fromId } from 'storybook-root';20const { fromId } = require('storybook-root');

Full Screen

Using AI Code Generation

copy

Full Screen

1import { fromId } from '@storybook/addon-storyshots';2import initStoryshots from '@storybook/addon-storyshots';3initStoryshots({4 test: fromId('my-id'),5});6import { configure } from '@storybook/react';7function loadStories() {8 require('../stories/index.js');9}10configure(loadStories, module);11import { storiesOf } from '@storybook/react';12import { withInfo } from '@storybook/addon-info';13storiesOf('MyComponent', module)14 .addDecorator(withInfo)15 .add('should render correctly', () => <MyComponent />, { info: { text: 'MyComponent description' } })16 .add('should render correctly with id', () => <MyComponent />, { info: { text: 'MyComponent description', myId: 'my-id' } });

Full Screen

Using AI Code Generation

copy

Full Screen

1import { fromId } from 'storybook-root';2import { storiesOf } from '@storybook/react';3storiesOf('Test', module)4 .add('test', () => {5 const storybookRoot = fromId('storybook-root');6 return <storybookRoot />;7 });8import { shallow } from 'enzyme';9import { fromId } from 'storybook-root';10import { storiesOf } from '@storybook/react';11describe('test', () => {12 it('should render', () => {13 const storybookRoot = fromId('storybook-root');14 const wrapper = shallow(<storybookRoot />);15 expect(wrapper).toBeDefined();16 });17});18import { fromId } from 'storybook-root';19import { storiesOf } from '@storybook/react';20describe('test', () => {21 it('should render', () => {22 const storybookRoot = fromId('storybook-root');23 const wrapper = mount(<storybookRoot />);24 expect(wrapper).toBeDefined();25 });26});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { fromId } from 'storybook-root';2import { storiesOf } from '@storybook/react';3storiesOf('My Component', module)4 .add('with text', () => fromId('MyComponent', 'with text'));5import { fromId } from 'storybook-root';6import { storiesOf } from '@storybook/react';7storiesOf('My Component', module)8 .add('with text', () => fromId('MyComponent', 'with text'));9import { fromId } from 'storybook-root';10import { storiesOf } from '@storybook/react';11storiesOf('My Component', module)12 .add('with text', () => fromId('MyComponent', 'with text'));13import { fromId } from 'storybook-root';14import { storiesOf } from '@storybook/react';15storiesOf('My Component', module)16 .add('with text', () => fromId('MyComponent', 'with text'));17import { fromId } from 'storybook-root';18import { storiesOf } from '@storybook/react';19storiesOf('My Component', module)20 .add('with text', () => fromId('MyComponent', 'with text'));21import { fromId } from 'storybook-root';22import { storiesOf } from '@storybook/react';23storiesOf('My Component', module)24 .add('with text', () => fromId('MyComponent', 'with text'));25import { fromId } from 'storybook-root';26import { storiesOf } from '@storybook/react';27storiesOf('My Component', module)28 .add('with text', () => fromId('MyComponent', 'with text'));29import { fromId } from 'storybook-root';30import { storiesOf } from '@storybook/react';31storiesOf('My Component', module)

Full Screen

Using AI Code Generation

copy

Full Screen

1import { fromId } from '@storybook/api';2const storybookRoot = fromId('storybook-preview-iframe');3const storybookId = storybookRoot.getCurrentStoryData().id;4import { fromId } from '@storybook/api';5const storybookRoot = fromId('storybook-preview-iframe');6const storybookId = storybookRoot.getCurrentStoryData().id;7import { fromId } from '@storybook/api';8const storybookRoot = fromId('storybook-preview-iframe');9const storybookId = storybookRoot.getCurrentStoryData().id;10import { fromId } from '@storybook/api';11const storybookRoot = fromId('storybook-preview-iframe');12const storybookId = storybookRoot.getCurrentStoryData().id;13import { fromId } from '@storybook/api';14const storybookRoot = fromId('storybook-preview-iframe');15const storybookId = storybookRoot.getCurrentStoryData().id;16import { fromId } from '@storybook/api';17const storybookRoot = fromId('storybook-preview-iframe');18const storybookId = storybookRoot.getCurrentStoryData().id;19import { fromId } from '@storybook/api';20const storybookRoot = fromId('storybook-preview-iframe');21const storybookId = storybookRoot.getCurrentStoryData().id;

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 storybook-root 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