Reputation: 303
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?
Upvotes: 1
Views: 7789
Reputation: 13105
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.
Upvotes: 2