angularjs - Testing an attribute of isolated scope from a directive -
I have already tested Q & A related to directing, separate scopes that help me test a feature Found in the '@'
property; But I find it hard to test such properties that use the '='
property
(from my next coming direction):
return {restrict: 'a', link: link, radius: {upcoming: '@', patient details: = '}}; In my testing for upcoming
I use it (forward angle 1.2) by using it like the isolateScope ()
function I can:
ALM = angular Element ('& lt; div forthcoming = "recall" patient details = "patient details" & gt; & lt; / div & gt;'); // directs the direction and links it to $ compilation (elm) (region); Scope $ digest (). Different scope = elm Istholtascope ();
And in the testing I can do this:
This ("attribute should be attached to separate 'incoming' ', work ( TB ('memorable';)); () ();
But if I go to other properties in the same way then I get an undefined
error. I tried again:
// Retrieve Goal HTML - Recalled html first (Injection (function ($ compilation) {Patient = {Name: 'Lorem Ipsum', readyForRefill: 1, Progress count: 2, Upcoming count: 3, Number of tagged: 4, end date: 5, one more: 9000}; Elm = angular element ('& lt; div upcoming' 'patient-description = "patient" & gt; & lt; / div & gt;); // directive Doing And the $ COLLECTION (ELM) (scope) connects the scope, scope. $ Digest (); isolation; Scope = elm. Ilolotsscop (); different Scopkpetiant Sex = patient;}));
Examination: <("isolated Scopepatient Details)" ("Differentiated" is to be attributed to 'Patient Details' to be excluded), Work () (defined) Go ();});
passes, but I think it is testing the wrong thing.
Can anyone explain to me this ?
Edit
What TASKATT suggested to solve the problem, but break 5 other tests These tests, done for the group, basically examined the loading of the actual template and determined what content they were. For example:
("Li"); expect (li.length) .toBe (4);});
is no longer valid because What is the correct way to load both? Although it is worth noting which template will change based on the log, so any effort can be made to test Divs and P tags as irrelevant for the tests? Thank you elm
element now & quot; div forthcoming = "remembered" patient "=" patient "& gt; & lt
& lt; p & gt; & Lt; a href = "" & gt; & lt; b & gt; Sign in & lt; / p & gt; & lt; / a & gt; Complete your & lt; Br> To see the status of the pamphlet. & Lt; / P & gt; & Lt; Ul & gt; & Lt; Li & gt; & Lt; Period & gt; {{PatientDetails.readyForRefill}} & lt; / Span & gt; Tips for refill & lt; / Li & gt; & Lt; Li & gt; & Lt; Period & gt; {{PatientDetails.readyForRefill}} & lt; / Span & gt; ReadyFill & LT; Support & gt; & Amp; # 174; & Lt; / Sup> & Lt; Li & gt; & Lt; Period & gt; & Lt; {{patientDetails.expiringCount}} / Span & gt; Ending prescriptions & lt; / Li & gt; & Lt; Li & gt; & Lt; Period & gt; {{PatientDetails.oneRefillRemaining}} & lt; / Span & gt; 1 refill with tips left & lt; / Li & gt; & Lt; / Ul & gt;
If you want to ensure that the scope of the instruction is correct patient If you pass the details then you must keep it in the scope before the element is compiled. You can then get it through the different scope ()
and make your assumptions. For example:
Lm = angular.liment (' and:
this ("must work", function () (hopefully (different scope.patient details). TBE based ( ); Hopefully (different Skype .name) .toBe ('Lorem Ipsum');}); If you need to test exactly the markup generated, then you should use the compiled element: code> compiled = $ compilation (elm) (scope); ... this should be "4th in ul", function () {var le = compiled.find (' Li '); Hopefully (li.length) .toBe (4) ;});
Comments
Post a Comment