/**
 * @fileoverview unit testing for fmd/request
 * @author Edgar
 * @date 131009
 * */

fmd( 'specs/request', ['request'], function( request ){
    describe( 'fmd/request', function(){
        
        var getStyle = function( node, name ){
            var ret;
            
            if ( window.getComputedStyle ){
                ret = getComputedStyle( node );
            } else {
                ret = node.currentStyle;
            }
            
            return ret[name];
        };
        
        var t = ( new Date() ).getTime();
        
        it( 'request js', function(){
            var a;
            
            runs(function(){
                request( {url:'/test/specs/request/a.js?'+t}, function(){
                    a = window.specsRequestA;
                } );
            });
            
            waitsFor(function(){
                return !!a;
            });
            
            runs(function(){
                expect(a).toEqual('specs-request-a');
            });
        } );
        
        describe( 'request css', function(){
            var el;
                
            beforeEach(function(){
                el = document.createElement('div');
                el.id = 'specs-request-a';
                document.body.appendChild( el );
            });
            
            afterEach(function(){
                document.body.removeChild( el );
            });
            
            it( 'request css', function(){
                var a;
                
                runs(function(){
                    request( {url:'/test/specs/request/a.css?'+t}, function(){
                        setTimeout(function(){
                            a = getStyle( el, 'color');
                        },200);
                    } );
                });
                
                waitsFor(function(){
                    return !!a;
                });
                
                runs(function(){
                    expect(a==='rgb(144, 40, 71)'||a==='#902847').toEqual(true);
                });
            } );
        } );
        
        describe( 'request css multiple', function(){
            var b, c;
                
            beforeEach(function(){
                b = document.createElement('div');
                c = document.createElement('div');
                b.id = 'specs-request-b';
                c.id = 'specs-request-c';
                document.body.appendChild( b );
                document.body.appendChild( c );
            });
            
            afterEach(function(){
                document.body.removeChild( b );
                document.body.removeChild( c );
            });
            
            it( 'request css multiple', function(){
                var a, d;
                
                runs(function(){
                    request( {url:'/test/specs/request/b.css?'+t}, function(){
                        setTimeout(function(){
                            a = getStyle( b, 'color');
                        },200);
                    } );
                    request( {url:'/test/specs/request/c.css?'+t}, function(){
                        setTimeout(function(){
                            d = getStyle( c, 'color');
                        },200);
                    } );
                });
                
                waitsFor(function(){
                    return !!a && !!d;
                });
                
                runs(function(){
                    expect(a==='rgb(88, 36, 56)'||a==='#582438').toEqual(true);
                    expect(d==='rgb(160, 48, 104)'||d==='#a03068').toEqual(true);
                });
            } );
        } );
        
    } );
} );

@@ -1722,34 +1722,48 @@
 le( el, 'color')
+.toLowerCase()
 ;%0A
-
                 
@@ -2002,28 +2002,31 @@
      expect(
-a
+ a 
 ===
+ 
 'rgb(144, 40
@@ -2031,22 +2031,26 @@
 40, 71)'
+ 
 %7C%7C
-a
+ a 
 ===
+ 
 '#902847
@@ -2050,16 +2050,17 @@
 #902847'
+ 
 ).toEqua
@@ -3023,32 +3023,47 @@
 tyle( b, 'color'
+ ).toLowerCase(
 );%0A             
@@ -3284,16 +3284,31 @@
  'color'
+ ).toLowerCase(
 );%0A     
@@ -3569,20 +3569,23 @@
  expect(
-a
+ a 
 ===
+ 
 'rgb(88,
@@ -3597,14 +3597,18 @@
 56)'
+ 
 %7C%7C
-a
+ a 
 ===
+ 
 '#58
@@ -3612,16 +3612,17 @@
 #582438'
+ 
 ).toEqua
@@ -3657,20 +3657,23 @@
  expect(
-d
+ d 
 ===
+ 
 'rgb(160
@@ -3687,14 +3687,18 @@
 04)'
+ 
 %7C%7C
-d
+ d 
 ===
+ 
 '#a0
@@ -3702,16 +3702,17 @@
 #a03068'
+ 
 ).toEqua

update request ut