Merge "SpecialMovepage: Convert form to use OOUI controls"
[lhc/web/wiklou.git] / tests / qunit / suites / resources / jquery / jquery.hidpi.test.js
1 ( function ( $ ) {
2 QUnit.module( 'jquery.hidpi', QUnit.newMwEnvironment() );
3
4 QUnit.test( 'devicePixelRatio', 1, function ( assert ) {
5 var devicePixelRatio = $.devicePixelRatio();
6 assert.equal( typeof devicePixelRatio, 'number', '$.devicePixelRatio() returns a number' );
7 } );
8
9 QUnit.test( 'bracketedDevicePixelRatio', 1, function ( assert ) {
10 var devicePixelRatio = $.devicePixelRatio();
11 assert.equal( typeof devicePixelRatio, 'number', '$.bracketedDevicePixelRatio() returns a number' );
12 } );
13
14 QUnit.test( 'bracketDevicePixelRatio', 8, function ( assert ) {
15 assert.equal( $.bracketDevicePixelRatio( 0.75 ), 1, '0.75 gives 1' );
16 assert.equal( $.bracketDevicePixelRatio( 1 ), 1, '1 gives 1' );
17 assert.equal( $.bracketDevicePixelRatio( 1.25 ), 1.5, '1.25 gives 1.5' );
18 assert.equal( $.bracketDevicePixelRatio( 1.5 ), 1.5, '1.5 gives 1.5' );
19 assert.equal( $.bracketDevicePixelRatio( 1.75 ), 2, '1.75 gives 2' );
20 assert.equal( $.bracketDevicePixelRatio( 2 ), 2, '2 gives 2' );
21 assert.equal( $.bracketDevicePixelRatio( 2.5 ), 2, '2.5 gives 2' );
22 assert.equal( $.bracketDevicePixelRatio( 3 ), 2, '3 gives 2' );
23 } );
24
25 QUnit.test( 'matchSrcSet', 6, function ( assert ) {
26 var srcset = 'onefive.png 1.5x, two.png 2x';
27
28 // Nice exact matches
29 assert.equal( $.matchSrcSet( 1, srcset ), null, '1.0 gives no match' );
30 assert.equal( $.matchSrcSet( 1.5, srcset ), 'onefive.png', '1.5 gives match' );
31 assert.equal( $.matchSrcSet( 2, srcset ), 'two.png', '2 gives match' );
32
33 // Non-exact matches; should return the next-biggest specified
34 assert.equal( $.matchSrcSet( 1.25, srcset ), null, '1.25 gives no match' );
35 assert.equal( $.matchSrcSet( 1.75, srcset ), 'onefive.png', '1.75 gives match to 1.5' );
36 assert.equal( $.matchSrcSet( 2.25, srcset ), 'two.png', '2.25 gives match to 2' );
37 } );
38 }( jQuery ) );