~caneypuggies/reformedchurcheslocator/couchapp-backbone

« back to all changes in this revision

Viewing changes to _attachments/js/vendor/respond/test/unit/tests.js

  • Committer: Tim Black
  • Date: 2013-09-16 22:50:16 UTC
  • Revision ID: tim@alwaysreformed.com-20130916225016-zk8jiba25z33ew7h
Versioned Bower vendor directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 Respond.js unit tests - based on qUnit
 
3
*/
 
4
 
 
5
window.onload = function(){
 
6
 
 
7
        if( !window.opener ){
 
8
                        
 
9
                document.documentElement.className = "launcher";
 
10
                        
 
11
                document.getElementById("launcher").innerHTML = '<p>Tests must run in a popup window. <a href="suite.html" id="suitelink">Open test suite</a></p>';
 
12
                
 
13
                document.getElementById( "suitelink" ).onclick = function(){
 
14
                        window.open( location.href + "?" + Math.random(), 'win', 'width=800,height=600,scrollbars=1,resizable=1' );
 
15
                        return false;
 
16
                };
 
17
                
 
18
        }
 
19
        else {
 
20
                
 
21
                var testElem = document.getElementById("testelem");
 
22
 
 
23
                //check if a particular style has applied properly
 
24
                function widthApplied( val ){
 
25
                        return testElem.offsetWidth === val;
 
26
                }
 
27
                function heightApplied( val ){
 
28
                        return testElem.offsetHeight === val;
 
29
                }
 
30
                
 
31
                // A short snippet for detecting versions of IE in JavaScript - author: @padolsey
 
32
                var ie = (function(){
 
33
 
 
34
                    var undef,
 
35
                        v = 3,
 
36
                        div = document.createElement('div'),
 
37
                        all = div.getElementsByTagName('i');
 
38
    
 
39
                    while (
 
40
                        div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
 
41
                        all[0]
 
42
                    );
 
43
    
 
44
                    return v > 4 ? v : undef;
 
45
    
 
46
                }());
 
47
 
 
48
                window.moveTo(0,0);
 
49
                
 
50
                /* TESTS HERE */ 
 
51
                asyncTest( 'Styles not nested in media queries apply as expected', function() { 
 
52
                        window.resizeTo(200,600);
 
53
                        setTimeout(function(){
 
54
                                ok( widthApplied( 50 ), "testelem is 50px wide when window is 200px wide" );
 
55
                                start();
 
56
                        }, 900);        
 
57
                });
 
58
                
 
59
                asyncTest( 'styles within min-width media queries apply properly', function() { 
 
60
                        window.resizeTo(520,600);
 
61
                        setTimeout(function(){
 
62
                                ok( widthApplied( 150 ), 'testelem is 150px wide when window is 500px wide'  );
 
63
                                start();
 
64
                        }, 900);        
 
65
                });
 
66
                
 
67
                // This test is for a feature in IE7 and up
 
68
                if(  ie >= 7 ){
 
69
                        asyncTest( "attribute selectors still work (where supported) after respond runs its course", function() { 
 
70
                                window.resizeTo(520,600);
 
71
                                setTimeout(function(){
 
72
                                        ok( heightApplied( 200 ), "testelem is 200px tall when window is 500px wide" );
 
73
                                        start();
 
74
                                }, 900);        
 
75
                        });
 
76
                }
 
77
                
 
78
                
 
79
                asyncTest( 'styles within max-width media queries apply properly', function() { 
 
80
                        window.resizeTo(300,600);
 
81
                        setTimeout(function(){
 
82
                                ok( heightApplied( 150 ), 'testelem is 150px tall when window is under 480px wide'  );
 
83
                                start();
 
84
                        }, 900);        
 
85
                });
 
86
 
 
87
 
 
88
                
 
89
                asyncTest( 'min and max-width media queries that use EM units apply properly', function() { 
 
90
                        window.resizeTo(560,600);
 
91
                        setTimeout(function(){
 
92
                                ok( widthApplied( 12 ), 'testelem is 150px wide when window is 500px wide'  );
 
93
                                start();
 
94
                        }, 900);        
 
95
                });
 
96
                
 
97
                
 
98
                
 
99
                asyncTest( "styles within a min-width media query with an \"only\" keyword apply properly", function() { 
 
100
                        window.resizeTo(650,600);
 
101
                        setTimeout(function(){
 
102
                                ok( widthApplied( 250 ), "testelem is 250px wide when window is 650px wide" );
 
103
                                start();
 
104
                        }, 900);        
 
105
                });
 
106
                
 
107
                asyncTest( "styles within a media query with a one true query among other false queries apply properly", function() { 
 
108
                        window.resizeTo(800,600);
 
109
                        setTimeout(function(){
 
110
                                ok( widthApplied( 350 ), "testelem is 350px wide when window is 750px wide" );
 
111
                                start();
 
112
                        }, 900);        
 
113
                });
 
114
                
 
115
                
 
116
                
 
117
                asyncTest( "Styles within a false media query do not apply", function() { 
 
118
                        window.resizeTo(800,600);
 
119
                        setTimeout(function(){
 
120
                                ok( !widthApplied( 500 ), "testelem is not 500px wide when window is 800px wide" );
 
121
                                start();
 
122
 
 
123
                        }, 900);        
 
124
                });
 
125
                
 
126
                asyncTest( "stylesheets with a media query in a media attribute apply when they should", function() { 
 
127
                        window.resizeTo(1300,600);
 
128
                        setTimeout(function(){
 
129
                                ok( widthApplied( 16 ), "testelem is 16px wide when window is 1300px wide" );
 
130
                                start();
 
131
                        }, 900);        
 
132
                });
 
133
                
 
134
                asyncTest( "stylesheets with an EM-based media query in a media attribute apply when they should", function() { 
 
135
                        window.resizeTo(1500,600);
 
136
                        setTimeout(function(){
 
137
                                ok( widthApplied( 25 ), "testelem is 25px wide when window is > 1400px wide" );
 
138
                                start();
 
139
                        }, 900);        
 
140
                });
 
141
                
 
142
        }
 
143
        
 
144
};
 
 
b'\\ No newline at end of file'