aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/css.js
diff options
context:
space:
mode:
authorRichard Gibson <richard.gibson@gmail.com>2015-03-16 23:05:36 -0400
committerRichard Gibson <richard.gibson@gmail.com>2015-03-16 23:05:36 -0400
commit48be675200e817f40fa8ec25da1be2ab0839d28d (patch)
tree86f52df8124a5066e593019eca9559b7faee97f5 /test/unit/css.js
parent7632b7454b8a918b5eb9ade199a6a842eae98571 (diff)
downloadjquery-48be675200e817f40fa8ec25da1be2ab0839d28d.tar.gz
jquery-48be675200e817f40fa8ec25da1be2ab0839d28d.zip
Tests: Fix CSS relative adjustment test for round-down browsers
Ref 9b03f6df88a8d9dbda3f7893cdd84e3a3c70da17
Diffstat (limited to 'test/unit/css.js')
-rw-r--r--test/unit/css.js26
1 files changed, 19 insertions, 7 deletions
diff --git a/test/unit/css.js b/test/unit/css.js
index d6b14eea2..e97e16d6b 100644
--- a/test/unit/css.js
+++ b/test/unit/css.js
@@ -208,13 +208,25 @@ test( "css() non-px relative values (gh-1711)", 17, function() {
units = {},
$child = jQuery( "#nothiddendivchild" ),
add = function( prop, val, unit ) {
- var str = ( val < 0 ? "-=" : "+=" ) + Math.abs( val ) + unit;
- $child.css( prop, str );
- equal(
- Math.round( parseFloat( $child.css( prop ) ) ),
- Math.round( cssCurrent += val * units[ prop ][ unit ] ),
- prop + ": '" + str + "'"
- );
+ var difference,
+ adjustment = ( val < 0 ? "-=" : "+=" ) + Math.abs( val ) + unit,
+ message = prop + ": " + adjustment,
+ cssOld = cssCurrent,
+ expected = cssOld + val * units[ prop ][ unit ];
+
+ // Apply change
+ $child.css( prop, adjustment );
+ cssCurrent = parseFloat( $child.css( prop ) );
+
+ // Require a difference of less than one pixel
+ difference = Math.abs( cssCurrent - expected );
+ if ( difference < 1 ) {
+ ok( true, message );
+
+ // ...or fail with actual and expected values
+ } else {
+ ok( false, message + " (actual " + cssCurrent + ", expected " + expected + ")" );
+ }
},
getUnits = function( prop ) {
units[ prop ] = {