Best JavaScript code snippet using tracetest
PartialActionTest.js
Source:PartialActionTest.js  
...57             return portlet.register(portletA);58          }59          var ph = new portlet.jasmine.PromiseHandler(testFunc);60          runs(ph.getRun());61          waitsFor(ph.getIsComplete(), "The PortletInit object should be returned", 1000);62          runs(ph.getChecker()); 63          runs(function() {64             expect(ph.result).toBeDefined();65          }); 66          runs(function() {67             hubA = ph.result;68          }); 69       });70       71       it('initializes a portlet hub instance for portlet B',function(){72          var testFunc = function () {73             return portlet.register(portletB);74          }75          var ph = new portlet.jasmine.PromiseHandler(testFunc);76          runs(ph.getRun());77          waitsFor(ph.getIsComplete(), "The PortletInit object should be returned", 1000);78          runs(ph.getChecker()); 79          runs(function() {80             expect(ph.result).toBeDefined();81          }); 82          runs(function() {83             hubB = ph.result;84          }); 85       });86   87       it('initializes a portlet hub instance for portlet C',function(){88          var testFunc = function () {89             return portlet.register(portletC);90          }91          var ph = new portlet.jasmine.PromiseHandler(testFunc);92          runs(ph.getRun());93          waitsFor(ph.getIsComplete(), "The PortletInit object should be returned", 1000);94          runs(ph.getChecker()); 95          runs(function() {96             expect(ph.result).toBeDefined();97          }); 98          runs(function() {99             hubC = ph.result;100          }); 101       });102       103       it('initializes a portlet hub instance for portlet D',function(){104          var testFunc = function () {105             return portlet.register(portletD);106          }107          var ph = new portlet.jasmine.PromiseHandler(testFunc);108          runs(ph.getRun());109          waitsFor(ph.getIsComplete(), "The PortletInit object should be returned", 1000);110          runs(ph.getChecker()); 111          runs(function() {112             expect(ph.result).toBeDefined();113          }); 114          runs(function() {115             hubD = ph.result;116          }); 117       });118     119   });120   describe('The portlet hub startPartialAction function: ',function(){121      // The tests in this section use just a single portlet - portletA122      var cbA = new portlet.jasmine.JasminePortletUtils(portletA, pageState);123      // partial action init structure124      var pai = null;125      // add an osc handler for the test126      beforeEach(function () {127         cbA.complete = false;128         runs(function() {129            cbA.oscHandle = hubA.addEventListener("portlet.onStateChange", cbA.getListener());130            cbA.oeHandle = hubA.addEventListener("portlet.onError", cbA.getListener("error"));131         }); 132         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);133         runs(function() {134            cbA.complete = false;    // in prep for the actual test135            cbA.retType = null;136            cbA.retErrorData = null;137         }); 138      });139      // remove the osc handler added during the test140      afterEach(function () {141         if (cbA.oscHandle !== null) {142            hubA.removeEventListener(cbA.oscHandle);143            cbA.oscHandle = null;144            hubA.removeEventListener(cbA.oeHandle);145            cbA.oeHandle = null;146         }147      });148      it('is present in the register return object and is a function',function(){149         expect(typeof hubA.startPartialAction).toEqual('function');150      });151      it('throws a TypeError if too many (>1) arguments are provided',function(){152         var parms  = {ap1 : ["actionVal"]};153         var testFunc = function () {154            pai = hubA.startPartialAction(parms, "parm3");155         };156         expect(testFunc).toThrowCustomException("TypeError");157      });158      it('throws a TypeError if the argument is null',function(){159         var testFunc = function () {160            pai = hubA.startPartialAction(null);161         };162         expect(testFunc).toThrowCustomException("TypeError");163      });164      it('throws a TypeError if action parameters is invalid',function(){165         var parms  = {ap1 : "actionVal"};166         var testFunc = function () {167            pai = hubA.startPartialAction(parms);168         };169         expect(testFunc).toThrowCustomException("TypeError");170      });171      it('throws an NotInitializedException if no onStateChange listener is registered.',function(){172         var parms  = {ap1 : ["actionVal"]};173         runs(function() {174            var testFunc = function () {175               pai = hubB.startPartialAction(parms);176            }177            expect(testFunc).toThrowCustomException("NotInitializedException");178         }); 179         waits(10);  // give it a chance to call its onStateChange180      });181      it('does not throw if the argument is valid',function(){182         var parms  = {ap1 : ["actionVal"]};183         runs(function() {184            var testFunc = function () {185               pai = hubA.startPartialAction(parms);186            };187            expect(testFunc).not.toThrow();188         }); 189         waits(10);  // give it a chance to call its onStateChange190      });191      it('returns an object',function(){192         var parms  = {ap1 : ["actionVal"]};193         var testFunc = function () {194            return hubA.startPartialAction(parms);195         }196         var ph = new portlet.jasmine.PromiseHandler(testFunc, false);197         runs(ph.getRun());198         waitsFor(ph.getIsComplete(), "The promise from startPartialAction is settled.", 1000);199         runs(ph.getChecker()); 200         runs(function() {201            pai = ph.result;202            expect(typeof pai).toEqual('object');203         }); 204      });205      it('return object contains setPageState function',function(){206         expect(typeof pai.setPageState).toEqual('function');207      });208      it('return object setPageState function throws an exception if called without a parameter',function(){209         var testFunc = function () {210            pai.setPageState();211         };212         expect(testFunc).toThrowCustomException("TypeError");213      });214      it('return object setPageState function throws an exception if called with invalid type',function(){215         var testFunc = function () {216            pai.setPageState(89);217         };218         expect(testFunc).toThrowCustomException("TypeError");219      });220      it('onError event is fired if the setPageState function is called with invalid update string',function(){221         runs(function() {222            pai.setPageState("Invalid page state.");223         }); 224         waitsFor(cbA.getIsComplete(), "The onError callback should be called", 100);225         runs(function() {226            expect(cbA.retType).toEqual('portlet.onError');227            expect(cbA.retErrorData).not.toEqual(null);228         }); 229      });230      it('return object setPageState function does not throw if parameter is correct',function(){231         var ustr = portlet.test.data.updateStrings[portletA];232         var testFunc = function () {233            pai.setPageState(ustr);234         };235         expect(testFunc).not.toThrow();236         waits(10);     // give it a chance to call its onStateChange237      }); 238      it('return object setPageState function causes the onStateChange listener to be called and state is as expected',function(){239         var ustr = portlet.test.data.updateStrings[portletA];240         runs(function() {241            pai.setPageState(ustr);242         }); 243         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);244         runs(function() {245            var states = portlet.test.decodeUpdateString(ustr, portletA),246            stateA = hubA.newState(states[portletA]);247            expect(cbA.retRenderState).toEqual(stateA);248         }); 249      });250      it('throws an AccessDeniedException if called twice',function(){251         var parms  = {ap1 : ["actionVal"]}, pai1 = null, pai2 = null;252         var ustr = portlet.test.data.updateStrings[portletA];253         runs(function() {254            var testFunc = function () {255               hubA.startPartialAction(parms).then(function (p) {256                  pai1 = p;257               });258            };259            expect(testFunc).not.toThrow();260         });261         waitsFor(function () {return pai1 !== null;}, "The promise to settle", 100)262         runs(function() {263            var testFunc = function () {264               hubA.startPartialAction(parms).then(function (p) {265                  pai2 = p;266               });267            };268            expect(testFunc).toThrowCustomException("AccessDeniedException");269         }); 270         runs(function() {271            pai1.setPageState(ustr);272         }); 273         waits(10);  // give it a chance to call its onStateChange274      });275   });276   describe('The portlet hub partial action URLs are OK: ',function(){277      // Make sure it works for more than one portlet 278      var cbA = new portlet.jasmine.JasminePortletUtils(portletB, pageState);279      var cbB = new portlet.jasmine.JasminePortletUtils(portletB, pageState);280      var cbC = new portlet.jasmine.JasminePortletUtils(portletC, pageState);281      var cbD = new portlet.jasmine.JasminePortletUtils(portletD, pageState);282      // partial action init structure283      var pai = null;284      // add an osc handler for the test285      beforeEach(function () {286         cbA.complete = false;287         cbB.complete = false;288         cbC.complete = false;289         cbD.complete = false;290         runs(function() {291            cbA.oscHandle = hubA.addEventListener("portlet.onStateChange", cbA.getListener());292            cbB.oscHandle = hubB.addEventListener("portlet.onStateChange", cbB.getListener());293            cbC.oscHandle = hubC.addEventListener("portlet.onStateChange", cbC.getListener());294            cbD.oscHandle = hubD.addEventListener("portlet.onStateChange", cbD.getListener());295         }); 296         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);297         waitsFor(cbB.getIsComplete(), "The onStateChange callback should be called", 100);298         waitsFor(cbC.getIsComplete(), "The onStateChange callback should be called", 100);299         waitsFor(cbD.getIsComplete(), "The onStateChange callback should be called", 100);300         runs(function() {301            cbA.complete = false;    // in prep for the actual test302            cbB.complete = false;    // in prep for the actual test303            cbC.complete = false;    // in prep for the actual test304            cbD.complete = false;    // in prep for the actual test305         }); 306      });307      // remove the osc handler added during the test308      afterEach(function () {309         if (cbA.oscHandle !== null) {310            hubA.removeEventListener(cbA.oscHandle);311            cbA.oscHandle = null;312         }313         if (cbB.oscHandle !== null) {314            hubB.removeEventListener(cbB.oscHandle);315            cbB.oscHandle = null;316         }317         if (cbC.oscHandle !== null) {318            hubC.removeEventListener(cbC.oscHandle);319            cbC.oscHandle = null;320         }321         if (cbD.oscHandle !== null) {322            hubD.removeEventListener(cbD.oscHandle);323            cbD.oscHandle = null;324         }325      });326      it('causes the onStateChange listener to be called and state is as expected',function(){327         var parms  = {ap1 : ["actionVal"]}, str, states, stateA;328         var ustr = portlet.test.data.updateStrings[portletA];329         runs(function() {330            pai = null;331            hubA.startPartialAction(parms).then(function (p) {332               pai = p;333            });334         }); 335         waitsFor(function () {return pai !== null;}, "The promise to settle", 100)336         runs(function() {337            pai.setPageState(ustr);338         }); 339         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);340         runs(function() {341            str = portlet.test.data.updateStrings[portletA];342            states = portlet.test.decodeUpdateString(str, portletA);343            stateA = hubA.newState(states[portletA]);344            expect(cbA.retRenderState).toEqual(stateA);345         }); 346      });347      it('return object setPageState URL indicates the initiating portlet A',function(){348         var parms  = {ap1 : ["actionVal"], ap2 : ["actionVal2"]}, id;349         var ustr = portlet.test.data.updateStrings[portletA];350         runs(function() {351            pai = null;352            hubA.startPartialAction(parms).then(function (p) {353               pai = p;354            });355         }); 356         waitsFor(function () {return pai !== null;}, "The promise to settle", 100)357         runs(function() {358            pai.setPageState(ustr);359         }); 360         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);361         runs(function() {362            id = portlet.test.resource.getInitiatingPortletId(pai.url);363            expect(id).toEqual(portletA);364         }); 365      });366      it('return object setPageState URL indicates a different initiating portlet B',function(){367         var parms  = {ap1 : ["actionVal"], ap2 : ["actionVal2"]}, id;368         var ustr = portlet.test.data.updateStrings[portletB];369         runs(function() {370            pai = null;371            hubB.startPartialAction(parms).then(function (p) {372               pai = p;373            });374         }); 375         waitsFor(function () {return pai !== null;}, "The promise to settle", 100)376         runs(function() {377            pai.setPageState(ustr);378         }); 379         waitsFor(cbB.getIsComplete(), "The onStateChange callback should be called", 100);380         runs(function() {381            id = portlet.test.resource.getInitiatingPortletId(pai.url);382            expect(id).toEqual(portletB);383         }); 384      });385      it('returns a partial action URL',function(){386         var parms  = {ap1 : ["actionVal"], ap2 : ["actionVal2"]}, url;387         var ustr = portlet.test.data.updateStrings[portletA];388         runs(function() {389            pai = null;390            hubA.startPartialAction(parms).then(function (p) {391               pai = p;392            });393         }); 394         waitsFor(function () {return pai !== null;}, "The promise to settle", 100)395         runs(function() {396            pai.setPageState(ustr);397         }); 398         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);399         runs(function() {400            expect(portlet.test.action.isPartialActionUrl(pai.url)).toBeTruthy();401         }); 402      });403      it('return object setPageState URL has the action parameters set as expected',function(){404         var parms  = {ap1 : ["actionVal"], ap2 : ["actionVal2"]}, str;405         var ustr = portlet.test.data.updateStrings[portletA];406         runs(function() {407            pai = null;408            hubA.startPartialAction(parms).then(function (p) {409               pai = p;410            });411         }); 412         waitsFor(function () {return pai !== null;}, "The promise to settle", 100)413         runs(function() {414            pai.setPageState(ustr);415         }); 416         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);417         runs(function() {418            str = portlet.test.action.getActionParms(pai.url);419            expect(str).toEqual(parms);420         }); 421      });422      it('return object setPageState URL has multivalued action parameters set as expected',function(){423         var parms  = {ap1 : ["actionVal", "actionVal1"], ap2 : ["actionVal2"]}, str;424         var ustr = portlet.test.data.updateStrings[portletA];425         runs(function() {426            pai = null;427            hubA.startPartialAction(parms).then(function (p) {428               pai = p;429            });430         }); 431         waitsFor(function () {return pai !== null;}, "The promise to settle", 100)432         runs(function() {433            pai.setPageState(ustr);434         }); 435         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);436         runs(function() {437            str = portlet.test.action.getActionParms(pai.url);438            expect(str).toEqual(parms);439         }); 440      });441      it('return object setPageState URL has multivalued action parameters containing null set as expected',function(){442         var parms  = {ap1 : ["actionVal", null, "actionVal1"], ap2 : ["actionVal2"]}, str;443         var ustr = portlet.test.data.updateStrings[portletA];444         runs(function() {445            pai = null;446            hubA.startPartialAction(parms).then(function (p) {447               pai = p;448            });449         }); 450         waitsFor(function () {return pai !== null;}, "The promise to settle", 100)451         runs(function() {452            pai.setPageState(ustr);453         }); 454         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);455         runs(function() {456            str = portlet.test.action.getActionParms(pai.url);457            expect(str).toEqual(parms);458         }); 459      });460      it('return object setPageState URL has null action parameter set as expected',function(){461         var parms  = {ap1 : ["actionVal"], ap2 : [null]}, str;462         var ustr = portlet.test.data.updateStrings[portletA];463         runs(function() {464            pai = null;465            hubA.startPartialAction(parms).then(function (p) {466               pai = p;467            });468         }); 469         waitsFor(function () {return pai !== null;}, "The promise to settle", 100)470         runs(function() {471            pai.setPageState(ustr);472         }); 473         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);474         runs(function() {475            str = portlet.test.action.getActionParms(pai.url);476            expect(str).toEqual(parms);477         }); 478      });479      it('return object setPageState URL has no action parameters when none are added',function(){480         var parms  = {}, str;481         var ustr = portlet.test.data.updateStrings[portletA];482         runs(function() {483            pai = null;484            hubA.startPartialAction(parms).then(function (p) {485               pai = p;486            });487         }); 488         waitsFor(function () {return pai !== null;}, "The promise to settle", 100)489         runs(function() {490            pai.setPageState(ustr);491         }); 492         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);493         runs(function() {494            str = portlet.test.action.getActionParms(pai.url);495            expect(str).toEqual(parms);496         }); 497      });498      it('allows a resource URL to be created containing the render state',function(){499         var parms  = {ap1 : ["actionVal"], ap2 : ["actionVal2"]}, 500             cache="cacheLevelPage", url = null, str;501         runs(function() {502            hubA.createResourceUrl(parms, cache).then(function (u) {503               url = u;504            });505         }); 506         waitsFor(function () {return (url !== null);}, "The promise to settle", 100)507         runs(function() {508            str = portlet.test.resource.getState(url, portletA);509            expect(str).toEqual(cbA.getState());510         }); 511      });512   });513   describe('The portlet hub startPartialAction & setPageState functions: ',function(){514      // Make sure it works for more than one portlet 515      var cbA = new portlet.jasmine.JasminePortletUtils(portletB, pageState);516      var cbB = new portlet.jasmine.JasminePortletUtils(portletB, pageState);517      var cbC = new portlet.jasmine.JasminePortletUtils(portletC, pageState);518      var cbD = new portlet.jasmine.JasminePortletUtils(portletD, pageState);519      // partial action init structure520      var pai = null;521      // add an osc handler for the test522      beforeEach(function () {523         cbA.complete = false;524         cbB.complete = false;525         cbC.complete = false;526         cbD.complete = false;527         runs(function() {528            cbA.oscHandle = hubA.addEventListener("portlet.onStateChange", cbA.getListener());529            cbB.oscHandle = hubB.addEventListener("portlet.onStateChange", cbB.getListener());530            cbC.oscHandle = hubC.addEventListener("portlet.onStateChange", cbC.getListener());531            cbD.oscHandle = hubD.addEventListener("portlet.onStateChange", cbD.getListener());532         }); 533         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);534         waitsFor(cbB.getIsComplete(), "The onStateChange callback should be called", 100);535         waitsFor(cbC.getIsComplete(), "The onStateChange callback should be called", 100);536         waitsFor(cbD.getIsComplete(), "The onStateChange callback should be called", 100);537         runs(function() {538            cbA.complete = false;    // in prep for the actual test539            cbB.complete = false;    // in prep for the actual test540            cbC.complete = false;    // in prep for the actual test541            cbD.complete = false;    // in prep for the actual test542         }); 543      });544      // remove the osc handler added during the test545      afterEach(function () {546         if (cbA.oscHandle !== null) {547            hubA.removeEventListener(cbA.oscHandle);548            cbA.oscHandle = null;549         }550         if (cbB.oscHandle !== null) {551            hubB.removeEventListener(cbB.oscHandle);552            cbB.oscHandle = null;553         }554         if (cbC.oscHandle !== null) {555            hubC.removeEventListener(cbC.oscHandle);556            cbC.oscHandle = null;557         }558         if (cbD.oscHandle !== null) {559            hubD.removeEventListener(cbD.oscHandle);560            cbD.oscHandle = null;561         }562      });563      it('allows actions that update the state of 2 portlets. other portlets are not updated',function(){564         var parms  = {ap1 : ["actionVal"]}, str, states, state;565         var ustr = portlet.test.data.updateStrings[portletB];566         runs(function() {567            pai = null;568            hubB.startPartialAction(parms).then(function (p) {569               pai = p;570            });571         }); 572         waitsFor(function () {return pai !== null;}, "The promise to settle", 100)573         runs(function() {574            pai.setPageState(ustr);575         }); 576         waitsFor(cbB.getIsComplete(), "The onStateChange callback should be called", 100);577         waitsFor(cbC.getIsComplete(), "The onStateChange callback should be called", 100);578         runs(function() {579            states = portlet.test.decodeUpdateString(ustr, portletB);580            state = hubA.newState(states[portletB]);581            expect(cbB.retRenderState).toEqual(state);582            state = hubC.newState(states[portletC]);583            expect(cbC.retRenderState).toEqual(state);584            expect(cbA.isComplete()).toBeFalsy();585            expect(cbD.isComplete()).toBeFalsy();586         }); 587      });588      it('allows actions that update the state of several portlets. The state of each is as expected.',function(){589         var parms  = {ap1 : ["actionVal"]}, str, states, state;590         var ustr = portlet.test.data.updateStrings[portletC];591         runs(function() {592            pai = null;593            hubC.startPartialAction(parms).then(function (p) {594               pai = p;595            });596         }); 597         waitsFor(function () {return pai !== null;}, "The promise to settle", 100)598         runs(function() {599            pai.setPageState(ustr);600         }); 601         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);602         waitsFor(cbB.getIsComplete(), "The onStateChange callback should be called", 100);603         waitsFor(cbC.getIsComplete(), "The onStateChange callback should be called", 100);604         waitsFor(cbD.getIsComplete(), "The onStateChange callback should be called", 100);605         runs(function() {606            states = portlet.test.decodeUpdateString(ustr, portletC);607            state = hubA.newState(states[portletA]);608            expect(cbA.retRenderState).toEqual(state);609            state = hubB.newState(states[portletB]);610            expect(cbB.retRenderState).toEqual(state);611            state = hubC.newState(states[portletC]);612            expect(cbC.retRenderState).toEqual(state);613            state = hubD.newState(states[portletD]);614            expect(cbD.retRenderState).toEqual(state);615         }); 616      });617      it('Blocks the startPartialAction method for a different portlet until setPageState is called',function(){618         var parms  = {ap1 : ["actionVal"]};619         var ustr = portlet.test.data.updateStrings[portletA];620         runs(function() {621            pai = null;622            hubA.startPartialAction(parms).then(function (p) {623               pai = p;624            });625         }); 626         waitsFor(function () {return pai !== null;}, "The promise to settle", 100)627         runs(function() {628            var testFunc = function () {629               hubB.startPartialAction(parms).then(function (p) {630                  pai = p;631               });632            };633            expect(testFunc).toThrowCustomException("AccessDeniedException");634         }); 635         runs(function() {636            pai.setPageState(ustr);637         }); 638         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);639      });640      it('Blocks the action method for a different portlet until setPageState is called',function(){641         var parms  = {ap1 : ["actionVal"]};642         var ustr = portlet.test.data.updateStrings[portletA];643         var el = document.createElement("form");644         runs(function() {645            pai = null;646            hubA.startPartialAction(parms).then(function (p) {647               pai = p;648            });649         }); 650         waitsFor(function () {return pai !== null;}, "The promise to settle", 100)651         runs(function() {652            var testFunc = function () {653               hubB.action(parms, el);654            }655            expect(testFunc).toThrowCustomException("AccessDeniedException");656         }); 657         runs(function() {658            pai.setPageState(ustr);659         }); 660         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);661      });662      it('Blocks the setRenderState method for a different portlet until setPageState is called',function(){663         var parms  = {ap1 : ["actionVal"]};664         var ustr = portlet.test.data.updateStrings[portletA];665         runs(function() {666            pai = null;667            hubA.startPartialAction(parms).then(function (p) {668               pai = p;669            });670         }); 671         waitsFor(function () {return pai !== null;}, "The promise to settle", 100)672         runs(function() {673            var state = cbC.getState();674            state.parameters["someparm1"] = ["NewVal"];675            var testFunc = function () {676               hubC.setRenderState(state);677            }678            expect(testFunc).toThrowCustomException("AccessDeniedException");679         }); 680         runs(function() {681            pai.setPageState(ustr);682         }); 683         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);684      });685   });686   ...SetPortletStateTest.js
Source:SetPortletStateTest.js  
...59             return portlet.register(portletA);60          }61          var ph = new portlet.jasmine.PromiseHandler(testFunc);62          runs(ph.getRun());63          waitsFor(ph.getIsComplete(), "The PortletInit object should be returned", 1000);64          runs(ph.getChecker()); 65          runs(function() {66             expect(ph.result).toBeDefined();67          }); 68          runs(function() {69             hubA = ph.result;70          }); 71       });72       73       it('initializes a portlet hub instance for portlet B',function(){74          var testFunc = function () {75             return portlet.register(portletB);76          }77          var ph = new portlet.jasmine.PromiseHandler(testFunc);78          runs(ph.getRun());79          waitsFor(ph.getIsComplete(), "The PortletInit object should be returned", 1000);80          runs(ph.getChecker()); 81          runs(function() {82             expect(ph.result).toBeDefined();83          }); 84          runs(function() {85             hubB = ph.result;86          }); 87       });88   89       it('initializes a portlet hub instance for portlet C',function(){90          var testFunc = function () {91             return portlet.register(portletC);92          }93          var ph = new portlet.jasmine.PromiseHandler(testFunc);94          runs(ph.getRun());95          waitsFor(ph.getIsComplete(), "The PortletInit object should be returned", 1000);96          runs(ph.getChecker()); 97          runs(function() {98             expect(ph.result).toBeDefined();99          }); 100          runs(function() {101             hubC = ph.result;102          }); 103       });104       105       it('initializes a portlet hub instance for portlet D',function(){106          var testFunc = function () {107             return portlet.register(portletD);108          }109          var ph = new portlet.jasmine.PromiseHandler(testFunc);110          runs(ph.getRun());111          waitsFor(ph.getIsComplete(), "The PortletInit object should be returned", 1000);112          runs(ph.getChecker()); 113          runs(function() {114             expect(ph.result).toBeDefined();115          }); 116          runs(function() {117             hubD = ph.result;118          }); 119       });120     121   });122       123   describe('The portlet hub setRenderState function: ',function(){124      // The tests in this section use just a single portlet - portletA125      var cbA = new portlet.jasmine.JasminePortletUtils(portletA, pageState);126      127      // add an osc handler for the test128      beforeEach(function () {129         cbA.complete = false;130         runs(function() {131            cbA.oscHandle = hubA.addEventListener("portlet.onStateChange", cbA.getListener());132         }); 133         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);134         runs(function() {135            cbA.complete = false;    // in prep for the actual test136         }); 137      });138      139      // remove the osc handler added during the test140      afterEach(function () {141         if (cbA.oscHandle !== null) {142            hubA.removeEventListener(cbA.oscHandle);143            cbA.oscHandle = null;144         }145      });146      it('is present in the register return object and is a function',function(){147         expect(typeof hubA.setRenderState).toEqual('function');148      });149      it('throws a TypeError if no argument is provided',function(){150         var testFunc = function () {151            hubA.setRenderState();152         }153         expect(testFunc).toThrowCustomException("TypeError");154      });155      it('throws a TypeError if too many (>1) arguments are provided',function(){156         var testFunc = function () {157            hubA.setRenderState("parm1", "parm2");158         }159         expect(testFunc).toThrowCustomException("TypeError");160      });161      it('throws a TypeError if the argument is not an object',function(){162         var testFunc = function () {163            hubA.setRenderState(89);164         }165         expect(testFunc).toThrowCustomException("TypeError");166      });167      it('throws a TypeError if the argument is null',function(){168         var testFunc = function () {169            hubA.setRenderState(null);170         }171         expect(testFunc).toThrowCustomException("TypeError");172      });173      it('throws a TypeError if the argument does not have a "parameters" property',function(){174         var state = {175               portletMode : "view",176               windowState : "normal",177         };178         var testFunc = function () {179            hubA.setRenderState(state);180         }181         expect(testFunc).toThrowCustomException("TypeError");182      });183      it('throws a TypeError if the argument does not have a "windowState" property',function(){184         var state = {185               parameters  : {},186               portletMode : "view",187         };188         var testFunc = function () {189            hubA.setRenderState(state);190         }191         expect(testFunc).toThrowCustomException("TypeError");192      });193      it('throws a TypeError if the argument does not have a "portletMode" property',function(){194         var state = {195               parameters  : {},196               windowState : "normal",197         };198         var testFunc = function () {199            hubA.setRenderState(state);200         }201         expect(testFunc).toThrowCustomException("TypeError");202      });203      it('throws an AccessDeniedException if setRenderState is called twice',function(){204         var state = cbA.getState();205         var testFunc = function () {206            hubA.setRenderState(state);207            hubA.setRenderState(state);208         }209         expect(testFunc).toThrowCustomException("AccessDeniedException");210      });211      it('throws an NotInitializedException if no onStateChange listener is registered',function(){212         var state = cbA.getState();213         var testFunc = function () {214            hubB.setRenderState(state);215         }216         expect(testFunc).toThrowCustomException("NotInitializedException");217      });218      it('throws a TypeError if "windowState" has an invalid value',function(){219         var state = cbA.getState();220         state.windowState = "ABNORMAL";221         var testFunc = function () {222            hubA.setRenderState(state);223         }224         expect(testFunc).toThrowCustomException("TypeError");225      });226      it('throws a TypeError if "portletMode" has an invalid value',function(){227         var state = cbA.getState();228         state.portletMode = "ABNORMAL";229         var testFunc = function () {230            hubA.setRenderState(state);231         }232         expect(testFunc).toThrowCustomException("TypeError");233      });234      it('throws an NotInitializedException if the portlet client has no registered onStateChange listener',function(){235         var state = cbA.getState();236         var testFunc = function () {237            hubA.removeEventListener(cbA.oscHandle);238            cbA.oscHandle = null;239            hubA.setRenderState(state);240         }241         expect(testFunc).toThrowCustomException("NotInitializedException");242      });243      it('does not throw an Exception if the argument is correct',function(){244        var state = pageState[portletA].state;245         runs(function() {246            var testFunc = function () {247               hubA.setRenderState(state);248            }249            expect(testFunc).not.toThrow();250         }); 251         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);252      });253      it('causes the onStateChange listener to be called',function(){254         var state = pageState[portletA].state;255         runs(function() {256            hubA.setRenderState(state);257         }); 258         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);259      });260      it('allows the portlet mode to be set to "edit"',function(){261         var state = cbA.getState();262         state.portletMode = "edit";263         runs(function() {264            hubA.setRenderState(state);265         }); 266         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);267         runs(function() {268            expect(cbA.retRenderState.portletMode).toEqual("edit");269         }); 270      });271      it('allows the portlet mode to be set to "view"',function(){272         var state = cbA.getState();273         state.portletMode = "view";274         runs(function() {275            hubA.setRenderState(state);276         }); 277         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);278         runs(function() {279            expect(cbA.retRenderState.portletMode).toEqual("view");280         }); 281      });282      it('allows the window state to be set to "maximized"',function(){283         var state = cbA.getState();284         state.windowState = "maximized";285         runs(function() {286            hubA.setRenderState(state);287         }); 288         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);289         runs(function() {290            expect(cbA.retRenderState.windowState).toEqual("maximized");291         }); 292      });293      it('allows the window state to be set to "normal"',function(){294         var state = cbA.getState();295         state.windowState = "normal";296         runs(function() {297            hubA.setRenderState(state);298         }); 299         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);300         runs(function() {301            expect(cbA.retRenderState.windowState).toEqual("normal");302         }); 303      });304      it('allows a new parameter "NewParm" to be set to "NewVal"',function(){305         var state = cbA.getState();306         state.parameters["NewParm"] = ["NewVal"];307         runs(function() {308            hubA.setRenderState(state);309         }); 310         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);311         runs(function() {312            expect(cbA.retRenderState.parameters["NewParm"]).toEqual(["NewVal"]);313         }); 314      });315      it('allows parameter "NewParm" to be set to ["NewVal1", "NewVal2"]',function(){316         var state = cbA.getState();317         var val = ["NewVal1", "NewVal2"];318         state.parameters["NewParm"] = val;319         runs(function() {320            hubA.setRenderState(state);321         }); 322         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);323         runs(function() {324            expect(cbA.retRenderState.parameters["NewParm"]).toEqual(val);325         }); 326      });327      it('allows a new parameter "NewParm" to be deleted',function(){328         var state = cbA.getState();329         delete state.parameters["NewParm"];330         runs(function() {331            hubA.setRenderState(state);332         }); 333         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);334         runs(function() {335            expect(cbA.retRenderState.parameters["NewParm"]).not.toEqual(["NewVal"]);336         }); 337      });338      it('allows all parameters to be deleted',function(){339         var state = cbA.getState();340         state.parameters = {};341         runs(function() {342            hubA.setRenderState(state);343         }); 344         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);345         runs(function() {346            // count the parameters347            var cnt = 0, parms = cbA.retRenderState.parameters;348            for (var parm in parms) {349               if (parms.hasOwnProperty(parm)) {350                  cnt++;351               }352            }353            expect(cnt).toEqual(0);354         }); 355      });356      it('allows several parameters to be set',function(){357         var state = cbA.getState(),358             newParms = {359                  parm1 : ["Fred"],360                  parm2 : ["Wilma", "Pebbles"],361                  parm3 : ["Barney", "Betty", "Bam Bam"],362               };363         state.parameters = newParms;364         runs(function() {365            hubA.setRenderState(state);366         }); 367         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);368         runs(function() {369            expect(cbA.retRenderState.parameters).toEqual(hubA.newParameters(newParms));370         }); 371      });372      it('allows setting the state back to the original test data',function(){373         var state = cbA.getState();374         runs(function() {375            hubA.setRenderState(state);376         }); 377         waitsFor(cbA.getIsComplete(), "The onStateChange callback should be called", 100);378         runs(function() {379            expect(cbA.retRenderState).toEqual(hubA.newState(state));380         }); 381      });382   });383      384       385   describe('The portlet hub setRenderState function handles public render parameters: ',function(){386      // The tests in this section use three portlets that have public render parameters defined387      var cbB = new portlet.jasmine.JasminePortletUtils(portletB, pageState);388      var cbC = new portlet.jasmine.JasminePortletUtils(portletC, pageState);389      var cbD = new portlet.jasmine.JasminePortletUtils(portletD, pageState);390      391      // add an osc handler for the test392      beforeEach(function () {393         cbB.complete = false;394         cbC.complete = false;395         cbD.complete = false;396         runs(function() {397            cbB.oscHandle = hubB.addEventListener("portlet.onStateChange", cbB.getListener());398            cbC.oscHandle = hubC.addEventListener("portlet.onStateChange", cbC.getListener());399            cbD.oscHandle = hubD.addEventListener("portlet.onStateChange", cbD.getListener());400         }); 401         waitsFor(cbB.getIsComplete(), "The onStateChange callback should be called", 100);402         waitsFor(cbC.getIsComplete(), "The onStateChange callback should be called", 100);403         waitsFor(cbD.getIsComplete(), "The onStateChange callback should be called", 100);404         runs(function() {405            cbB.complete = false;    // in prep for the actual test406            cbC.complete = false;    // in prep for the actual test407            cbD.complete = false;    // in prep for the actual test408         }); 409      });410      411      // remove the osc handler added during the test412      afterEach(function () {413         if (cbB.oscHandle !== null) {414            hubB.removeEventListener(cbB.oscHandle);415            cbB.oscHandle = null;416         }417         if (cbC.oscHandle !== null) {418            hubC.removeEventListener(cbC.oscHandle);419            cbC.oscHandle = null;420         }421         if (cbD.oscHandle !== null) {422            hubD.removeEventListener(cbD.oscHandle);423            cbD.oscHandle = null;424         }425      });426      it('throws an AccessDeniedException if called before previous set render state completes',function(){427         var parms  = {rp1 : ["resVal"]};428         var el = document.createElement("form");429         runs(function() {430            var state = cbB.getState();431            state.parameters["pubparm1"] = ["NewVal"];432            var testFunc = function () {433               hubB.setRenderState(state);434            }435            expect(testFunc).not.toThrow();436         }); 437         runs(function() {438            var state = cbC.getState();439            state.parameters["someparm1"] = ["NewVal"];440            var testFunc = function () {441               hubC.setRenderState(state);442            }443            expect(testFunc).toThrowCustomException("AccessDeniedException");444         }); 445         waitsFor(cbB.getIsComplete(), "The onStateChange callback should be called", 100);446      });447      it('informs the initiating portlet (B) when public render parameter is set',function(){448         var state = cbB.getState();449         state.parameters["pubparm1"] = ["NewVal"];450         runs(function() {451            hubB.setRenderState(state);452         }); 453         waitsFor(cbB.getIsComplete(), "The onStateChange callback should be called", 100);454         runs(function() {455            expect(cbB.retRenderState.parameters["pubparm1"]).toEqual(["NewVal"]);456         }); 457      });458      it('informs the other affected portlet (C) when public render parameter is set',function(){459         var state = cbB.getState();460         state.parameters["pubparm1"] = ["NewVal2"];461         runs(function() {462            hubB.setRenderState(state);463         }); 464         waitsFor(cbC.getIsComplete(), "The onStateChange callback should be called", 100);465         runs(function() {466            expect(cbC.retRenderState.parameters["pubparm1"]).toEqual(["NewVal2"]);467         }); 468      });469      it('does not inform unaffected portlet (D) when public render parameter is set',function(){470         var state = cbB.getState();471         state.parameters["pubparm1"] = ["NewVal"];472         runs(function() {473            hubB.setRenderState(state);474         }); 475         waitsFor(cbB.getIsComplete(), "The onStateChange callback should be called", 100);476         waitsFor(cbC.getIsComplete(), "The onStateChange callback should be called", 100);477         runs(function() {478            expect(cbD.isComplete()).toBeFalsy();479         }); 480      });481      it('does not update private parameter in unaffected portlet (D) with same name as public parameter',function(){482         var state = cbC.getState();483         state.parameters["pubparm1"] = ["newVal4"];484         runs(function() {485            hubC.setRenderState(state);486         }); 487         waitsFor(cbB.getIsComplete(), "The onStateChange callback should be called", 100);488         waitsFor(cbC.getIsComplete(), "The onStateChange callback should be called", 100);489         runs(function() {490            expect(cbD.isComplete()).toBeFalsy();491         }); 492      });493      it('does not update PRP when private parameter with same name as PRP is changed in different portlet',function(){494         var state = cbD.getState();495         state.parameters["pubparm1"] = ["NewVal5"];496         runs(function() {497            hubD.setRenderState(state);498         }); 499         waitsFor(cbD.getIsComplete(), "The onStateChange callback should be called", 100);500         runs(function() {501            expect(cbB.isComplete()).toBeFalsy();502            expect(cbC.isComplete()).toBeFalsy();503            expect(cbD.retRenderState.parameters["pubparm1"]).toEqual(["NewVal5"]);504         }); 505      });506      it('allows changing multiple PRPs and having affected portlets be notified',function(){507         var state = cbC.getState(), prp1, prp2;508         prp1 = state.parameters.pubparm1 = ["NewVal5", "NewVal6"];509         prp2 = state.parameters.pubparm2 = ["NewVal7", "NewVal8"];510         runs(function() {511            hubC.setRenderState(state);512         }); 513         waitsFor(cbB.getIsComplete(), "The onStateChange callback should be called", 100);514         waitsFor(cbC.getIsComplete(), "The onStateChange callback should be called", 100);515         waitsFor(cbD.getIsComplete(), "The onStateChange callback should be called", 100);516         runs(function() {517            expect(cbB.retRenderState.parameters["pubparm1"]).toEqual(prp1);518            expect(cbC.retRenderState.parameters["pubparm1"]).toEqual(prp1);519            expect(cbC.retRenderState.parameters["pubparm2"]).toEqual(prp2);520            expect(cbD.retRenderState.parameters["pubparm2"]).toEqual(prp2);521            // pubparm1 is private parm for portletD522            expect(cbD.retRenderState.parameters["pubparm1"]).not.toEqual(prp1);523         }); 524      });525      it('allows a PRP to be deleted, and it is deleted for all affected portlets',function(){526         var state = cbB.getState();527         delete state.parameters["pubparm1"];528         runs(function() {529            hubB.setRenderState(state);530         }); 531         waitsFor(cbB.getIsComplete(), "The onStateChange callback should be called", 100);532         waitsFor(cbC.getIsComplete(), "The onStateChange callback should be called", 100);533         runs(function() {534            expect(cbB.retRenderState.parameters["pubparm1"]).toBeUndefined();535            expect(cbC.retRenderState.parameters["pubparm1"]).toBeUndefined();536         }); 537      });538      it('allows a deleted PRP to be added again',function(){539         var state = cbB.getState();540         state.parameters["pubparm1"] = ["NewVal2", "NewVal3"];541         runs(function() {542            hubB.setRenderState(state);543         }); 544         waitsFor(cbB.getIsComplete(), "The onStateChange callback should be called", 100);545         waitsFor(cbC.getIsComplete(), "The onStateChange callback should be called", 100);546         runs(function() {547            expect(cbB.retRenderState.parameters["pubparm1"]).toEqual(["NewVal2", "NewVal3"]);548            expect(cbC.retRenderState.parameters["pubparm1"]).toEqual(["NewVal2", "NewVal3"]);549            expect(cbD.isComplete()).toBeFalsy();550         }); 551      });552      it('informs only affected portlets when a PRP is deleted',function(){553         var state = cbB.getState();554         delete state.parameters["pubparm1"];555         runs(function() {556            hubB.setRenderState(state);557         }); 558         waitsFor(cbB.getIsComplete(), "The onStateChange callback should be called", 100);559         waitsFor(cbC.getIsComplete(), "The onStateChange callback should be called", 100);560         runs(function() {561            expect(cbD.isComplete()).toBeFalsy();562         }); 563      });564      it('allows a deleted PRP to be added again through a different portlet',function(){565         var state = cbC.getState(),566             prp1 = ["NewVal10", "NewVal11"];567         state.parameters["pubparm1"] = prp1;568         runs(function() {569            hubC.setRenderState(state);570         }); 571         waitsFor(cbB.getIsComplete(), "The onStateChange callback should be called", 100);572         waitsFor(cbC.getIsComplete(), "The onStateChange callback should be called", 100);573         runs(function() {574            expect(cbB.retRenderState.parameters["pubparm1"]).toEqual(prp1);575            expect(cbC.retRenderState.parameters["pubparm1"]).toEqual(prp1);576            // pubparm1 is private parameter for portlet D 577            expect(cbD.isComplete()).toBeFalsy();578            expect(cbD.retRenderState.parameters["pubparm1"]).not.toEqual(prp1);579         }); 580      });581      it('allows deleting all parameters on a portlet with PRPs. All affected portlets are notified',function(){582         var state = cbC.getState();583         state.parameters = {};584         runs(function() {585            hubC.setRenderState(state);586         }); 587         waitsFor(cbB.getIsComplete(), "The onStateChange callback should be called", 100);588         waitsFor(cbC.getIsComplete(), "The onStateChange callback should be called", 100);589         waitsFor(cbD.getIsComplete(), "The onStateChange callback should be called", 100);590         runs(function() {591            expect(cbB.retRenderState.parameters["pubparm1"]).toBeUndefined();592            expect(cbC.retRenderState.parameters["pubparm1"]).toBeUndefined();593            expect(cbC.retRenderState.parameters["pubparm2"]).toBeUndefined();594            expect(cbD.retRenderState.parameters["pubparm2"]).toBeUndefined();595            expect(cbD.retRenderState.parameters["pubparm1"]).toBeDefined();596         }); 597      });598      it('allows adding back multiple previously deleted PRPs and having affected portlets be notified',function(){599         var state = cbC.cloneState(pageState[portletC].state);600         var prp1 = state.parameters.pubparm1;601         var prp2 = state.parameters.pubparm2;602         runs(function() {603            hubC.setRenderState(state);604         }); 605         waitsFor(cbB.getIsComplete(), "The onStateChange callback should be called", 100);606         waitsFor(cbC.getIsComplete(), "The onStateChange callback should be called", 100);607         waitsFor(cbD.getIsComplete(), "The onStateChange callback should be called", 100);608         runs(function() {609            expect(cbB.retRenderState.parameters["pubparm1"]).toEqual(prp1);610            expect(cbC.retRenderState.parameters["pubparm1"]).toEqual(prp1);611            expect(cbC.retRenderState.parameters["pubparm2"]).toEqual(prp2);612            expect(cbD.retRenderState.parameters["pubparm2"]).toEqual(prp2);613            expect(cbD.retRenderState.parameters["pubparm1"]).not.toEqual(prp1);614         }); 615      });616      it('allows setting the state back to the original test data',function(){617         var stateB = cbB.cloneState(pageState[portletB].state),618             stateC = cbC.cloneState(pageState[portletC].state),619             stateD = cbD.cloneState(pageState[portletD].state),620             prp1 = stateC.parameters.pubparm1,621             prp2 = stateC.parameters.pubparm2;622         623         runs(function() {624            hubB.setRenderState(stateB);625         }); 626         waitsFor(cbB.getIsComplete(), "The onStateChange callback should be called", 100);627         628         runs(function() {629            hubC.setRenderState(stateC);630         }); 631         waitsFor(cbC.getIsComplete(), "The onStateChange callback should be called", 100);632         633         runs(function() {634            hubD.setRenderState(stateD);635         }); 636         waitsFor(cbD.getIsComplete(), "The onStateChange callback should be called", 100);637         638         runs(function() {639            expect(cbB.retRenderState.parameters["pubparm1"]).toEqual(prp1);640            expect(cbC.retRenderState.parameters["pubparm1"]).toEqual(prp1);641            expect(cbC.retRenderState.parameters["pubparm2"]).toEqual(prp2);642            expect(cbD.retRenderState.parameters["pubparm2"]).toEqual(prp2);643         }); 644      });645   646   });...Using AI Code Generation
1var trace = require('./tracetest.js');2var isComplete = trace.getIsComplete();3console.log(isComplete);4exports.getIsComplete = function() {5  return true;6};7Your name to display (optional):8Your name to display (optional):9exports.getIsComplete = function() {10  return true;11};12Your name to display (optional):Using AI Code Generation
1var trace = require('./tracetest.js');2var isComplete = trace.getIsComplete();3console.log(isComplete);4var trace = require('./tracetest.js');5var isComplete = trace.getIsComplete();6console.log(isComplete);7var trace = require('./tracetest.js');8var isComplete = trace.getIsComplete();9console.log(isComplete);10var trace = require('./tracetest.js');11var isComplete = trace.getIsComplete();12console.log(isComplete);13var trace = require('./tracetest.js');14var isComplete = trace.getIsComplete();15console.log(isComplete);16var trace = require('./tracetest.js');17var isComplete = trace.getIsComplete();18console.log(isComplete);19var trace = require('./tracetest.js');20var isComplete = trace.getIsComplete();21console.log(isComplete);22var trace = require('./tracetest.js');23var isComplete = trace.getIsComplete();24console.log(isComplete);25var trace = require('./tracetest.js');26var isComplete = trace.getIsComplete();27console.log(isComplete);28var trace = require('./tracetest.js');29var isComplete = trace.getIsComplete();30console.log(isComplete);31var trace = require('./tracetest.js');32var isComplete = trace.getIsComplete();33console.log(isComplete);Using AI Code Generation
1var trace = require('./tracetest.js');2console.log(trace.getIsComplete());3var getIsComplete = function() {4  return true;5};6exports.getIsComplete = getIsComplete;7var path = require('path');8var trace = require(path.join(__dirname, 'tracetest.js'));9console.log(trace.getIsComplete());Using AI Code Generation
1var trace = require('./tracetest.js');2var isComplete = trace.getIsComplete();3console.log('isComplete: ' + isComplete);4var isComplete = false;5var getIsComplete = function(){6  return isComplete;7}8module.exports = {9}10var trace = require('./tracetest.js');11var isComplete = trace.getIsComplete();12console.log('isComplete: ' + isComplete);13var isComplete = false;14var getIsComplete = function(){15  return isComplete;16}17module.exports = {18}Using AI Code Generation
1var trace = require('./tracetest.js');2console.log(trace.getIsComplete());3module.exports = {4getIsComplete : function(){5return "getIsComplete";6}7};8var trace = require('./tracetest.js');9console.log(trace.getIsComplete());10module.exports = {11getIsComplete : function(){12return "getIsComplete";13}14};15module.exports = {16getIsComplete : function(){17return "getIsComplete";18}19};Using AI Code Generation
1var trace = require('./tracetest');2var trc = new trace.Trace();3trc.getIsComplete();4I have the same question Show 0 Likes (0)5I have the same question Show 0 Likes (0)6I have the same question Show 0 Likes (0)Using AI Code Generation
1var trace = require('./tracetest.js');2var isComplete = trace.getIsComplete();3console.log(isComplete);4var isComplete = false;5var getIsComplete = function() {6  return isComplete;7}8exports.getIsComplete = getIsComplete;9var trace = require('./tracetest.js');10var isComplete = trace.getIsComplete();11console.log(isComplete);12var isComplete = false;13var TraceTest = function() {14  this.getIsComplete = function() {15    return isComplete;16  }17}18exports.TraceTest = TraceTest;19var trace = require('./tracetest.js');20var traceTest = new trace.TraceTest();21var isComplete = traceTest.getIsComplete();22console.log(isComplete);23var isComplete = false;24exports.isComplete = isComplete;25var trace = require('./tracetest.js');26var isComplete = trace.isComplete;27console.log(isComplete);28var isComplete = false;29var getIsComplete = function() {30  return isComplete;31}32module.exports = getIsComplete;Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
