CSS Styles only appear to work when you specify them in style attributes.

4 views
Skip to first unread message

leeand00

unread,
May 14, 2010, 11:16:10 AM5/14/10
to JsTestDriver
It seems that CSS Styles only appear to work when you specify them in
style attributes of an element. When you specify them as an assigned
class they seem to have no effect.

--
You received this message because you are subscribed to the Google Groups "JsTestDriver" group.
To post to this group, send email to js-test...@googlegroups.com.
To unsubscribe from this group, send email to js-test-drive...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/js-test-driver?hl=en.

kenny....@gmail.com

unread,
May 14, 2010, 11:19:07 AM5/14/10
to js-test...@googlegroups.com
You really shouldn't be worrying about css styles in your javascript testing.

The css styles probably don't work using class names becuase you don't have the css class imported.

What are you trying to do that you want to check the style of an element?
Sent from my Verizon Wireless BlackBerry

leeand00

unread,
May 14, 2010, 11:39:12 AM5/14/10
to JsTestDriver
Yes,

I'm actually using a jquery plugin called SimpleModal (http://
www.ericmmartin.com/projects/simplemodal) to display a dialog box to
the user. When you call $('#elementId').modal() it is suppose to
display a dialog, and all I really want to do is test if the dialog
has been displayed or not.

I've tried a couple of different things before I reverted to checking
the className to see if it was displayed; for instance I tried
checking the element.style.display property and the
element.style.visibility property, but both didn't yeild a result even
after calling the modal() method on the line directly before it to
rule out any other code problems.

On May 14, 11:19 am, kenny.ortm...@gmail.com wrote:
> You really shouldn't be worrying about css styles in your javascript testing.
>
> The css styles probably don't work using class names becuase you don't have the css class imported.
>
> What are you trying to do that you want to check the style of an element?
> Sent from my Verizon Wireless BlackBerry
>
> -----Original Message-----
> From: leeand00 <leean...@gmail.com>
> Date: Fri, 14 May 2010 08:16:10
> To: JsTestDriver<js-test...@googlegroups.com>
> Subject: CSS Styles only appear to work when you specify them in style
>
>         attributes.
>
> It seems that CSS Styles only appear to work when you specify them in
> style attributes of an element.  When you specify them as an assigned
> class they seem to have no effect.
>
> --
> You received this message because you are subscribed to the Google Groups "JsTestDriver" group.
> To post to this group, send email to js-test...@googlegroups.com.
> To unsubscribe from this group, send email to js-test-drive...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/js-test-driver?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "JsTestDriver" group.
> To post to this group, send email to js-test...@googlegroups.com.
> To unsubscribe from this group, send email to js-test-drive...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/js-test-driver?hl=en.

Misko Hevery

unread,
May 14, 2010, 11:40:33 AM5/14/10
to js-test...@googlegroups.com
browsers compute CSS styles differently if they are attached to the DOM or if it is a DOM fragment. Did you attach your DOM under test to the document?

kenny....@gmail.com

unread,
May 14, 2010, 11:44:27 AM5/14/10
to js-test...@googlegroups.com
In all reality I would say that you should be mocking out the modal call and expecting that the .modal() method is called on that object.

If you are checking the style of the object after calling the modal method then you are essentially testing the jquery modal plugin that you are using. If you need to write tests around the plugin then you don't trust the plugin and you shouldn't be using it IMHO.

I've been writing some of my own helper methods for mocking stuff out but I'm not sure how useful it would be in your case, and I haven't been using the framework long enough to know if I'm even doing it the correct way.

leeand00

unread,
May 14, 2010, 12:05:18 PM5/14/10
to JsTestDriver
@Misko

I don't know if I attached it to the document or not. I have two
places where I use the /*:DOC += syntax to attach things to the tests,
the first one is in the setUp method where I attach the form that I am
testing the validation for; the second place is in my unit test where
I attach the div that will become the content of the Modal dialog.

Am I attaching my DOM to the document or not?

Thanks,
Andrew J. Leer
> > js-test-drive...@googlegroups.com<js-test-driver%2Bunsu...@googlegroups.com>
> > .
> > > For more options, visit this group athttp://
> > groups.google.com/group/js-test-driver?hl=en.
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > "JsTestDriver" group.
> > > To post to this group, send email to js-test...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > js-test-drive...@googlegroups.com<js-test-driver%2Bunsu...@googlegroups.com>
> > .
> > > For more options, visit this group athttp://
> > groups.google.com/group/js-test-driver?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "JsTestDriver" group.
> > To post to this group, send email to js-test...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > js-test-drive...@googlegroups.com<js-test-driver%2Bunsu...@googlegroups.com>
> > .

leeand00

unread,
May 14, 2010, 12:09:09 PM5/14/10
to JsTestDriver
@kenny Hmm I hadn't thought of the fact that I'm testing the jquery
plugin...I just wanted to preserve the functionality that I had
written for later reference, so in that sense I guess this is more of
an integration test than a unit test. Maybe I should mock that
functionality out.

Should be as simple as adding a fake method for it to the jquery
object, and when the method is called, it sets the value to true, and
then assert on that to see if the dialog was displayed or not.

On May 14, 11:44 am, kenny.ortm...@gmail.com wrote:
> In all reality I would say that you should be mocking out the modal call and expecting that the .modal() method is called on that object.
>
> If you are checking the style of the object after calling the modal method then you are essentially testing the jquery modal plugin that you are using. If you need to write tests around the plugin then you don't trust the plugin and you shouldn't be using it IMHO.
>
> I've been writing some of my own helper methods for mocking stuff out but I'm not sure how useful it would be in your case, and I haven't been using the framework long enough to know if I'm even doing it the correct way.
>
> Sent from my Verizon Wireless BlackBerry
>
> -----Original Message-----
> From: leeand00 <leean...@gmail.com>
> Date: Fri, 14 May 2010 08:39:12
> To: JsTestDriver<js-test...@googlegroups.com>
> Subject: Re: CSS Styles only appear to work when you specify them in style
>
>         attributes.
>
> Yes,
>
> I'm actually using a jquery plugin called SimpleModal (http://www.ericmmartin.com/projects/simplemodal) to display a dialog box to

Misko Hevery

unread,
May 14, 2010, 12:20:14 PM5/14/10
to js-test...@googlegroups.com
Yes the /*:DOC syntax attaches to the document, so you should be good. id that does not work than I am out of ideas.
Reply all
Reply to author
Forward
0 new messages