开发者

How can I get Jasmine-jQuery to correctly read z-index properties?

I'm using Jasmine and Jasmine-jQuery to test the Javascript in my application. I set up an HTML fixture have successfully tested showing and hiding elements and other interactions, but so far, I can't get it to correctly set and read a z-index value.

Here's a failing test:

    it("understands z-index values", function(){
      loadFixtures('input_tips.html');
      $('span.tip:first').css('z-index',200);
      expect($('span.tip:first').css('z-index')).toEqual(200);
    });

This test fails; the z-index is read as "auto."

So far I've tried:

  • Setting and checking other CSS attributes, like color, in my test. This works fine.
  • Setting and checking z-index values with jQuery in my console. This works fine.
  • Setting the z-index as a string value instead of a number. Makes no difference.
  • Hard开发者_开发知识库-coding the z-index in an HTML "style" tag. Makes no difference.

Am I doing something wrong, or is this a bug?


This happens because z-index only makes sense when position attribute is present and set to 'relative' or 'absolute'. Please try changing it to:

it("understands z-index values", function(){
  loadFixtures('input_tips.html');
  $('span.tip:first').css({'position':'relative','z-index':200});
  expect($('span.tip:first').css('z-index')).toEqual('200');
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜