1

Im fairly new to unit testing and Jasmine. What I'm trying to test is to see if the window has resized, but I'm not sure how to do it.

I have tables that resize with jQuery and but the script only starts working when the browser is resized below a certain amount. What i want to do with jasmine is check if the browser window has decreased in size.

I tried doing $(window).resizeTo(1000,1000) but that doesn't seem to work with latest browsers? I tried using pop-ups instead but that caused a whole lot of problems.

Any ideas?

2
  • stackoverflow.com/questions/7649574/… This might help but I don't seem to understand what you need. Commented May 1, 2012 at 22:53
  • 1
    I'm not sure I got your question. You want to resize browser window using jQuery? I doubt that's even possible because JQuery only interacts with DOM within browser and not the browser itself. What your are looking for here is a Windows event that resizes application window I guess. Commented May 2, 2012 at 14:26

1 Answer 1

2

You cannot reliably use resizeTo to actually resize the window.

If you have handlers on window.onresize what you should be doing is manually calling the handlers you have that listen for a window resize in your test and use jquery-jasmine to see whether you meet your UI expectations.

As an alternative, if you use say modernizr or simply measuring the window size, use spyOn with andCallFake to mock them providing your custom size.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, ill give that shot, what ended up doing is putting a wrapper around the fixture and changing the width of it before i called the function/object that makes changes then testing against that.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.