Thanks Ariel,
Do you know if there's any other way of making my tests unitary that
doesn't involve taking the code I have in my application.js binding
the actions, and repeating it in the setup part of the module? I
actually tried doing this but it hasn't worked out for me.
I have a pastie of my code http://pastie.org/337487 I placed two
alerts in application.js (one for each binding), but only one gets
called, and the weird thing is that it depends on which of the two
tests (in tests.js) runs first. If the prev test runs first, only the
prev alert is called inside application.js, if it's the next test the
one that runs first, the opposite happens.

Nacho

PS: Sorry for the triple post. I didn't get a warning saying my post
had to be moderated, it said it was successful.

On Dec 12, 1:18 am, Ariel Flesler <[email protected]> wrote:
> Unit tests are meant to be unitary, that is, every test you setup and
> clean up whatever they need. This could be events, extra markup, etc.
>
> You shouldn't assume a click bound before the test.
>
> --
> Ariel Fleslerhttp://flesler.blogspot.com
>
> On Oct 19, 12:16 am, "John Teague" <[email protected]> wrote:
>
> > yes, commenting out that line did resolve the issue.
>
> > Thanks you.  Please let me know if the change is going to committed to the
> > trunk or if I need to submit a bug report.
>
> > Thanks,
> > John
>
> > On Sat, Oct 18, 2008 at 4:59 PM, Diego Perini <[email protected]>wrote:
>
> > > John,
> > > it doesn't seem a "ready()" problem, look instead in
> > > "testrunner.js"...explicitly in the "reset()" method that the "test()"
> > > function is calling inside a try/catch block.
>
> > > The content of the "#main" container is overwritten by the following
> > > line of code in the "reset()" method:
>
> > >   jQuery("#main").html( _config.fixture );
>
> > > Even if the "_config.fixture" is an exact clone of the original html,
> > > events are lost when using the ".html()" method to replace content.
>
> > > I have tested commenting the above line and theeventis correctly
> > > fired, the alert says "hello"...
>
> > > Hope I did understand and explain correctly,
>
> > > --
> > > Diego Perini
>
> > > On 18 Ott, 15:46, "John Teague" <[email protected]> wrote:
> > > > sure, here is the complete test suite.
>
> > > > thanks for helping with this,
> > > > John
>
> > > > <head><link rel="Stylesheet" href="../Content/css/testsuite.css"
> > > /><title>
>
> > > > </title></head>
> > > > <body>
>
> > > >  <h1>WebService Tests</h1>
> > > >  <h2 id="banner"></h2>
> > > >  <h2 id="userAgent"></h2>
>
> > > >  <ol id="tests"></ol>
>
> > > >  <div id="main">
> > > >     <a id="l2" href="#">Execute Function Test</a>
> > > >  </div>
>
> > > > </body>
> > > > <script src="/Content/js/jquery.js" type="text/javascript"></script>
> > > > <script type="text/javascript">/*<![CDATA[*/
> > > >     $(document).ready(function(){
> > > >         $('#l2').click(test1);
>
> > > > });
>
> > > > //]]></script>
>
> > > > <script type="text/javascript"
> > > > src="../../Content/js/testrunner.js"></script>
> > > > <script type="text/javascript">
> > > >         function test1(){
> > > >             ok(true,"clickevent");
> > > >             alert("hello");
> > > >             return false;
> > > >         }
> > > >         $(document).ready(function(){
>
> > > >             module("when anchor is generated ");
> > > >             test("should create anchor with correct id",function(){
> > > >                 var $a = $('#l2');
> > > >                 ok($a.length === 1);
> > > >             });
>
> > > >             test("should create anchor with correct text",function(){
> > > >                 var $a = $('#l2');
> > > >                 ok($a.text() === 'Execute Function Test');
> > > >             });
>
> > > >             module("when calling execute function on click")
>
> > > >             test("should execute the specified method",function(){
> > > >                 expect(1);
> > > >                 var $a = $('#l2').click();
>
> > > >             });
>
> > > >         });
>
> > > >     </script>
> > > > </html>
>
> > > > On Sat, Oct 18, 2008 at 2:39 AM, Jörn Zaefferer <
>
> > > > [email protected]> wrote:
> > > > > Could you provide a more complete example?
>
> > > > > Jörn
>
> > > > > On Fri, Oct 17, 2008 at 6:41 PM, john teague <[email protected]>
> > > wrote:
>
> > > > > > I have a library that generates jquery that I would like to test 
> > > > > > with
> > > > > >qUnit, but I'm running into problems.
>
> > > > > > The library generates attaches events during the readyevent, but
> > > > > > events are not being wired up when I have a unit test on the page in
> > > a
> > > > > > sepearate readyevent.  My code looks like this.
> > > > > > <body>
> > > > > >  <div id="main">
> > > > > >        <a id="l2" href="#">Execute Function Test</a>
> > > > > >  </div>
> > > > > > </body>
> > > > > > --script source tags here
> > > > > > --this is the generated code
> > > > > > <script type="text/javascript">/*<![CDATA[*/
> > > > > >        $(document).ready(function(){
> > > > > >                $('#l2').click(function(){alert('hello')});
>
> > > > > > });
>
> > > > > > //]]></script>
> > > > > > -- and now the tests
> > > > > > <script type="text/javascript">
> > > > > > $(document).ready(function(){
> > > > > >                        module("when anchor is generated ");
> > > > > >                        test("should create anchor with correct
> > > > > id",function(){
> > > > > >                                var $a = $('#l2');
> > > > > >                                ok($a.length === 1);
> > > > > >                        });
> > > > > > });
> > > > > > </script>
> > > > > > the clickeventwill not fire for the anchor.
>
> > > > > > Any suggestions?
>
> > > > > > Thanks,
> > > > > > John
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to