Skip to content

Commit

Permalink
Used user agent matching similar to the one used in jQuery Migrate fo…
Browse files Browse the repository at this point in the history
…r testing #174
  • Loading branch information
pisi committed Feb 20, 2013
1 parent 43ed7c9 commit 23a1f51
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 6 deletions.
31 changes: 27 additions & 4 deletions test/unit/issues.js
Expand Up @@ -3,14 +3,37 @@
*/
(function($){

var
browser = (function( ua ) {
// Adapted from jQuery Migrate
// https://github.com/jquery/jquery-migrate/blob/master/src/core.js
var
match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
/(msie) ([\w.]+)/.exec( ua ) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
[],
browser = {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
}

if (browser.browser){
browser[browser.browser] = true;
}
return browser;

})(navigator.userAgent.toLowerCase())

module('Issues', reel_test_module_routine);

test( 'GH-4 Proper background positioning range for stitched non-looping panoramas', function(){
/* Github issue 4 bugfix
* http://github.com/pisi/Reel/issues/#issue/4
*/
var
iesaurus = $.browser.msie && +$.browser.version < 9, // Flag for IE 8- quirks
iesaurus = browser.msie && +browser.version < 9, // Flag for IE 8- quirks
stitched= 1652,
$pano= $('#stitched_nonlooping').reel({ stitched: stitched, loops: false }),
travel= stitched - parseInt($pano.css('width'))
Expand Down Expand Up @@ -38,7 +61,7 @@
* http://github.com/pisi/Reel/issues/#issue/6
*/
var
iesaurus = $.browser.msie && +$.browser.version < 9, // Flag for IE 8- quirks
iesaurus = browser.msie && +browser.version < 9, // Flag for IE 8- quirks
stitched= 1652,
$pano= $('#stitched_looping').reel({ stitched: stitched, loops: true }),
travel= stitched
Expand Down Expand Up @@ -123,8 +146,8 @@
var
protocol= $('#image').attr('src').split(':')[0],
dot= '.',
browser_version= +$.browser.version.split(dot).slice(0,2).join(dot),
ie= $.browser.msie
browser_version= +browser.version.split(dot).slice(0,2).join(dot),
ie= browser.msie

if (!ie || (ie && browser_version > 6)){
equal(protocol, 'data', 'Embedded transparent image.');
Expand Down
27 changes: 25 additions & 2 deletions test/unit/sprite.js
Expand Up @@ -3,12 +3,35 @@
*/
(function($){

var
browser = (function( ua ) {
// Adapted from jQuery Migrate
// https://github.com/jquery/jquery-migrate/blob/master/src/core.js
var
match = /(chrome)[ \/]([\w.]+)/.exec( ua ) ||
/(webkit)[ \/]([\w.]+)/.exec( ua ) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec( ua ) ||
/(msie) ([\w.]+)/.exec( ua ) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( ua ) ||
[],
browser = {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
}

if (browser.browser){
browser[browser.browser] = true;
}
return browser;

})(navigator.userAgent.toLowerCase())

module('Sprite', reel_test_module_routine);

test( 'Multi-row: Frame shifting (4 rows)', function(){

var
iesaurus = $.browser.msie && +$.browser.version < 9, // Flag for IE 8- quirks
iesaurus = browser.msie && +browser.version < 9, // Flag for IE 8- quirks
selector= '#image',
$reel= $(selector).reel({
frames: 6,
Expand Down Expand Up @@ -58,7 +81,7 @@

test( 'Multi-row: Uneven rows frame shifting (3 rows)', function(){
var
iesaurus = $.browser.msie && +$.browser.version < 9, // Flag for IE 8- quirks
iesaurus = browser.msie && +browser.version < 9, // Flag for IE 8- quirks
selector= '#image',
$reel= $(selector).reel({
frames: 6,
Expand Down

0 comments on commit 23a1f51

Please sign in to comment.