How to use Suite method in Mocha

Best JavaScript code snippet using mocha

Center.js

Source:Center.js Github

copy

Full Screen

1describe("Ext.layout.container.Center", function() {23 var ct, item;45 afterEach(function() {6 item = ct = Ext.destroy(ct);7 });89 function makeCt(cfg) {10 ct = new Ext.container.Container(Ext.apply({11 renderTo: Ext.getBody(),12 defaultType: 'component',13 layout: 'center'14 }, cfg));15 item = ct.items.getAt(0);16 }1718 function expectResult(w, h, left, top, ctWidth, ctHeight) {19 var pos = item.getEl().getStyle(['left', 'top']);20 expect(item.getWidth()).toBe(w);21 expect(item.getHeight()).toBe(h);22 expect(parseInt(pos.left, 10)).toBe(left);23 expect(parseInt(pos.top, 10)).toBe(top);24 expect(ct.getWidth()).toBe(ctWidth);25 expect(ct.getHeight()).toBe(ctHeight);26 }2728 function makeAutoSizer(w, h) {29 var css = [];30 if (w) {31 css.push('width: ' + w + 'px');32 }33 if (h) {34 css.push('height: ' + h + 'px');35 }36 return '<div style="' + css.join(';') + '"></div>';37 }3839 it("should respect bodyPadding when used as a panel", function() {40 var pad = 20;4142 ct = new Ext.panel.Panel({43 width: 400,44 height: 400,45 renderTo: Ext.getBody(),46 layout: 'center',47 bodyPadding: pad,48 border: false,49 items: {50 xtype: 'component',51 width: '100%',52 height: '100%'53 }54 });5556 item = ct.items.getAt(0);5758 expect(item.getX() - ct.getX()).toBe(pad);59 expect(item.getY() - ct.getY()).toBe(pad);60 });6162 describe("shrink wrapping child item where dimension is calculated", function() {63 it("should layout width correctly when width is being calculated by parent", function() {64 var p = new Ext.panel.Panel({65 renderTo: Ext.getBody(),66 height: 400,67 width: 400,68 dockedItems: [{69 xtype: 'container',70 dock: 'top',71 layout: 'center',72 items: [{73 xtype: 'component',74 html: makeAutoSizer(100, 30)75 }]76 }]77 });78 ct = p.getDockedItems()[0];79 item = ct.items.first();80 expectResult(100, 30, 150, 0, 400, 30);81 // Assign here so it gets destroyed.82 ct = p;83 });8485 it("should layout height correctly when width is being calculated by parent", function() {86 var p = new Ext.panel.Panel({87 renderTo: Ext.getBody(),88 height: 400,89 width: 400,90 dockedItems: [{91 xtype: 'container',92 dock: 'left',93 layout: 'center',94 items: [{95 xtype: 'component',96 html: makeAutoSizer(30, 100)97 }]98 }]99 });100 ct = p.getDockedItems()[0];101 item = ct.items.first();102 expectResult(30, 100, 0, 150, 30, 400);103 // Assign here so it gets destroyed.104 ct = p;105 });106 });107108 describe("container: fixed width, fixed height", function() {109 function makeSuiteCt(item) {110 makeCt({111 width: 400,112 height: 400,113 items: item114 });115 }116117 function expectSuiteResult(w, h, left, top) {118 // Ct size is static119 expectResult(w, h, left, top, 400, 400);120 }121122 describe("component: fixed width", function() {123 describe("fixed height", function() {124 it("should center the item", function() {125 makeSuiteCt({126 width: 200,127 height: 200128 });129 expectSuiteResult(200, 200, 100, 100);130 });131132 it("should take margins into account", function() {133 makeSuiteCt({134 width: 200,135 height: 200,136 margin: '20 30'137 });138 expectSuiteResult(200, 200, 70, 80);139 });140 });141142 describe("calculated height", function() {143 it("should center the item", function() {144 makeSuiteCt({145 width: 200,146 height: '40%'147 });148 expectSuiteResult(200, 160, 100, 120);149 });150151 it("should take margins into account", function() {152 makeSuiteCt({153 width: 200,154 height: '40%',155 margin: '20 30'156 });157 expectSuiteResult(200, 144, 70, 128);158 });159160 describe("constraints", function() {161 it("should take minHeight into account", function() {162 makeSuiteCt({163 width: 200,164 height: '10%',165 minHeight: 300166 });167 expectSuiteResult(200, 300, 100, 50);168 });169170 it("should take maxHeight into account", function() {171 makeSuiteCt({172 width: 200,173 height: '80%',174 maxHeight: 100175 });176 expectSuiteResult(200, 100, 100, 150);177 });178 });179 });180181 describe("auto height", function() {182 it("should center the item", function() {183 makeSuiteCt({184 width: 200,185 html: makeAutoSizer(null, 50)186 });187 expectSuiteResult(200, 50, 100, 175);188 });189190 it("should take margins into account", function() {191 makeSuiteCt({192 width: 200,193 html: makeAutoSizer(null, 50),194 margin: '20 30'195 });196 expectSuiteResult(200, 50, 70, 155);197 });198199 describe("constraints", function() {200 it("should take minHeight into account", function() {201 makeSuiteCt({202 width: 200,203 html: makeAutoSizer(null, 50),204 minHeight: 300205 });206 expectSuiteResult(200, 300, 100, 50);207 });208209 it("should take maxHeight into account", function() {210 makeSuiteCt({211 width: 200,212 html: makeAutoSizer(null, 300),213 maxHeight: 100214 });215 expectSuiteResult(200, 100, 100, 150);216 });217 });218 });219 });220221 describe("component: calculated width", function() {222 describe("fixed height", function() {223 it("should center the item", function() {224 makeSuiteCt({225 width: '80%',226 height: 200227 });228 expectSuiteResult(320, 200, 40, 100);229 });230231 it("should take margins into account", function() {232 makeSuiteCt({233 width: '80%',234 height: 200,235 margin: '20 30'236 });237 expectSuiteResult(272, 200, 64, 80);238 });239240 describe("constraints", function() {241 it("should take minWidth into account", function() {242 makeSuiteCt({243 width: '10%',244 minWidth: 320,245 height: 200246 });247 expectSuiteResult(320, 200, 40, 100);248 });249250 it("should take maxWidth into account", function() {251 makeSuiteCt({252 width: '80%',253 maxWidth: 100,254 height: 200255 });256 expectSuiteResult(100, 200, 150, 100);257 });258 });259 });260261 describe("calculated height", function() {262 it("should center the item", function() {263 makeSuiteCt({264 width: '80%',265 height: '40%'266 });267 expectSuiteResult(320, 160, 40, 120);268 });269270 it("should take margins into account", function() {271 makeSuiteCt({272 width: '80%',273 height: '40%',274 margin: '20 30'275 });276 expectSuiteResult(272, 144, 64, 128);277 });278279 describe("constraints", function() {280 it("should take minHeight into account", function() {281 makeSuiteCt({282 width: '80%',283 height: '40%',284 minHeight: 300285 });286 expectSuiteResult(320, 300, 40, 50);287 });288289 it("should take maxHeight into account", function() {290 makeSuiteCt({291 width: '80%',292 height: '40%',293 maxHeight: 50294 });295 expectSuiteResult(320, 50, 40, 175);296 });297298 it("should take minWidth into account", function() {299 makeSuiteCt({300 width: '80%',301 height: '40%',302 minWidth: 350303 });304 expectSuiteResult(350, 160, 25, 120);305 });306307 it("should take maxWidth into account", function() {308 makeSuiteCt({309 width: '80%',310 height: '40%',311 maxWidth: 100312 });313 expectSuiteResult(100, 160, 150, 120);314 });315 });316 });317318 describe("auto height", function() {319 it("should center the item", function() {320 makeSuiteCt({321 width: '80%',322 html: makeAutoSizer(null, 100)323 });324 expectSuiteResult(320, 100, 40, 150);325 });326327 it("should take margins into account", function() {328 makeSuiteCt({329 width: '80%',330 html: makeAutoSizer(null, 100),331 margin: '20 30'332 });333 expectSuiteResult(272, 100, 64, 130);334 });335336 describe("constraints", function() {337 it("should take minHeight into account", function() {338 makeSuiteCt({339 width: '80%',340 html: makeAutoSizer(null, 100),341 minHeight: 300342 });343 expectSuiteResult(320, 300, 40, 50);344 });345346 it("should take maxHeight into account", function() {347 makeSuiteCt({348 width: '80%',349 html: makeAutoSizer(null, 350),350 maxHeight: 300351 });352 expectSuiteResult(320, 300, 40, 50);353 });354355 it("should take minWidth into account", function() {356 makeSuiteCt({357 width: '80%',358 html: makeAutoSizer(null, 100),359 minWidth: 350360 });361 expectSuiteResult(350, 100, 25, 150);362 });363364 it("should take maxWidth into account", function() {365 makeSuiteCt({366 width: '80%',367 html: makeAutoSizer(null, 100),368 maxWidth: 100369 });370 expectSuiteResult(100, 100, 150, 150);371 });372 });373 });374 });375376 describe("component: auto width", function() {377 describe("fixed height", function() {378 it("should center the item", function() {379 makeSuiteCt({380 html: makeAutoSizer(200),381 height: 200382 });383 expectSuiteResult(200, 200, 100, 100);384 });385386 it("should take margins into account", function() {387 makeSuiteCt({388 html: makeAutoSizer(200),389 height: 200,390 margin: '20 30'391 });392 expectSuiteResult(200, 200, 70, 80);393 });394395 describe("constraints", function() {396 it("should take minWidth into account", function() {397 makeSuiteCt({398 html: makeAutoSizer(200),399 height: 200,400 minWidth: 300401 });402 expectSuiteResult(300, 200, 50, 100);403 });404405 it("should take maxWidth into account", function() {406 makeSuiteCt({407 html: makeAutoSizer(200),408 height: 200,409 maxWidth: 100410 });411 expectSuiteResult(100, 200, 150, 100);412 });413 });414 });415416 describe("calculated height", function() {417 it("should center the item", function() {418 makeSuiteCt({419 html: makeAutoSizer(200),420 height: '40%'421 });422 expectSuiteResult(200, 160, 100, 120);423 });424425 it("should take margins into account", function() {426 makeSuiteCt({427 html: makeAutoSizer(200),428 height: '40%',429 margin: '20 30'430 });431 expectSuiteResult(200, 144, 70, 128);432 });433434 describe("constraints", function() {435 it("should take minHeight into account", function() {436 makeSuiteCt({437 html: makeAutoSizer(200),438 height: '40%',439 minHeight: 300440 });441 expectSuiteResult(200, 300, 100, 50);442 });443444 it("should take maxHeight into account", function() {445 makeSuiteCt({446 html: makeAutoSizer(200),447 height: '40%',448 maxHeight: 50449 });450 expectSuiteResult(200, 50, 100, 175);451 });452453 it("should take minWidth into account", function() {454 makeSuiteCt({455 html: makeAutoSizer(200),456 height: '40%',457 minWidth: 300458 });459 expectSuiteResult(300, 160, 50, 120);460 });461462 it("should take maxWidth into account", function() {463 makeSuiteCt({464 html: makeAutoSizer(200),465 height: '40%',466 maxWidth: 100467 });468 expectSuiteResult(100, 160, 150, 120);469 });470 });471 });472473 describe("auto height", function() {474 it("should center the item", function() {475 makeSuiteCt({476 html: makeAutoSizer(200, 100)477 });478 expectSuiteResult(200, 100, 100, 150);479 });480481 it("should take margins into account", function() {482 makeSuiteCt({483 html: makeAutoSizer(200, 100),484 margin: '20 30'485 });486 expectSuiteResult(200, 100, 70, 130);487 });488489 describe("constraints", function() {490 it("should take minHeight into account", function() {491 makeSuiteCt({492 html: makeAutoSizer(200, 100),493 minHeight: 300494 });495 expectSuiteResult(200, 300, 100, 50);496 });497498 it("should take maxHeight into account", function() {499 makeSuiteCt({500 html: makeAutoSizer(200, 100),501 maxHeight: 50502 });503 expectSuiteResult(200, 50, 100, 175);504 });505506 it("should take minWidth into account", function() {507 makeSuiteCt({508 html: makeAutoSizer(200, 100),509 minWidth: 300510 });511 expectSuiteResult(300, 100, 50, 150);512 });513514 it("should take maxWidth into account", function() {515 makeSuiteCt({516 html: makeAutoSizer(200, 100),517 maxWidth: 100518 });519 expectSuiteResult(100, 100, 150, 150);520 });521 });522 });523 });524 });525526 describe("container: fixed width, auto height", function() {527 function makeSuiteCt(item) {528 makeCt({529 width: 400,530 items: item531 });532 }533534 function expectSuiteResult(w, h, left, ctHeight) {535 // Top of the item & ctWidth are static536 expectResult(w, h, left, 0, 400, ctHeight);537 }538539 describe("component: fixed width", function() {540 describe("fixed height", function() {541 it("should center the item", function() {542 makeSuiteCt({543 width: 200,544 height: 200545 });546 expectSuiteResult(200, 200, 100, 200);547 });548549 it("should take margins into account", function() {550 makeSuiteCt({551 width: 200,552 height: 200,553 margin: '20 30'554 });555 expectSuiteResult(200, 200, 70, 240);556 });557 });558559 describe("calculated height", function() {560 it("should center the item", function() {561 makeSuiteCt({562 width: 200,563 height: '40%'564 });565 expectSuiteResult(200, 0, 100, 0);566 });567568 it("should take margins into account", function() {569 makeSuiteCt({570 width: 200,571 height: '40%',572 margin: '20 30'573 });574 expectSuiteResult(200, 0, 70, 40);575 });576577 describe("constraints", function() {578 it("should take minHeight into account", function() {579 makeSuiteCt({580 width: 200,581 height: '10%',582 minHeight: 300583 });584 expectSuiteResult(200, 300, 100, 300);585 });586587 it("should take maxHeight into account", function() {588 makeSuiteCt({589 width: 200,590 height: '80%',591 maxHeight: 100592 });593 expectSuiteResult(200, 0, 100, 0);594 });595 });596 });597598 describe("auto height", function() {599 it("should center the item", function() {600 makeSuiteCt({601 width: 200,602 html: makeAutoSizer(null, 50)603 });604 expectSuiteResult(200, 50, 100, 50);605 });606607 it("should take margins into account", function() {608 makeSuiteCt({609 width: 200,610 html: makeAutoSizer(null, 50),611 margin: '20 30'612 });613 expectSuiteResult(200, 50, 70, 90);614 });615616 describe("constraints", function() {617 it("should take minHeight into account", function() {618 makeSuiteCt({619 width: 200,620 html: makeAutoSizer(null, 50),621 minHeight: 300622 });623 expectSuiteResult(200, 300, 100, 300);624 });625626 it("should take maxHeight into account", function() {627 makeSuiteCt({628 width: 200,629 html: makeAutoSizer(null, 300),630 maxHeight: 100631 });632 expectSuiteResult(200, 100, 100, 100);633 });634 });635 });636 });637638 describe("component: calculated width", function() {639 describe("fixed height", function() {640 it("should center the item", function() {641 makeSuiteCt({642 width: '80%',643 height: 200644 });645 expectSuiteResult(320, 200, 40, 200);646 });647648 it("should take margins into account", function() {649 makeSuiteCt({650 width: '80%',651 height: 200,652 margin: '20 30'653 });654 expectSuiteResult(272, 200, 64, 240);655 });656657 describe("constraints", function() {658 it("should take minWidth into account", function() {659 makeSuiteCt({660 width: '10%',661 minWidth: 320,662 height: 200663 });664 expectSuiteResult(320, 200, 40, 200);665 });666667 it("should take maxWidth into account", function() {668 makeSuiteCt({669 width: '80%',670 maxWidth: 100,671 height: 200672 });673 expectSuiteResult(100, 200, 150, 200);674 });675 });676 });677678 describe("calculated height", function() {679 it("should center the item", function() {680 makeSuiteCt({681 width: '80%',682 height: '40%'683 });684 expectSuiteResult(320, 0, 40, 0);685 });686687 it("should take margins into account", function() {688 makeSuiteCt({689 width: '80%',690 height: '40%',691 margin: '20 30'692 });693 expectSuiteResult(272, 0, 64, 40);694 });695696 describe("constraints", function() {697 it("should take minHeight into account", function() {698 makeSuiteCt({699 width: '80%',700 height: '40%',701 minHeight: 300702 });703 expectSuiteResult(320, 300, 40, 300);704 });705706 it("should take maxHeight into account", function() {707 makeSuiteCt({708 width: '80%',709 height: '40%',710 maxHeight: 50711 });712 expectSuiteResult(320, 0, 40, 0);713 });714715 it("should take minWidth into account", function() {716 makeSuiteCt({717 width: '80%',718 height: '40%',719 minWidth: 350720 });721 expectSuiteResult(350, 0, 25, 0);722 });723724 it("should take maxWidth into account", function() {725 makeSuiteCt({726 width: '80%',727 height: '40%',728 maxWidth: 100729 });730 expectSuiteResult(100, 0, 150, 0);731 });732 });733 });734735 describe("auto height", function() {736 it("should center the item", function() {737 makeSuiteCt({738 width: '80%',739 html: makeAutoSizer(null, 100)740 });741 expectSuiteResult(320, 100, 40, 100);742 });743744 it("should take margins into account", function() {745 makeSuiteCt({746 width: '80%',747 html: makeAutoSizer(null, 100),748 margin: '20 30'749 });750 expectSuiteResult(272, 100, 64, 140);751 });752753 describe("constraints", function() {754 it("should take minHeight into account", function() {755 makeSuiteCt({756 width: '80%',757 html: makeAutoSizer(null, 100),758 minHeight: 300759 });760 expectSuiteResult(320, 300, 40, 300);761 });762763 it("should take maxHeight into account", function() {764 makeSuiteCt({765 width: '80%',766 html: makeAutoSizer(null, 350),767 maxHeight: 300768 });769 expectSuiteResult(320, 300, 40, 300);770 });771772 it("should take minWidth into account", function() {773 makeSuiteCt({774 width: '80%',775 html: makeAutoSizer(null, 100),776 minWidth: 350777 });778 expectSuiteResult(350, 100, 25, 100);779 });780781 it("should take maxWidth into account", function() {782 makeSuiteCt({783 width: '80%',784 html: makeAutoSizer(null, 100),785 maxWidth: 100786 });787 expectSuiteResult(100, 100, 150, 100);788 });789 });790 });791 });792793 describe("component: auto width", function() {794 describe("fixed height", function() {795 it("should center the item", function() {796 makeSuiteCt({797 html: makeAutoSizer(200),798 height: 200799 });800 expectSuiteResult(200, 200, 100, 200);801 });802803 it("should take margins into account", function() {804 makeSuiteCt({805 html: makeAutoSizer(200),806 height: 200,807 margin: '20 30'808 });809 expectSuiteResult(200, 200, 70, 240);810 });811812 describe("constraints", function() {813 it("should take minWidth into account", function() {814 makeSuiteCt({815 html: makeAutoSizer(200),816 height: 200,817 minWidth: 300818 });819 expectSuiteResult(300, 200, 50, 200);820 });821822 it("should take maxWidth into account", function() {823 makeSuiteCt({824 html: makeAutoSizer(200),825 height: 200,826 maxWidth: 100827 });828 expectSuiteResult(100, 200, 150, 200);829 });830 });831 });832833 describe("calculated height", function() {834 it("should center the item", function() {835 makeSuiteCt({836 html: makeAutoSizer(200),837 height: '40%'838 });839 expectSuiteResult(200, 0, 100, 0);840 });841842 it("should take margins into account", function() {843 makeSuiteCt({844 html: makeAutoSizer(200),845 height: '40%',846 margin: '20 30'847 });848 expectSuiteResult(200, 0, 70, 40);849 });850851 describe("constraints", function() {852 it("should take minHeight into account", function() {853 makeSuiteCt({854 html: makeAutoSizer(200),855 height: '40%',856 minHeight: 300857 });858 expectSuiteResult(200, 300, 100, 300);859 });860861 it("should take maxHeight into account", function() {862 makeSuiteCt({863 html: makeAutoSizer(200),864 height: '40%',865 maxHeight: 50866 });867 expectSuiteResult(200, 0, 100, 0);868 });869870 it("should take minWidth into account", function() {871 makeSuiteCt({872 html: makeAutoSizer(200),873 height: '40%',874 minWidth: 300875 });876 expectSuiteResult(300, 0, 50, 0);877 });878879 it("should take maxWidth into account", function() {880 makeSuiteCt({881 html: makeAutoSizer(200),882 height: '40%',883 maxWidth: 100884 });885 expectSuiteResult(100, 0, 150, 0);886 });887 });888 });889890 describe("auto height", function() {891 it("should center the item", function() {892 makeSuiteCt({893 html: makeAutoSizer(200, 100)894 });895 expectSuiteResult(200, 100, 100, 100);896 });897898 it("should take margins into account", function() {899 makeSuiteCt({900 html: makeAutoSizer(200, 100),901 margin: '20 30'902 });903 expectSuiteResult(200, 100, 70, 140);904 });905906 describe("constraints", function() {907 it("should take minHeight into account", function() {908 makeSuiteCt({909 html: makeAutoSizer(200, 100),910 minHeight: 300911 });912 expectSuiteResult(200, 300, 100, 300);913 });914915 it("should take maxHeight into account", function() {916 makeSuiteCt({917 html: makeAutoSizer(200, 100),918 maxHeight: 50919 });920 expectSuiteResult(200, 50, 100, 50);921 });922923 it("should take minWidth into account", function() {924 makeSuiteCt({925 html: makeAutoSizer(200, 100),926 minWidth: 300927 });928 expectSuiteResult(300, 100, 50, 100);929 });930931 it("should take maxWidth into account", function() {932 makeSuiteCt({933 html: makeAutoSizer(200, 100),934 maxWidth: 100935 });936 expectSuiteResult(100, 100, 150, 100);937 });938 });939 });940 });941 });942943 describe("container: auto width, fixed height", function() {944 function makeSuiteCt(item) {945 makeCt({946 floating: true, // Float the ct so it shrink wraps947 height: 400,948 items: item949 });950 }951952 function expectSuiteResult(w, h, top, ctWidth) {953 // Left of the item & ctHeight are static954 expectResult(w, h, 0, top, ctWidth, 400);955 }956957 describe("component: fixed width", function() {958 describe("fixed height", function() {959 it("should center the item", function() {960 makeSuiteCt({961 width: 200,962 height: 200963 });964 expectSuiteResult(200, 200, 100, 200);965 });966967 it("should take margins into account", function() {968 makeSuiteCt({969 width: 200,970 height: 200,971 margin: '20 30'972 });973 expectSuiteResult(200, 200, 80, 260);974 });975 });976977 describe("calculated height", function() {978 it("should center the item", function() {979 makeSuiteCt({980 width: 200,981 height: '40%'982 });983 expectSuiteResult(200, 160, 120, 200);984 });985986 it("should take margins into account", function() {987 makeSuiteCt({988 width: 200,989 height: '40%',990 margin: '20 30'991 });992 expectSuiteResult(200, 144, 128, 260);993 });994995 describe("constraints", function() {996 it("should take minHeight into account", function() {997 makeSuiteCt({998 width: 200,999 height: '10%',1000 minHeight: 3001001 });1002 expectSuiteResult(200, 300, 50, 200);1003 });10041005 it("should take maxHeight into account", function() {1006 makeSuiteCt({1007 width: 200,1008 height: '80%',1009 maxHeight: 1001010 });1011 expectSuiteResult(200, 100, 150, 200);1012 });1013 });1014 });10151016 describe("auto height", function() {1017 it("should center the item", function() {1018 makeSuiteCt({1019 width: 200,1020 html: makeAutoSizer(null, 50)1021 });1022 expectSuiteResult(200, 50, 175, 200);1023 });10241025 it("should take margins into account", function() {1026 makeSuiteCt({1027 width: 200,1028 html: makeAutoSizer(null, 50),1029 margin: '20 30'1030 });1031 expectSuiteResult(200, 50, 155, 260);1032 });10331034 describe("constraints", function() {1035 it("should take minHeight into account", function() {1036 makeSuiteCt({1037 width: 200,1038 html: makeAutoSizer(null, 50),1039 minHeight: 3001040 });1041 expectSuiteResult(200, 300, 50, 200);1042 });10431044 it("should take maxHeight into account", function() {1045 makeSuiteCt({1046 width: 200,1047 html: makeAutoSizer(null, 300),1048 maxHeight: 1001049 });1050 expectSuiteResult(200, 100, 150, 200);1051 });1052 });1053 });1054 });10551056 describe("component: calculated width", function() {1057 describe("fixed height", function() {1058 it("should center the item", function() {1059 makeSuiteCt({1060 width: '80%',1061 height: 2001062 });1063 expectSuiteResult(0, 200, 100, 0);1064 });10651066 it("should take margins into account", function() {1067 makeSuiteCt({1068 width: '80%',1069 height: 200,1070 margin: '20 30'1071 });1072 expectSuiteResult(0, 200, 80, 60);1073 });10741075 describe("constraints", function() {1076 it("should take minWidth into account", function() {1077 makeSuiteCt({1078 width: '10%',1079 minWidth: 320,1080 height: 2001081 });1082 expectSuiteResult(320, 200, 100, 320);1083 });10841085 it("should take maxWidth into account", function() {1086 makeSuiteCt({1087 width: '80%',1088 maxWidth: 100,1089 height: 2001090 });1091 expectSuiteResult(0, 200, 100, 0);1092 });1093 });1094 });10951096 describe("calculated height", function() {1097 it("should center the item", function() {1098 makeSuiteCt({1099 width: '80%',1100 height: '40%'1101 });1102 expectSuiteResult(0, 160, 120, 0);1103 });11041105 it("should take margins into account", function() {1106 makeSuiteCt({1107 width: '80%',1108 height: '40%',1109 margin: '20 30'1110 });1111 expectSuiteResult(0, 144, 128, 60);1112 });11131114 describe("constraints", function() {1115 it("should take minHeight into account", function() {1116 makeSuiteCt({1117 width: '80%',1118 height: '40%',1119 minHeight: 3001120 });1121 expectSuiteResult(0, 300, 50, 0);1122 });11231124 it("should take maxHeight into account", function() {1125 makeSuiteCt({1126 width: '80%',1127 height: '40%',1128 maxHeight: 501129 });1130 expectSuiteResult(0, 50, 175, 0);1131 });11321133 it("should take minWidth into account", function() {1134 makeSuiteCt({1135 width: '80%',1136 height: '40%',1137 minWidth: 3501138 });1139 expectSuiteResult(350, 160, 120, 350);1140 });11411142 it("should take maxWidth into account", function() {1143 makeSuiteCt({1144 width: '80%',1145 height: '40%',1146 maxWidth: 1001147 });1148 expectSuiteResult(0, 160, 120, 0);1149 });1150 });1151 });11521153 describe("auto height", function() {1154 it("should center the item", function() {1155 makeSuiteCt({1156 width: '80%',1157 html: makeAutoSizer(null, 100)1158 });1159 expectSuiteResult(0, 100, 150, 0);1160 });11611162 it("should take margins into account", function() {1163 makeSuiteCt({1164 width: '80%',1165 html: makeAutoSizer(null, 100),1166 margin: '20 30'1167 });1168 expectSuiteResult(0, 100, 130, 60);1169 });11701171 describe("constraints", function() {1172 it("should take minHeight into account", function() {1173 makeSuiteCt({1174 width: '80%',1175 html: makeAutoSizer(null, 100),1176 minHeight: 3001177 });1178 expectSuiteResult(0, 300, 50, 0);1179 });11801181 it("should take maxHeight into account", function() {1182 makeSuiteCt({1183 width: '80%',1184 html: makeAutoSizer(null, 350),1185 maxHeight: 3001186 });1187 expectSuiteResult(0, 300, 50, 0);1188 });11891190 it("should take minWidth into account", function() {1191 makeSuiteCt({1192 width: '80%',1193 html: makeAutoSizer(null, 100),1194 minWidth: 3501195 });1196 expectSuiteResult(350, 100, 150, 350);1197 });11981199 it("should take maxWidth into account", function() {1200 makeSuiteCt({1201 width: '80%',1202 html: makeAutoSizer(null, 100),1203 maxWidth: 1001204 });1205 expectSuiteResult(0, 100, 150, 0);1206 });1207 });1208 });1209 });12101211 describe("component: auto width", function() {1212 describe("fixed height", function() {1213 it("should center the item", function() {1214 makeSuiteCt({1215 html: makeAutoSizer(200),1216 height: 2001217 });1218 expectSuiteResult(200, 200, 100, 200);1219 });12201221 it("should take margins into account", function() {1222 makeSuiteCt({1223 html: makeAutoSizer(200),1224 height: 200,1225 margin: '20 30'1226 });1227 expectSuiteResult(200, 200, 80, 260);1228 });12291230 describe("constraints", function() {1231 it("should take minWidth into account", function() {1232 makeSuiteCt({1233 html: makeAutoSizer(200),1234 height: 200,1235 minWidth: 3001236 });1237 expectSuiteResult(300, 200, 100, 300);1238 });12391240 it("should take maxWidth into account", function() {1241 makeSuiteCt({1242 html: makeAutoSizer(200),1243 height: 200,1244 maxWidth: 1001245 });1246 expectSuiteResult(100, 200, 100, 100);1247 });1248 });1249 });12501251 describe("calculated height", function() {1252 it("should center the item", function() {1253 makeSuiteCt({1254 html: makeAutoSizer(200),1255 height: '40%'1256 });1257 expectSuiteResult(200, 160, 120, 200);1258 });12591260 it("should take margins into account", function() {1261 makeSuiteCt({1262 html: makeAutoSizer(200),1263 height: '40%',1264 margin: '20 30'1265 });1266 expectSuiteResult(200, 144, 128, 260);1267 });12681269 describe("constraints", function() {1270 it("should take minHeight into account", function() {1271 makeSuiteCt({1272 html: makeAutoSizer(200),1273 height: '40%',1274 minHeight: 3001275 });1276 expectSuiteResult(200, 300, 50, 200);1277 });12781279 it("should take maxHeight into account", function() {1280 makeSuiteCt({1281 html: makeAutoSizer(200),1282 height: '40%',1283 maxHeight: 501284 });1285 expectSuiteResult(200, 50, 175, 200);1286 });12871288 it("should take minWidth into account", function() {1289 makeSuiteCt({1290 html: makeAutoSizer(200),1291 height: '40%',1292 minWidth: 3001293 });1294 expectSuiteResult(300, 160, 120, 300);1295 });12961297 it("should take maxWidth into account", function() {1298 makeSuiteCt({1299 html: makeAutoSizer(200),1300 height: '40%',1301 maxWidth: 1001302 });1303 expectSuiteResult(100, 160, 120, 100);1304 });1305 });1306 });13071308 describe("auto height", function() {1309 it("should center the item", function() {1310 makeSuiteCt({1311 html: makeAutoSizer(200, 100)1312 });1313 expectSuiteResult(200, 100, 150, 200);1314 });13151316 it("should take margins into account", function() {1317 makeSuiteCt({1318 html: makeAutoSizer(200, 100),1319 margin: '20 30'1320 });1321 expectSuiteResult(200, 100, 130, 260);1322 });13231324 describe("constraints", function() {1325 it("should take minHeight into account", function() {1326 makeSuiteCt({1327 html: makeAutoSizer(200, 100),1328 minHeight: 3001329 });1330 expectSuiteResult(200, 300, 50, 200);1331 });13321333 it("should take maxHeight into account", function() {1334 makeSuiteCt({1335 html: makeAutoSizer(200, 100),1336 maxHeight: 501337 });1338 expectSuiteResult(200, 50, 175, 200);1339 });13401341 it("should take minWidth into account", function() {1342 makeSuiteCt({1343 html: makeAutoSizer(200, 100),1344 minWidth: 3001345 });1346 expectSuiteResult(300, 100, 150, 300);1347 });13481349 it("should take maxWidth into account", function() {1350 makeSuiteCt({1351 html: makeAutoSizer(200, 100),1352 maxWidth: 1001353 });1354 expectSuiteResult(100, 100, 150, 100);1355 });1356 });1357 });1358 });1359 });13601361 describe("container: auto width, auto height", function() {1362 function makeSuiteCt(item) {1363 makeCt({1364 floating: true, // Float the ct so it shrink wraps1365 items: item1366 });1367 }13681369 function expectSuiteResult(w, h, ctWidth, ctHeight) {1370 // Position of the item should always be 0,01371 expectResult(w, h, 0, 0, ctWidth, ctHeight);1372 }13731374 describe("component: fixed width", function() {1375 describe("fixed height", function() {1376 it("should center the item", function() {1377 makeSuiteCt({1378 width: 200,1379 height: 2001380 });1381 expectSuiteResult(200, 200, 200, 200);1382 });13831384 it("should take margins into account", function() {1385 makeSuiteCt({1386 width: 200,1387 height: 200,1388 margin: '20 30'1389 });1390 expectSuiteResult(200, 200, 260, 240);1391 });1392 });13931394 describe("calculated height", function() {1395 it("should center the item", function() {1396 makeSuiteCt({1397 width: 200,1398 height: '40%'1399 });1400 expectSuiteResult(200, 0, 200, 0);1401 });14021403 it("should take margins into account", function() {1404 makeSuiteCt({1405 width: 200,1406 height: '40%',1407 margin: '20 30'1408 });1409 expectSuiteResult(200, 0, 260, 40);1410 });14111412 describe("constraints", function() {1413 it("should take minHeight into account", function() {1414 makeSuiteCt({1415 width: 200,1416 height: '10%',1417 minHeight: 3001418 });1419 expectSuiteResult(200, 300, 200, 300);1420 });14211422 it("should take maxHeight into account", function() {1423 makeSuiteCt({1424 width: 200,1425 height: '80%',1426 maxHeight: 1001427 });1428 expectSuiteResult(200, 0, 200, 0);1429 });1430 });1431 });14321433 describe("auto height", function() {1434 it("should center the item", function() {1435 makeSuiteCt({1436 width: 200,1437 html: makeAutoSizer(null, 50)1438 });1439 expectSuiteResult(200, 50, 200, 50);1440 });14411442 it("should take margins into account", function() {1443 makeSuiteCt({1444 width: 200,1445 html: makeAutoSizer(null, 50),1446 margin: '20 30'1447 });1448 expectSuiteResult(200, 50, 260, 90);1449 });14501451 describe("constraints", function() {1452 it("should take minHeight into account", function() {1453 makeSuiteCt({1454 width: 200,1455 html: makeAutoSizer(null, 50),1456 minHeight: 3001457 });1458 expectSuiteResult(200, 300, 200, 300);1459 });14601461 it("should take maxHeight into account", function() {1462 makeSuiteCt({1463 width: 200,1464 html: makeAutoSizer(null, 300),1465 maxHeight: 1001466 });1467 expectSuiteResult(200, 100, 200, 100);1468 });1469 });1470 });1471 });14721473 describe("component: calculated width", function() {1474 describe("fixed height", function() {1475 it("should center the item", function() {1476 makeSuiteCt({1477 width: '80%',1478 height: 2001479 });1480 expectSuiteResult(0, 200, 0, 200);1481 });14821483 it("should take margins into account", function() {1484 makeSuiteCt({1485 width: '80%',1486 height: 200,1487 margin: '20 30'1488 });1489 expectSuiteResult(0, 200, 60, 240);1490 });14911492 describe("constraints", function() {1493 it("should take minWidth into account", function() {1494 makeSuiteCt({1495 width: '10%',1496 minWidth: 320,1497 height: 2001498 });1499 expectSuiteResult(320, 200, 320, 200);1500 });15011502 it("should take maxWidth into account", function() {1503 makeSuiteCt({1504 width: '80%',1505 maxWidth: 100,1506 height: 2001507 });1508 expectSuiteResult(0, 200, 0, 200);1509 });1510 });1511 });15121513 describe("calculated height", function() {1514 it("should center the item", function() {1515 makeSuiteCt({1516 width: '80%',1517 height: '40%'1518 });1519 expectSuiteResult(0, 0, 0, 0);1520 });15211522 it("should take margins into account", function() {1523 makeSuiteCt({1524 width: '80%',1525 height: '40%',1526 margin: '20 30'1527 });1528 expectSuiteResult(0, 0, 60, 40);1529 });15301531 describe("constraints", function() {1532 it("should take minHeight into account", function() {1533 makeSuiteCt({1534 width: '80%',1535 height: '40%',1536 minHeight: 3001537 });1538 expectSuiteResult(0, 300, 0, 300);1539 });15401541 it("should take maxHeight into account", function() {1542 makeSuiteCt({1543 width: '80%',1544 height: '40%',1545 maxHeight: 501546 });1547 expectSuiteResult(0, 0, 0, 0);1548 });15491550 it("should take minWidth into account", function() {1551 makeSuiteCt({1552 width: '80%',1553 height: '40%',1554 minWidth: 3501555 });1556 expectSuiteResult(350, 0, 350, 0);1557 });15581559 it("should take maxWidth into account", function() {1560 makeSuiteCt({1561 width: '80%',1562 height: '40%',1563 maxWidth: 1001564 });1565 expectSuiteResult(0, 0, 0, 0);1566 });1567 });1568 });15691570 describe("auto height", function() {1571 it("should center the item", function() {1572 makeSuiteCt({1573 width: '80%',1574 html: makeAutoSizer(null, 100)1575 });1576 expectSuiteResult(0, 100, 0, 100);1577 });15781579 it("should take margins into account", function() {1580 makeSuiteCt({1581 width: '80%',1582 html: makeAutoSizer(null, 100),1583 margin: '20 30'1584 });1585 expectSuiteResult(0, 100, 60, 140);1586 });15871588 describe("constraints", function() {1589 it("should take minHeight into account", function() {1590 makeSuiteCt({1591 width: '80%',1592 html: makeAutoSizer(null, 100),1593 minHeight: 3001594 });1595 expectSuiteResult(0, 300, 0, 300);1596 });15971598 it("should take maxHeight into account", function() {1599 makeSuiteCt({1600 width: '80%',1601 html: makeAutoSizer(null, 350),1602 maxHeight: 3001603 });1604 expectSuiteResult(0, 300, 0, 300);1605 });16061607 it("should take minWidth into account", function() {1608 makeSuiteCt({1609 width: '80%',1610 html: makeAutoSizer(null, 100),1611 minWidth: 3501612 });1613 expectSuiteResult(350, 100, 350, 100);1614 });16151616 it("should take maxWidth into account", function() {1617 makeSuiteCt({1618 width: '80%',1619 html: makeAutoSizer(null, 100),1620 maxWidth: 1001621 });1622 expectSuiteResult(0, 100, 0, 100);1623 });1624 });1625 });1626 });16271628 describe("component: auto width", function() {1629 describe("fixed height", function() {1630 it("should center the item", function() {1631 makeSuiteCt({1632 html: makeAutoSizer(200),1633 height: 2001634 });1635 expectSuiteResult(200, 200, 200, 200);1636 });16371638 it("should take margins into account", function() {1639 makeSuiteCt({1640 html: makeAutoSizer(200),1641 height: 200,1642 margin: '20 30'1643 });1644 expectSuiteResult(200, 200, 260, 240);1645 });16461647 describe("constraints", function() {1648 it("should take minWidth into account", function() {1649 makeSuiteCt({1650 html: makeAutoSizer(200),1651 height: 200,1652 minWidth: 3001653 });1654 expectSuiteResult(300, 200, 300, 200);1655 });16561657 it("should take maxWidth into account", function() {1658 makeSuiteCt({1659 html: makeAutoSizer(200),1660 height: 200,1661 maxWidth: 1001662 });1663 expectSuiteResult(100, 200, 100, 200);1664 });1665 });1666 });16671668 describe("calculated height", function() {1669 it("should center the item", function() {1670 makeSuiteCt({1671 html: makeAutoSizer(200),1672 height: '40%'1673 });1674 expectSuiteResult(200, 0, 200, 0);1675 });16761677 it("should take margins into account", function() {1678 makeSuiteCt({1679 html: makeAutoSizer(200),1680 height: '40%',1681 margin: '20 30'1682 });1683 expectSuiteResult(200, 0, 260, 40);1684 });16851686 describe("constraints", function() {1687 it("should take minHeight into account", function() {1688 makeSuiteCt({1689 html: makeAutoSizer(200),1690 height: '40%',1691 minHeight: 3001692 });1693 expectSuiteResult(200, 300, 200, 300);1694 });16951696 it("should take maxHeight into account", function() {1697 makeSuiteCt({1698 html: makeAutoSizer(200),1699 height: '40%',1700 maxHeight: 501701 });1702 expectSuiteResult(200, 0, 200, 0);1703 });17041705 it("should take minWidth into account", function() {1706 makeSuiteCt({1707 html: makeAutoSizer(200),1708 height: '40%',1709 minWidth: 3001710 });1711 expectSuiteResult(300, 0, 300, 0);1712 });17131714 it("should take maxWidth into account", function() {1715 makeSuiteCt({1716 html: makeAutoSizer(200),1717 height: '40%',1718 maxWidth: 1001719 });1720 expectSuiteResult(100, 0, 100, 0);1721 });1722 });1723 });17241725 describe("auto height", function() {1726 it("should center the item", function() {1727 makeSuiteCt({1728 html: makeAutoSizer(200, 100)1729 });1730 expectSuiteResult(200, 100, 200, 100);1731 });17321733 it("should take margins into account", function() {1734 makeSuiteCt({1735 html: makeAutoSizer(200, 100),1736 margin: '20 30'1737 });1738 expectSuiteResult(200, 100, 260, 140);1739 });17401741 describe("constraints", function() {1742 it("should take minHeight into account", function() {1743 makeSuiteCt({1744 html: makeAutoSizer(200, 100),1745 minHeight: 3001746 });1747 expectSuiteResult(200, 300, 200, 300);1748 });17491750 it("should take maxHeight into account", function() {1751 makeSuiteCt({1752 html: makeAutoSizer(200, 100),1753 maxHeight: 501754 });1755 expectSuiteResult(200, 50, 200, 50);1756 });17571758 it("should take minWidth into account", function() {1759 makeSuiteCt({1760 html: makeAutoSizer(200, 100),1761 minWidth: 3001762 });1763 expectSuiteResult(300, 100, 300, 100);1764 });17651766 it("should take maxWidth into account", function() {1767 makeSuiteCt({1768 html: makeAutoSizer(200, 100),1769 maxWidth: 1001770 });1771 expectSuiteResult(100, 100, 100, 100);1772 });1773 });1774 });1775 });1776 });1777 ...

Full Screen

Full Screen

testcase_grid.js

Source:testcase_grid.js Github

copy

Full Screen

...18 // use jquery's API to add and remove class property19 $('#testCase-grid .selectedCase').removeClass('selectedCase');20 $('#testCase-grid .selectedSuite').removeClass('selectedSuite');21}22function setSelectedSuite(id) {23 saveOldCase();24 cleanSelected();25 $("#" + id).addClass('selectedSuite');26 clean_panel();27}28function setSelectedCase(id) {29 saveOldCase();30 var suite_id = document.getElementById(id).parentNode.id;31 setSelectedSuite(suite_id);32 $("#" + id).addClass('selectedCase');33 clean_panel();34 document.getElementById("records-grid").innerHTML = escapeHTML(sideex_testCase[id].records);35 attachEvent(1, getRecordsNum());36}37function getSelectedSuite() {38 if (document.getElementById("testCase-grid").getElementsByClassName("selectedSuite")) {39 return document.getElementById("testCase-grid").getElementsByClassName("selectedSuite")[0];40 } else {41 return null;42 }43}44function getSelectedCase() {45 if (document.getElementById("testCase-grid").getElementsByClassName("selectedCase")) {46 return document.getElementById("testCase-grid").getElementsByClassName("selectedCase")[0];47 } else {48 return null;49 }50}51function getSuiteNum() {52 return document.getElementById("testCase-grid").getElementsByTagName("DIV").length;53}54function getCaseNumInSuite() {55 let selectedSuite = getSelectedSuite();56 if (selectedSuite != null) {57 return selectedSuite.getElementsByTagName("P").length;58 }59 return 0;60}61function saveOldCase() {62 var old_case = getSelectedCase();63 if (old_case) {64 sideex_testCase[old_case.id].records = document.getElementById("records-grid").innerHTML;65 }66}67function appendContextMenu(node, isCase) {68 var ul = document.createElement("ul");69 var a;70 if (isCase) {71 var add_case = document.createElement("li");72 a = document.createElement("a");73 a.setAttribute("href", "#");74 a.textContent = "Add New Test Case";75 add_case.appendChild(a);76 add_case.addEventListener("click", function(event) {77 event.stopPropagation();78 document.getElementById('add-testCase').click();79 }, false);80 ul.appendChild(add_case);81 var remove_case = document.createElement("li");82 a = document.createElement("a");83 a.setAttribute("href", "#");84 a.textContent = "Remove Test Case";85 remove_case.appendChild(a);86 remove_case.addEventListener("click", function(event) {87 event.stopPropagation();88 document.getElementById('delete-testCase').click();89 }, false);90 ul.appendChild(remove_case);91 var rename_case = document.createElement("li");92 a = document.createElement("a");93 a.setAttribute("href", "#");94 a.textContent = "Rename Test Case";95 rename_case.appendChild(a);96 rename_case.addEventListener("click", function(event) {97 event.stopPropagation();98 var s_case = getSelectedCase();99 var n_title = prompt("Please enter the Test Case's name", sideex_testCase[s_case.id].title);100 if (n_title) {101 // get text node102 s_case.childNodes[0].textContent = n_title;103 sideex_testCase[s_case.id].title = n_title;104 }105 }, false);106 ul.appendChild(rename_case);107 } else {108 var open_suite = document.createElement("li");109 a = document.createElement("a");110 a.setAttribute("href", "#");111 a.textContent = "Open Test Suites";112 open_suite.appendChild(a);113 open_suite.addEventListener("click", function(event) {114 event.stopPropagation();115 document.getElementById('load-testSuite-hidden').click();116 }, false);117 ul.appendChild(open_suite);118 var add_suite = document.createElement("li");119 a = document.createElement("a");120 a.setAttribute("href", "#");121 a.textContent = "Add New Test Suite";122 add_suite.appendChild(a);123 add_suite.addEventListener("click", function(event) {124 event.stopPropagation();125 document.getElementById("add-testSuite").click();126 }, false);127 ul.appendChild(add_suite);128 var save_suite = document.createElement("li");129 a = document.createElement("a");130 a.setAttribute("href", "#");131 a.textContent = "Save Test Suite As...";132 save_suite.appendChild(a);133 save_suite.addEventListener("click", function(event) {134 event.stopPropagation();135 document.getElementById('save-testSuite').click();136 }, false);137 ul.appendChild(save_suite);138 var close_suite = document.createElement("li");139 a = document.createElement("a");140 a.setAttribute("href", "#");141 a.textContent = "Close Test Suite";142 close_suite.appendChild(a);143 close_suite.addEventListener("click", function(event) {144 event.stopPropagation();145 document.getElementById('close-testSuite').click();146 }, false);147 ul.appendChild(close_suite);148 var add_case = document.createElement("li");149 a = document.createElement("a");150 a.setAttribute("href", "#");151 a.textContent = "Add New Test Case";152 add_case.appendChild(a);153 add_case.addEventListener("click", function(event) {154 event.stopPropagation();155 document.getElementById('add-testCase').click();156 }, false);157 ul.appendChild(add_case);158 var rename_suite = document.createElement("li");159 a = document.createElement("a");160 a.setAttribute("href", "#");161 a.textContent = "Rename Test Suite";162 rename_suite.appendChild(a);163 rename_suite.addEventListener("click", function(event) {164 event.stopPropagation();165 var s_suite = getSelectedSuite();166 var n_title = prompt("Please enter the Test Suite's name", sideex_testSuite[s_suite.id].title);167 if (n_title) {168 // get text node169 s_suite.getElementsByTagName("STRONG")[0].textContent = n_title;170 sideex_testSuite[s_suite.id].title = n_title;171 sideex_testSuite[s_suite.id].file_name = n_title + ".html";172 $(s_suite).find("strong").addClass("modified");173 closeConfirm(true);174 }175 }, false);176 ul.appendChild(rename_suite);177 }178 node.appendChild(ul);179}180function addTestCase(title, id) {181 if (!getSelectedSuite()) {182 var suite_id = "suite" + sideex_testSuite.count;183 sideex_testSuite.count++;184 sideex_testSuite[suite_id] = {185 file_name: "Untitled Test Suite.html",186 title: "Untitled Test Suite"187 };188 addTestSuite("Untitled Test Suite", suite_id);189 }190 var p = document.createElement("p");191 p.textContent = title;192 p.setAttribute("id", id);193 p.setAttribute("contextmenu", "menu" + id);194 var s_case = getSelectedCase();195 if (s_case) {196 s_case.parentNode.insertBefore(p, s_case.nextSibling);197 } else {198 getSelectedSuite().appendChild(p);199 }200 cleanSelected();201 p.classList.add("selectedCase");202 p.classList.add("test-case-title");203 p.parentNode.classList.add("selectedSuite");204 if (sideex_testCase[id]) { // load file205 clean_panel();206 document.getElementById("records-grid").innerHTML = escapeHTML(sideex_testCase[id].records);207 if (getRecordsNum() !== '0') {208 reAssignId("records-1", "records-" + getRecordsNum());209 attachEvent(1, getRecordsNum());210 }211 } else { // add new testCase212 clean_panel();213 document.getElementById("records-grid").innerHTML = escapeHTML('<input id="records-count" type=hidden value=0></input>');214 sideex_testCase[id] = {215 records: "",216 title: title217 };218 p.classList.add("modified");219 p.parentNode.getElementsByTagName("strong")[0].classList.add("modified");220 }221 // attach event222 p.addEventListener("click", function(event) {223 event.stopPropagation();224 saveOldCase();225 // use jquery's API to add and remove class property226 cleanSelected();227 this.classList.add("selectedCase");228 this.parentNode.classList.add("selectedSuite");229 if (sideex_testCase[this.id].records) {230 clean_panel();231 document.getElementById("records-grid").innerHTML = escapeHTML(sideex_testCase[this.id].records);232 if (getRecordsNum() !== '0') {233 reAssignId("records-1", "records-" + getRecordsNum());234 attachEvent(1, getRecordsNum());235 }236 } else {237 clean_panel();238 document.getElementById("records-grid").innerHTML = escapeHTML('<input id="records-count" type=hidden value=0></input>');239 }240 // prevent event trigger on parent from child241 event.stopPropagation();242 }, false);243 var menu = document.createElement("div");244 menu.setAttribute("class", "menu");245 menu.setAttribute("id", "menu" + id);246 appendContextMenu(menu, true);247 p.appendChild(menu);248 // right click249 p.addEventListener("contextmenu", function(event) {250 event.preventDefault();251 event.stopPropagation();252 saveOldCase();253 setSelectedCase(this.id);254 var mid = "#" + "menu" + id;255 $(".menu").css("left", event.pageX);256 $(".menu").css("top", event.pageY);257 $(mid).show();258 }, false);259 closeConfirm(true);260 261 // enable play button262 enableButton("playback");263}264function addTestSuite(title, id) {265 // set test suite title div266 var textDiv = document.createElement("div");267 textDiv.classList.add("test-suite-title");268 // add save icon269 var saveIcon = document.createElement("i");270 saveIcon.classList.add("fa");271 saveIcon.classList.add("fa-download");272 saveIcon.setAttribute("aria-hidden", "true");273 saveIcon.addEventListener("click", clickSaveIcon);274 textDiv.appendChild(saveIcon);275 // set test suite title276 var text = document.createElement("strong");277 text.classList.add("test-suite-title");278 text.innerHTML = escapeHTML(title);279 textDiv.appendChild(text);280 // add plus icon281 var plusIcon = document.createElement("i");282 plusIcon.classList.add("fa");283 plusIcon.classList.add("fa-plus");284 plusIcon.classList.add("case-plus");285 plusIcon.setAttribute("aria-hidden", "true");286 plusIcon.addEventListener("click", clickCasePlusIcon);287 textDiv.appendChild(plusIcon);288 // set test suite div289 var div = document.createElement("div");290 div.setAttribute("id", id);291 div.setAttribute("contextmenu", "menu" + id);292 div.setAttribute("class", "message");293 div.addEventListener("mouseover", mouseOnAndOutTestSuite);294 div.addEventListener("mouseout", mouseOnAndOutTestSuite);295 div.appendChild(textDiv);296 var s_suite = getSelectedSuite();297 if (s_suite) {298 s_suite.parentNode.insertBefore(div, s_suite.nextSibling);299 } else {300 document.getElementById("testCase-grid").appendChild(div);301 }302 cleanSelected();303 div.classList.add("selectedSuite");304 // attach event305 div.addEventListener("click", function(event) {306 if (this.getElementsByTagName("p").length != 0) {307 this.getElementsByTagName("p")[0].click();308 } else {309 event.stopPropagation();310 saveOldCase();311 cleanSelected();312 this.classList.add("selectedSuite");313 clean_panel();314 }315 }, false);316 var menu = document.createElement("div");317 menu.setAttribute("class", "menu");318 menu.setAttribute("id", "menu" + id);319 appendContextMenu(menu, false);320 div.appendChild(menu);321 // right click322 div.addEventListener("contextmenu", function(event) {323 event.preventDefault();324 event.stopPropagation();325 saveOldCase();326 setSelectedSuite(this.id);327 var mid = "#" + "menu" + id;328 $(".menu").css("left", event.pageX);329 $(".menu").css("top", event.pageY);330 $(mid).show();331 }, false);332 makeCaseSortable(div);333 // enable play button334 enableButton("playSuites");335 enableButton("playSuite");336}337function modifyCaseSuite() {338 getSelectedCase().classList.add("modified");339 getSelectedSuite().getElementsByTagName("strong")[0].classList.add("modified");340}341document.getElementById("add-testSuite").addEventListener("click", function(event) {342 event.stopPropagation();343 var title = prompt("Please enter the Test Suite's name", "Untitled Test Suite");344 if (title) {345 var id = "suite" + sideex_testSuite.count;346 sideex_testSuite.count++;347 sideex_testSuite[id] = {348 file_name: title + ".html",349 title: title350 };351 addTestSuite(title, id);352 }353}, false);354document.getElementById("add-testSuite-menu").addEventListener("click", function(event) {355 event.stopPropagation();356 document.getElementById('add-testSuite').click();357}, false);358var confirmCloseSuite = function(question) {359 var defer = $.Deferred();360 $('<div></div>')361 .html(question)362 .dialog({363 title: "Save?",364 resizable: false,365 height: "auto",366 width: 400,367 modal: true,368 buttons: {369 "Yes": function() {370 defer.resolve("true");371 $(this).dialog("close");372 },373 "No": function() {374 defer.resolve("false");375 $(this).dialog("close");376 },377 Cancel: function() {378 $(this).dialog("close");379 }380 },381 close: function() {382 $(this).remove();383 }384 });385 return defer.promise();386};387var remove_testSuite = function() {388 var s_suite = getSelectedSuite();389 sideex_testSuite[s_suite.id] = null;390 s_suite.parentNode.removeChild(s_suite);391 clean_panel();392};393document.getElementById("close-testSuite").addEventListener('click', function(event) {394 event.stopPropagation();395 var s_suite = getSelectedSuite();396 if (s_suite) {397 if ($(s_suite).find(".modified").length) {398 confirmCloseSuite("Would you like to save this test suite?").then(function(answer) {399 if (answer === "true")400 downloadSuite(s_suite, remove_testSuite);401 else402 remove_testSuite(s_suite);403 // disable play button when there is no suite404 if (getSuiteNum() == 0) {405 disableButton("playback");406 disableButton("playSuite");407 disableButton("playSuites");408 }409 });410 } else {411 remove_testSuite(s_suite);412 // disable play button when there is no suite413 if (getSuiteNum() == 0) {414 disableButton("playback");415 disableButton("playSuite");416 disableButton("playSuites");417 } 418 }419 }420}, false);421document.getElementById("add-testCase").addEventListener("click", function(event) {422 var title = prompt("Please enter the Test Case's name", "Untitled Test Case");423 if (title) {424 var id = "case" + sideex_testCase.count;425 sideex_testCase.count++;426 addTestCase(title, id);427 }428}, false);429var remove_testCase = function() {430 var s_case = getSelectedCase();431 sideex_testCase[s_case.id] = null;432 s_case.parentNode.removeChild(s_case);433 clean_panel();434};435document.getElementById("delete-testCase").addEventListener('click', function() {436 var s_case = getSelectedCase();437 if (s_case) {438 if ($(s_case).hasClass("modified")) {439 confirmCloseSuite("Would you like to save this test case?").then(function(answer) {440 if (answer === "true")441 downloadSuite(getSelectedSuite(), remove_testCase);442 else443 remove_testCase();444 // disable play button when there is no test case445 if (getCaseNumInSuite() == 0) {446 disableButton("playback");447 }448 });449 } else {450 remove_testCase();451 // disable play button when there is no test case452 if (getCaseNumInSuite() == 0) {453 disableButton("playback");454 }455 }456 }457}, false);458function clickCasePlusIcon(event) {459 event.stopPropagation();460 event.target.parentNode.parentNode.click();461 document.getElementById('add-testCase').click();462}463function clickSaveIcon(event) {464 event.stopPropagation();465 event.target.parentNode.parentNode.click();466 document.getElementById('save-testSuite').click();...

Full Screen

Full Screen

suite.spec.js

Source:suite.spec.js Github

copy

Full Screen

...4 , Test = mocha.Test;5describe('Suite', function(){6 describe('.clone()', function(){7 beforeEach(function(){8 this.suite = new Suite('To be cloned');9 this.suite._timeout = 3043;10 this.suite._slow = 101;11 this.suite._bail = true;12 this.suite.suites.push(1);13 this.suite.tests.push('hello');14 this.suite._beforeEach.push(2);15 this.suite._beforeAll.push(3);16 this.suite._afterEach.push(4);17 this.suite._afterAll.push(5);18 });19 it('should copy the title', function(){20 this.suite.clone().title.should.equal('To be cloned');21 });22 it('should copy the timeout value', function(){23 this.suite.clone().timeout().should.equal(3043);24 });25 it('should copy the slow value', function(){26 this.suite.clone().slow().should.equal(101);27 });28 it('should copy the bail value', function(){29 this.suite.clone().bail().should.be.true();30 });31 it('should not copy the values from the suites array', function(){32 this.suite.clone().suites.should.be.empty();33 });34 it('should not copy the values from the tests array', function(){35 this.suite.clone().tests.should.be.empty();36 });37 it('should not copy the values from the _beforeEach array', function(){38 this.suite.clone()._beforeEach.should.be.empty();39 });40 it('should not copy the values from the _beforeAll array', function(){41 this.suite.clone()._beforeAll.should.be.empty();42 });43 it('should not copy the values from the _afterEach array', function(){44 this.suite.clone()._afterEach.should.be.empty();45 });46 it('should not copy the values from the _afterAll array', function(){47 this.suite.clone()._afterAll.should.be.empty();48 });49 });50 describe('.timeout()', function(){51 beforeEach(function(){52 this.suite = new Suite('A Suite');53 });54 describe('when no argument is passed', function(){55 it('should return the timeout value', function(){56 this.suite.timeout().should.equal(2000);57 });58 });59 describe('when argument is passed', function(){60 it('should return the Suite object', function(){61 var newSuite = this.suite.timeout(5000);62 newSuite.timeout().should.equal(5000);63 });64 });65 });66 describe('.slow()', function(){67 beforeEach(function(){68 this.suite = new Suite('A Suite');69 });70 describe('when given a string', function(){71 it('should parse it', function(){72 this.suite.slow('5 seconds');73 this.suite.slow().should.equal(5000);74 })75 })76 describe('when no argument is passed', function(){77 it('should return the slow value', function(){78 this.suite.slow().should.equal(75);79 });80 });81 describe('when argument is passed', function(){82 it('should return the Suite object', function(){83 var newSuite = this.suite.slow(5000);84 newSuite.slow().should.equal(5000);85 });86 });87 });88 describe('.bail()', function(){89 beforeEach(function(){90 this.suite = new Suite('A Suite');91 this.suite._bail = true92 });93 describe('when no argument is passed', function(){94 it('should return the bail value', function(){95 this.suite.bail().should.be.true();96 });97 });98 describe('when argument is passed', function(){99 it('should return the Suite object', function(){100 var newSuite = this.suite.bail(false);101 newSuite.bail().should.be.false();102 });103 });104 });105 describe('.beforeAll()', function(){106 beforeEach(function(){107 this.suite = new Suite('A Suite');108 });109 describe('wraps the passed in function in a Hook', function(){110 it('adds it to _beforeAll', function(){111 var fn = function(){};112 this.suite.beforeAll(fn);113 this.suite._beforeAll.should.have.length(1);114 var beforeAllItem = this.suite._beforeAll[0];115 beforeAllItem.title.should.match(/^"before all" hook/);116 beforeAllItem.fn.should.equal(fn);117 });118 it('appends title to hook', function(){119 var fn = function(){};120 this.suite.beforeAll('test', fn);121 this.suite._beforeAll.should.have.length(1);122 var beforeAllItem = this.suite._beforeAll[0];123 beforeAllItem.title.should.equal('"before all" hook: test');124 beforeAllItem.fn.should.equal(fn);125 function namedFn(){}126 this.suite.beforeAll(namedFn);127 this.suite._beforeAll.should.have.length(2);128 beforeAllItem = this.suite._beforeAll[1];129 beforeAllItem.title.should.equal('"before all" hook: namedFn');130 beforeAllItem.fn.should.equal(namedFn);131 });132 });133 });134 describe('.afterAll()', function(){135 beforeEach(function(){136 this.suite = new Suite('A Suite');137 });138 describe('wraps the passed in function in a Hook', function(){139 it('adds it to _afterAll', function(){140 var fn = function(){};141 this.suite.afterAll(fn);142 this.suite._afterAll.should.have.length(1);143 var afterAllItem = this.suite._afterAll[0];144 afterAllItem.title.should.match(/^"after all" hook/);145 afterAllItem.fn.should.equal(fn);146 });147 it('appends title to hook', function(){148 var fn = function(){};149 this.suite.afterAll('test', fn);150 this.suite._afterAll.should.have.length(1);151 var beforeAllItem = this.suite._afterAll[0];152 beforeAllItem.title.should.equal('"after all" hook: test');153 beforeAllItem.fn.should.equal(fn);154 function namedFn(){}155 this.suite.afterAll(namedFn);156 this.suite._afterAll.should.have.length(2);157 beforeAllItem = this.suite._afterAll[1];158 beforeAllItem.title.should.equal('"after all" hook: namedFn');159 beforeAllItem.fn.should.equal(namedFn);160 });161 });162 });163 describe('.beforeEach()', function(){164 beforeEach(function(){165 this.suite = new Suite('A Suite');166 });167 describe('wraps the passed in function in a Hook', function(){168 it('adds it to _beforeEach', function(){169 var fn = function(){};170 this.suite.beforeEach(fn);171 this.suite._beforeEach.should.have.length(1);172 var beforeEachItem = this.suite._beforeEach[0];173 beforeEachItem.title.should.match(/^"before each" hook/);174 beforeEachItem.fn.should.equal(fn);175 });176 it('appends title to hook', function(){177 var fn = function(){};178 this.suite.beforeEach('test', fn);179 this.suite._beforeEach.should.have.length(1);180 var beforeAllItem = this.suite._beforeEach[0];181 beforeAllItem.title.should.equal('"before each" hook: test');182 beforeAllItem.fn.should.equal(fn);183 function namedFn(){}184 this.suite.beforeEach(namedFn);185 this.suite._beforeEach.should.have.length(2);186 beforeAllItem = this.suite._beforeEach[1];187 beforeAllItem.title.should.equal('"before each" hook: namedFn');188 beforeAllItem.fn.should.equal(namedFn);189 });190 });191 });192 describe('.afterEach()', function(){193 beforeEach(function(){194 this.suite = new Suite('A Suite');195 });196 describe('wraps the passed in function in a Hook', function(){197 it('adds it to _afterEach', function(){198 var fn = function(){};199 this.suite.afterEach(fn);200 this.suite._afterEach.should.have.length(1);201 var afterEachItem = this.suite._afterEach[0];202 afterEachItem.title.should.match(/^"after each" hook/);203 afterEachItem.fn.should.equal(fn);204 });205 it('appends title to hook', function(){206 var fn = function(){};207 this.suite.afterEach('test', fn);208 this.suite._afterEach.should.have.length(1);209 var beforeAllItem = this.suite._afterEach[0];210 beforeAllItem.title.should.equal('"after each" hook: test');211 beforeAllItem.fn.should.equal(fn);212 function namedFn(){}213 this.suite.afterEach(namedFn);214 this.suite._afterEach.should.have.length(2);215 beforeAllItem = this.suite._afterEach[1];216 beforeAllItem.title.should.equal('"after each" hook: namedFn');217 beforeAllItem.fn.should.equal(namedFn);218 });219 });220 });221 describe('.addSuite()', function(){222 beforeEach(function(){223 this.first = new Suite('First suite');224 this.first.timeout(4002);225 this.first.slow(200);226 this.second = new Suite('Second suite');227 this.first.addSuite(this.second);228 });229 it('sets the parent on the added Suite', function(){230 this.second.parent.should.equal(this.first);231 });232 it('copies the timeout value', function(){233 this.second.timeout().should.equal(4002);234 });235 it('copies the slow value', function(){236 this.second.slow().should.equal(200);237 });238 it('adds the suite to the suites collection', function(){239 this.first.suites.should.have.length(1);240 this.first.suites[0].should.equal(this.second);241 });242 it('treats suite as pending if its parent is pending', function(){243 this.first.pending = true244 this.second.isPending.should.be.true245 });246 });247 // describe('.addTest()', function(){248 // beforeEach(function(){249 // this.suite = new Suite('A Suite', new Context);250 // this.suite.timeout(4002);251 // this.test = new Test('test');252 // this.suite.addTest(this.test);253 // });254 //255 // it('sets the parent on the added test', function(){256 // this.test.parent.should.equal(this.suite);257 // });258 //259 // it('copies the timeout value', function(){260 // this.test.timeout().should.equal(4002);261 // });262 //263 // it('adds the test to the tests collection', function(){264 // this.suite.tests.should.have.length(1);265 // this.suite.tests[0].should.equal(this.test);266 // });267 // });268 describe('.fullTitle()', function(){269 beforeEach(function(){270 this.suite = new Suite('A Suite');271 });272 describe('when there is no parent', function(){273 it('returns the suite title', function(){274 this.suite.fullTitle().should.equal('A Suite');275 });276 });277 describe('when there is a parent', function(){278 it('returns the combination of parent\'s and suite\'s title', function(){279 var parentSuite = new Suite('I am a parent');280 parentSuite.addSuite(this.suite);281 this.suite.fullTitle().should.equal('I am a parent A Suite');282 });283 });284 });285 describe('.total()', function(){286 beforeEach(function(){287 this.suite = new Suite('A Suite');288 });289 describe('when there are no nested suites or tests', function(){290 it('should return 0', function(){291 this.suite.total().should.equal(0);292 });293 });294 describe('when there are several tests in the suite', function(){295 it('should return the number', function(){296 this.suite.addTest(new Test('a child test'));297 this.suite.addTest(new Test('another child test'));298 this.suite.total().should.equal(2);299 });300 });301 });302 describe('.eachTest(fn)', function(){303 beforeEach(function(){304 this.suite = new Suite('A Suite');305 });306 describe('when there are no nested suites or tests', function(){307 it('should return 0', function(){308 var n = 0;309 function fn(){ n++; }310 this.suite.eachTest(fn);311 n.should.equal(0);312 });313 });314 describe('when there are several tests in the suite', function(){315 it('should return the number', function(){316 this.suite.addTest(new Test('a child test'));317 this.suite.addTest(new Test('another child test'));318 var n = 0;319 function fn(){ n++; }320 this.suite.eachTest(fn);321 n.should.equal(2);322 });323 });324 describe('when there are several levels of nested suites', function(){325 it('should return the number', function(){326 this.suite.addTest(new Test('a child test'));327 var suite = new Suite('a child suite');328 suite.addTest(new Test('a test in a child suite'));329 this.suite.addSuite(suite);330 var n = 0;331 function fn(){ n++; }332 this.suite.eachTest(fn);333 n.should.equal(2);334 });335 });336 });337 describe('initialization', function() {338 it('should throw an error if the title isn\'t a string', function() {339 (function() {340 new Suite(undefined, 'root');341 }).should.throw();342 (function() {343 new Suite(function(){}, 'root');344 }).should.throw();345 });346 it('should not throw if the title is a string', function() {347 (function() {348 new Suite('Bdd suite', 'root');349 }).should.not.throw();350 });351 });352});353describe('Test', function() {354 describe('initialization', function() {355 it('should throw an error if the title isn\'t a string', function() {356 (function() {357 new Test(function(){});358 }).should.throw();359 (function() {360 new Test(undefined, function(){});361 }).should.throw();362 });...

Full Screen

Full Screen

jasmine-jsreporter.js

Source:jasmine-jsreporter.js Github

copy

Full Screen

...199 var JSR = jasmine.JSReporter2.prototype;200 // Reporter API methods201 // --------------------202 JSR.suiteStarted = function (suite) {203 suite = this._cacheSuite(suite);204 // build up suite tree as we go205 suite.specs = [];206 suite.suites = [];207 suite.passed = true;208 suite.parentId = this.suiteStack.slice(this.suiteStack.length -1)[0];209 if (suite.parentId) {210 this.suites[suite.parentId].suites.push(suite);211 } else {212 this.rootSuites.push(suite.id);213 }214 this.suiteStack.push(suite.id);215 suite.timer = new Timer().start();216 };217 JSR.suiteDone = function (suite) {218 suite = this._cacheSuite(suite);219 suite.duration = suite.timer.elapsed();220 suite.durationSec = suite.duration / 1000;221 this.suiteStack.pop();222 // maintain parent suite state223 var parent = this.suites[suite.parentId];224 if (parent) {225 parent.passed = parent.passed && suite.passed;226 }227 // keep report representation clean228 delete suite.timer;229 delete suite.id;230 delete suite.parentId;231 delete suite.fullName;232 };...

Full Screen

Full Screen

suite.js

Source:suite.js Github

copy

Full Screen

...4 , Test = mocha.Test;5describe('Suite', function(){6 describe('.clone()', function(){7 beforeEach(function(){8 this.suite = new Suite('To be cloned');9 this.suite._timeout = 3043;10 this.suite._slow = 101;11 this.suite._bail = true;12 this.suite.suites.push(1);13 this.suite.tests.push('hello');14 this.suite._beforeEach.push(2);15 this.suite._beforeAll.push(3);16 this.suite._afterEach.push(4);17 this.suite._afterAll.push(5);18 });19 it('should copy the title', function(){20 this.suite.clone().title.should.equal('To be cloned');21 });22 it('should copy the timeout value', function(){23 this.suite.clone().timeout().should.equal(3043);24 });25 it('should copy the slow value', function(){26 this.suite.clone().slow().should.equal(101);27 });28 it('should copy the bail value', function(){29 this.suite.clone().bail().should.be.true;30 });31 it('should not copy the values from the suites array', function(){32 this.suite.clone().suites.should.be.empty;33 });34 it('should not copy the values from the tests array', function(){35 this.suite.clone().tests.should.be.empty;36 });37 it('should not copy the values from the _beforeEach array', function(){38 this.suite.clone()._beforeEach.should.be.empty;39 });40 it('should not copy the values from the _beforeAll array', function(){41 this.suite.clone()._beforeAll.should.be.empty;42 });43 it('should not copy the values from the _afterEach array', function(){44 this.suite.clone()._afterEach.should.be.empty;45 });46 it('should not copy the values from the _afterAll array', function(){47 this.suite.clone()._afterAll.should.be.empty;48 });49 });50 describe('.timeout()', function(){51 beforeEach(function(){52 this.suite = new Suite('A Suite');53 });54 describe('when no argument is passed', function(){55 it('should return the timeout value', function(){56 this.suite.timeout().should.equal(2000);57 });58 });59 describe('when argument is passed', function(){60 it('should return the Suite object', function(){61 var newSuite = this.suite.timeout(5000);62 newSuite.timeout().should.equal(5000);63 });64 });65 });66 describe('.slow()', function(){67 beforeEach(function(){68 this.suite = new Suite('A Suite');69 });70 describe('when given a string', function(){71 it('should parse it', function(){72 this.suite.slow('5 seconds');73 this.suite.slow().should.equal(5000);74 })75 })76 describe('when no argument is passed', function(){77 it('should return the slow value', function(){78 this.suite.slow().should.equal(75);79 });80 });81 describe('when argument is passed', function(){82 it('should return the Suite object', function(){83 var newSuite = this.suite.slow(5000);84 newSuite.slow().should.equal(5000);85 });86 });87 });88 describe('.bail()', function(){89 beforeEach(function(){90 this.suite = new Suite('A Suite');91 this.suite._bail = true92 });93 describe('when no argument is passed', function(){94 it('should return the bail value', function(){95 this.suite.bail().should.be.true;96 });97 });98 describe('when argument is passed', function(){99 it('should return the Suite object', function(){100 var newSuite = this.suite.bail(false);101 newSuite.bail().should.be.false;102 });103 });104 });105 describe('.beforeAll()', function(){106 beforeEach(function(){107 this.suite = new Suite('A Suite');108 });109 describe('wraps the passed in function in a Hook', function(){110 it('adds it to _beforeAll', function(){111 function fn(){}112 this.suite.beforeAll(fn);113 this.suite._beforeAll.should.have.length(1);114 var beforeAllItem = this.suite._beforeAll[0];115 beforeAllItem.title.should.equal('"before all" hook');116 beforeAllItem.fn.should.equal(fn);117 });118 });119 });120 describe('.afterAll()', function(){121 beforeEach(function(){122 this.suite = new Suite('A Suite');123 });124 describe('wraps the passed in function in a Hook', function(){125 it('adds it to _afterAll', function(){126 function fn(){}127 this.suite.afterAll(fn);128 this.suite._afterAll.should.have.length(1);129 var afterAllItem = this.suite._afterAll[0];130 afterAllItem.title.should.equal('"after all" hook');131 afterAllItem.fn.should.equal(fn);132 });133 });134 });135 describe('.beforeEach()', function(){136 beforeEach(function(){137 this.suite = new Suite('A Suite');138 });139 describe('wraps the passed in function in a Hook', function(){140 it('adds it to _beforeEach', function(){141 function fn(){}142 this.suite.beforeEach(fn);143 this.suite._beforeEach.should.have.length(1);144 var beforeEachItem = this.suite._beforeEach[0];145 beforeEachItem.title.should.equal('"before each" hook');146 beforeEachItem.fn.should.equal(fn);147 });148 });149 });150 describe('.afterEach()', function(){151 beforeEach(function(){152 this.suite = new Suite('A Suite');153 });154 describe('wraps the passed in function in a Hook', function(){155 it('adds it to _afterEach', function(){156 function fn(){}157 this.suite.afterEach(fn);158 this.suite._afterEach.should.have.length(1);159 var afterEachItem = this.suite._afterEach[0];160 afterEachItem.title.should.equal('"after each" hook');161 afterEachItem.fn.should.equal(fn);162 });163 });164 });165 describe('.addSuite()', function(){166 beforeEach(function(){167 this.first = new Suite('First suite');168 this.first.timeout(4002);169 this.first.slow(200);170 this.second = new Suite('Second suite');171 this.first.addSuite(this.second);172 });173 it('sets the parent on the added Suite', function(){174 this.second.parent.should.equal(this.first);175 });176 it('copies the timeout value', function(){177 this.second.timeout().should.equal(4002);178 });179 it('copies the slow value', function(){180 this.second.slow().should.equal(200);181 });182 it('adds the suite to the suites collection', function(){183 this.first.suites.should.have.length(1);184 this.first.suites[0].should.equal(this.second);185 });186 });187 // describe('.addTest()', function(){188 // beforeEach(function(){189 // this.suite = new Suite('A Suite', new Context);190 // this.suite.timeout(4002);191 // this.test = new Test('test');192 // this.suite.addTest(this.test);193 // });194 //195 // it('sets the parent on the added test', function(){196 // this.test.parent.should.equal(this.suite);197 // });198 //199 // it('copies the timeout value', function(){200 // this.test.timeout().should.equal(4002);201 // });202 //203 // it('adds the test to the tests collection', function(){204 // this.suite.tests.should.have.length(1);205 // this.suite.tests[0].should.equal(this.test);206 // });207 // });208 describe('.fullTitle()', function(){209 beforeEach(function(){210 this.suite = new Suite('A Suite');211 });212 describe('when there is no parent', function(){213 it('returns the suite title', function(){214 this.suite.fullTitle().should.equal('A Suite');215 });216 });217 describe('when there is a parent', function(){218 it('returns the combination of parent\'s and suite\'s title', function(){219 var parentSuite = new Suite('I am a parent');220 parentSuite.addSuite(this.suite);221 this.suite.fullTitle().should.equal('I am a parent A Suite');222 });223 });224 });225 describe('.total()', function(){226 beforeEach(function(){227 this.suite = new Suite('A Suite');228 });229 describe('when there are no nested suites or tests', function(){230 it('should return 0', function(){231 this.suite.total().should.equal(0);232 });233 });234 describe('when there are several tests in the suite', function(){235 it('should return the number', function(){236 this.suite.addTest(new Test('a child test'));237 this.suite.addTest(new Test('another child test'));238 this.suite.total().should.equal(2);239 });240 });241 });242 describe('.eachTest(fn)', function(){243 beforeEach(function(){244 this.suite = new Suite('A Suite');245 });246 describe('when there are no nested suites or tests', function(){247 it('should return 0', function(){248 var n = 0;249 function fn(){ n++; }250 this.suite.eachTest(fn);251 n.should.equal(0);252 });253 });254 describe('when there are several tests in the suite', function(){255 it('should return the number', function(){256 this.suite.addTest(new Test('a child test'));257 this.suite.addTest(new Test('another child test'));258 var n = 0;259 function fn(){ n++; }260 this.suite.eachTest(fn);261 n.should.equal(2);262 });263 });264 describe('when there are several levels of nested suites', function(){265 it('should return the number', function(){266 this.suite.addTest(new Test('a child test'));267 var suite = new Suite('a child suite');268 suite.addTest(new Test('a test in a child suite'));269 this.suite.addSuite(suite);270 var n = 0;271 function fn(){ n++; }272 this.suite.eachTest(fn);273 n.should.equal(2);274 });275 });276 });...

Full Screen

Full Screen

AllTests.js

Source:AllTests.js Github

copy

Full Screen

...74system.AllTests.suite = function() 75{76 var TestSuite = buRRRn.ASTUce.TestSuite;77 78 var suite = new TestSuite( "system unit tests" );79 80 suite.addTest( new TestSuite( system.CloneableTest ) );81 suite.addTest( new TestSuite( system.ComparableTest ) );82 suite.addTest( new TestSuite( system.ComparatorTest ) );83 suite.addTest( new TestSuite( system.EnumTest ) );84 suite.addTest( new TestSuite( system.EquatableTest ) );85 suite.addTest( new TestSuite( system.SerializableTest ) );86 suite.addTest( new TestSuite( system.SerializerTest ) );87 suite.addTest( new TestSuite( system.SortableTest ) );88 89 suite.addTest( system.data.AllTests.suite() );90 suite.addTest( system.errors.AllTests.suite() );91 suite.addTest( system.evaluators.AllTests.suite() );92 suite.addTest( system.events.AllTests.suite() );93 suite.addTest( system.formatters.AllTests.suite() );94 suite.addTest( system.ioc.AllTests.suite() );95 suite.addTest( system.logging.AllTests.suite() );96 suite.addTest( system.numeric.AllTests.suite() );97 suite.addTest( system.process.AllTests.suite() );98 suite.addTest( system.signals.AllTests.suite() );99 100 return suite;101}

Full Screen

Full Screen

benchmark.js

Source:benchmark.js Github

copy

Full Screen

...8BenchClass.prototype.isTHREELoaded = function() {9 return _.isObject(this.THREE);10}11BenchClass.prototype.newSuite = function(name) {12 var s = new Benchmark.Suite(name);13 this.suites.push(s);14 return s;15}16BenchClass.prototype.display = function() {17 for (x of this.suites) {18 var s = new SuiteUI(x);19 s.render();20 }21}22BenchClass.prototype.warning = function(message) {23 console.error(message);24}25var SuiteUI = function(suite) {26 this.suite = suite;...

Full Screen

Full Screen

mochaTreeUtil.js

Source:mochaTreeUtil.js Github

copy

Full Screen

...60/**61 * @param {Object} suite mocha suite62 * @returns {TestSuiteNode}63 */64function getNodeForSuite(suite) {65 if (hasOwnProperty.call(suite, INTELLIJ_SUITE_NODE)) {66 return suite[INTELLIJ_SUITE_NODE];67 }68 return null;69}70/**71 * @param {Object} suite mocha suite72 * @param {TestSuiteNode} suiteNode73 */74function setNodeForSuite(suite, suiteNode) {75 suite[INTELLIJ_SUITE_NODE] = suiteNode;76}77module.exports.forEachTest = forEachTest;78module.exports.finishTree = finishTree;79module.exports.getNodeForTest = getNodeForTest;80module.exports.setNodeForTest = setNodeForTest;81module.exports.getNodeForSuite = getNodeForSuite;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const assert = require("chai").assert;2const app = require("../app");3sayHelloResult = app.sayHello();4addNumbersResult = app.addNumbers(5, 5);5describe("App", function() {6 describe("sayHello()", function() {7 it("sayHello should return hello", function() {8 assert.equal(sayHelloResult, "hello");9 });10 it("sayHello should return type string", function() {11 assert.typeOf(sayHelloResult, "string");12 });13 });14 describe("addNumbers()", function() {15 it("addNumbers should be above 5", function() {16 assert.isAbove(addNumbersResult, 5);17 });18 it("addNumbers should return type number", function() {19 assert.typeOf(addNumbersResult, "number");20 });21 });22});23const sayHello = function() {24 return "hello";25};26const addNumbers = function(value1, value2) {27 return value1 + value2;28};29module.exports = {30};31{32 "scripts": {33 },34 "devDependencies": {35 }36}37const assert = require("chai").assert;38const app = require("../app");39sayHelloResult = app.sayHello();40addNumbersResult = app.addNumbers(5, 5);41describe("App", function() {42 describe("sayHello()", function() {43 it("sayHello should return hello", function() {44 assert.equal(sayHelloResult, "hello");45 });46 it("sayHello

Full Screen

Using AI Code Generation

copy

Full Screen

1var assert = require('assert');2var expect = require('chai').expect;3var should = require('chai').should();4var request = require('supertest');5var chai = require('chai');6var chaiHttp = require('chai-http');7var server = require('../server');8var token = require('../token');9chai.use(chaiHttp);10describe('Test Case for User', function() {11 it("should get all user record", function(done) {12 chai.request(server)13 .get('/user')14 .set('x-access-token', token)15 .end((err, res) => {16 res.should.have.status(200);17 res.body.should.have.property('status');18 res.body.should.have.property('message');19 res.body.should.have.property('data');20 res.body.should.have.property('status').eql('success');21 res.body.should.have.property('message').eql('User data retrieved successfully');22 done();23 });24 });25 it("should get single user record", function(done) {26 chai.request(server)27 .get('/user/1')28 .set('x-access-token', token)29 .end((err, res) => {30 res.should.have.status(200);31 res.body.should.have.property('status');32 res.body.should.have.property('message');33 res.body.should.have.property('data');34 res.body.should.have.property('status').eql('success');35 res.body.should.have.property('message').eql('User data retrieved successfully');36 done();37 });38 });39 it("should not get single user record", function(done) {40 chai.request(server)41 .get('/user/100')42 .set('x-access-token', token)43 .end((err, res) => {44 res.should.have.status(404);45 res.body.should.have.property('status');46 res.body.should.have.property('message');47 res.body.should.have.property('status').eql('error');48 res.body.should.have.property('message').eql('User not found');49 done();50 });51 });52 it("should create user record", function(done) {53 chai.request(server)54 .post('/user')55 .set('x-access-token', token)

Full Screen

Using AI Code Generation

copy

Full Screen

1var assert = require('assert');2suite('Array', function() {3 test('#indexOf() should return -1 when the value is not present', function() {4 assert.equal(-1, [1,2,3].indexOf(5));5 assert.equal(-1, [1,2,3].indexOf(0));6 });7});8suite('Array', function() {9 test('should return -1 when the value is not present', function() {10 assert.equal(-1, [1,2,3].indexOf(5));11 assert.equal(-1, [1,2,3].indexOf(0));12 });13});14suite('Array', function() {15 test('should return -1 when the value is not present', function() {16 assert.equal(-1, [1,2,3].indexOf(5));17 assert.equal(-1, [1,2,3].indexOf(0));18 });19});20suite('Array', function() {21 test('should return -1 when the value is not present', function() {22 assert.equal(-1, [1,2,3].indexOf(5));23 assert.equal(-1, [1,2,3].indexOf(0));24 });25});26suite('Array', function() {27 test('should return -1 when the value is not present', function() {28 assert.equal(-1, [1,2,3].indexOf(5));29 assert.equal(-1, [1,2,3].indexOf(0));30 });31});32suite('Array', function() {33 test('should return -1 when the value is not present', function() {34 assert.equal(-1, [1,2,3].indexOf(5));35 assert.equal(-1, [1,2,3].indexOf(0));36 });37});

Full Screen

Using AI Code Generation

copy

Full Screen

1describe("Mocha", function() {2 it("should run our tests using npm", function() {3 assert.equal(-1, [1,2,3].indexOf(5));4 assert.equal(-1, [1,2,3].indexOf(0));5 });6});7{8 "scripts": {9 },10 "dependencies": {11 }12}13var assert = require('chai').assert;14describe("Mocha", function() {15 it("should run our tests using npm", function() {16 assert.equal(-1, [1,2,3].indexOf(5));17 assert.equal(-1, [1,2,3].indexOf(0));18 });19});20{21 "scripts": {22 },23 "devDependencies": {24 }25}26var assert = require('chai').assert;27describe("Mocha", function() {28 it("should run our tests using npm", function() {29 assert.equal(-1, [1,2,3].indexOf(5));30 assert.equal(-1, [1,2,3].indexOf(0));31 });32});33{34 "scripts": {35 },36 "devDependencies": {37 }38}

Full Screen

Using AI Code Generation

copy

Full Screen

1var assert = require('assert');2var webdriver = require('selenium-webdriver');3var driver = new webdriver.Builder()4 .forBrowser('chrome')5 .build();6driver.findElement(webdriver.By.name('q')).sendKeys('webdriver');7driver.findElement(webdriver.By.name('btnG')).click();8driver.wait(function() {9 return driver.getTitle().then(function(title) {10 return title === 'webdriver - Google Search';11 });12}, 1000);13driver.quit();

Full Screen

Using AI Code Generation

copy

Full Screen

1var assert = require('assert');2var suite = require('mocha').suite;3var test = require('mocha').test;4var chai = require('chai');5var expect = chai.expect;6var should = chai.should();7describe('Mocha', function() {8 describe('Suite', function() {9 it('should be a function', function() {10 assert.equal('function', typeof suite);11 });12 });13});14describe('Chai', function() {15 describe('Should', function() {16 it('should be a function', function() {17 assert.equal('function', typeof should);18 });19 });20});21describe('Chai', function() {22 describe('Expect', function() {23 it('should be a function', function() {24 assert.equal('function', typeof expect);25 });26 });27});28suite('Mocha', function() {29 test('Test', function() {30 assert.equal('function', typeof test);31 });32});33suite('Chai', function() {34 suite('Expect', function() {35 test('Expect', function() {36 assert.equal('function', typeof expect);37 });38 });39});40suite('Chai', function() {41 suite('Should', function() {42 test('Should', function() {43 assert.equal('function', typeof should);44 });45 });46});47suite('Mocha', function() {48 test('Test', function() {49 assert.equal('function', typeof test);50 });51});52suite('Chai', function() {53 suite('Expect', function() {54 test('Expect', function() {55 assert.equal('function', typeof expect);56 });57 });58});59suite('Chai', function() {60 suite('Should', function() {61 test('Should', function() {62 assert.equal('function', typeof should);63 });64 });65});66suite('Mocha', function() {67 test('Test', function() {68 assert.equal('function', typeof test);69 });70});

Full Screen

Using AI Code Generation

copy

Full Screen

1var myApp = require('../app/library.js');2describe("Arithmetic Operations", function() {3 describe("Addition of two numbers", function() {4 it("should return 10 when we add 4 and 6", function() {5 expect(myApp.add(4, 6)).toEqual(10);6 });7 it("should return -2 when we add 4 and -6", function() {8 expect(myApp.add(4, -6)).toEqual(-2);9 });10 it("should return 0 when we add 0 and 0", function() {11 expect(myApp.add(0, 0)).toEqual(0);12 });13 });14});15module.exports = {16 add: function(a, b) {17 return a + b;18 }19};

Full Screen

Using AI Code Generation

copy

Full Screen

1var assert = require('chai').assert;2var utility = require('../utility/utility');3suite('test suite', function() {4 test('test case', function() {5 });6});7var assert = require('chai').assert;8var utility = require('../utility/utility');9suite('test suite', function() {10 test('test case', function() {11 });12});13var assert = require('chai').assert;14var utility = require('../utility/utility');15suite('test suite', function() {16 test('test case', function() {17 });18});19var assert = require('chai').assert;20var utility = require('../utility/utility');21suite('test suite', function() {22 test('test case', function() {23 });24});25var assert = require('chai').assert;26var utility = require('../utility/utility');27suite('test suite', function() {28 test('test case', function() {29 });30});31var assert = require('chai').assert;32var utility = require('../utility/utility');33suite('test suite', function() {34 test('

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