Permalink
Browse files

fixed some unit tests and added a test for attribute selector support…

… in IE7+
  • Loading branch information...
1 parent b652928 commit e8f2678fb86a2c2dff8fafd0d9680faf6b3dc8a6 scottjehl committed Jan 16, 2012
Showing with 37 additions and 3 deletions.
  1. +1 −1 test/unit/index.html
  2. +4 −0 test/unit/test.css
  3. +32 −2 test/unit/tests.js
View
@@ -22,7 +22,7 @@ <h2 id="qunit-userAgent"></h2>
<div id="launcher"></div>
<!-- elem for applying css via queries -->
- <div id="testelem"></div>
+ <div id="testelem" class="foo">test</div>
</body>
</html>
View
@@ -13,13 +13,17 @@
#testelem {
width: 50px;
+ display: block;
}
/*styles for 480px and up */
@media screen and (min-width: 480px) {
#testelem {
width: 150px;
}
+ #testelem[class=foo] {
+ height: 200px;
+ }
}
/*styles for 500px and under*/
View
@@ -27,6 +27,23 @@ window.onload = function(){
function heightApplied( val ){
return testElem.offsetHeight === val;
}
+
+ // A short snippet for detecting versions of IE in JavaScript - author: @padolsey
+ var ie = (function(){
+
+ var undef,
+ v = 3,
+ div = document.createElement('div'),
+ all = div.getElementsByTagName('i');
+
+ while (
+ div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
+ all[0]
+ );
+
+ return v > 4 ? v : undef;
+
+ }());
window.moveTo(0,0);
@@ -40,13 +57,25 @@ window.onload = function(){
});
asyncTest( 'styles within min-width media queries apply properly', function() {
- window.resizeTo(500,600);
+ window.resizeTo(520,600);
setTimeout(function(){
ok( widthApplied( 150 ), 'testelem is 150px wide when window is 500px wide' );
start();
}, 900);
});
+ // This test is for a feature in IE7 and up
+ if( ie >= 7 ){
+ asyncTest( "attribute selectors still work (where supported) after respond runs its course", function() {
+ window.resizeTo(520,600);
+ setTimeout(function(){
+ ok( heightApplied( 200 ), "testelem is 200px tall when window is 500px wide" );
+ start();
+ }, 900);
+ });
+ }
+
+
asyncTest( 'styles within max-width media queries apply properly', function() {
window.resizeTo(300,600);
setTimeout(function(){
@@ -78,7 +107,7 @@ window.onload = function(){
asyncTest( "Styles within a false media query do not apply", function() {
window.resizeTo(800,600);
setTimeout(function(){
- ok( !widthApplied( 500 ), "testelem is not 500px wide when window is 1300px wide" );
+ ok( !widthApplied( 500 ), "testelem is not 500px wide when window is 800px wide" );
start();
}, 900);
@@ -92,6 +121,7 @@ window.onload = function(){
}, 900);
});
+
}
};

0 comments on commit e8f2678

Please sign in to comment.