Index: trunk/phase3/tests/qunit/sample/awesome.js |
— | — | @@ -1,4 +1,4 @@ |
2 | 2 | window.mw.loader.testCallback = function(){ |
3 | 3 | start(); |
4 | | - deepEqual( true, true, 'Implementing a module, is the callback timed properly ?'); |
| 4 | + ok( true, 'Implementing a module, is the callback timed properly ?'); |
5 | 5 | }; |
Index: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.colorUtil.js |
— | — | @@ -1,73 +1,71 @@ |
2 | 2 | module( 'jquery.colorUtil.js' ); |
3 | 3 | |
4 | | -test( '-- Initial check', function(){ |
| 4 | +test( '-- Initial check', function() { |
5 | 5 | expect(1); |
6 | | - ok( jQuery.colorUtil, 'jQuery.colorUtil defined' ); |
| 6 | + ok( $.colorUtil, '$.colorUtil defined' ); |
7 | 7 | }); |
8 | 8 | |
9 | | -test( 'getRGB', function(){ |
| 9 | +test( 'getRGB', function() { |
10 | 10 | expect(18); |
11 | 11 | |
12 | | - equal( typeof jQuery.colorUtil.getRGB(), 'undefined', 'No arguments' ); |
13 | | - equal( typeof jQuery.colorUtil.getRGB( '' ), 'undefined', 'Empty string' ); |
14 | | - deepEqual( jQuery.colorUtil.getRGB( [0, 100, 255] ), [0, 100, 255], 'Array' ); |
15 | | - deepEqual( jQuery.colorUtil.getRGB( 'rgb(0,100,255)' ), [0, 100, 255], 'Parse simple string' ); |
16 | | - deepEqual( jQuery.colorUtil.getRGB( 'rgb(0, 100, 255)' ), [0, 100, 255], 'Parse simple string (whitespace)' ); |
17 | | - deepEqual( jQuery.colorUtil.getRGB( 'rgb(0%,20%,40%)' ), [0, 51, 102], 'Parse percentages string' ); |
18 | | - deepEqual( jQuery.colorUtil.getRGB( 'rgb(0%, 20%, 40%)' ), [0, 51, 102], 'Parse percentages string (whitespace)' ); |
19 | | - deepEqual( jQuery.colorUtil.getRGB( '#f2ddee' ), [242, 221, 238], 'Hex string: 6 char lowercase' ); |
20 | | - deepEqual( jQuery.colorUtil.getRGB( '#f2DDEE' ), [242, 221, 238], 'Hex string: 6 char uppercase' ); |
21 | | - deepEqual( jQuery.colorUtil.getRGB( '#f2DdEe' ), [242, 221, 238], 'Hex string: 6 char mixed' ); |
22 | | - deepEqual( jQuery.colorUtil.getRGB( '#eee' ), [238, 238, 238], 'Hex string: 3 char lowercase' ); |
23 | | - deepEqual( jQuery.colorUtil.getRGB( '#EEE' ), [238, 238, 238], 'Hex string: 3 char uppercase' ); |
24 | | - deepEqual( jQuery.colorUtil.getRGB( '#eEe' ), [238, 238, 238], 'Hex string: 3 char mixed' ); |
25 | | - deepEqual( jQuery.colorUtil.getRGB( 'rgba(0, 0, 0, 0)' ), [255, 255, 255], 'Zero rgba for Safari 3; Transparent (whitespace)' ); |
26 | | - // Perhaps this is a bug in colorUtil, but it is the current behaviour so, let's keep track |
27 | | - // would that ever change |
28 | | - equal( typeof jQuery.colorUtil.getRGB( 'rgba(0,0,0,0)' ), 'undefined', 'Zero rgba without whitespace' ); |
29 | | - |
30 | | - deepEqual( jQuery.colorUtil.getRGB( 'lightGreen' ), [144, 238, 144], 'Color names (lightGreen)' ); |
31 | | - deepEqual( jQuery.colorUtil.getRGB( 'lightGreen' ), [144, 238, 144], 'Color names (transparent)' ); |
32 | | - equal( typeof jQuery.colorUtil.getRGB( 'mediaWiki' ), 'undefined', 'Inexisting color name' ); |
| 12 | + strictEqual( $.colorUtil.getRGB(), undefined, 'No arguments' ); |
| 13 | + strictEqual( $.colorUtil.getRGB( '' ), undefined, 'Empty string' ); |
| 14 | + deepEqual( $.colorUtil.getRGB( [0, 100, 255] ), [0, 100, 255], 'Parse array of rgb values' ); |
| 15 | + deepEqual( $.colorUtil.getRGB( 'rgb(0,100,255)' ), [0, 100, 255], 'Parse simple rgb string' ); |
| 16 | + deepEqual( $.colorUtil.getRGB( 'rgb(0, 100, 255)' ), [0, 100, 255], 'Parse simple rgb string with spaces' ); |
| 17 | + deepEqual( $.colorUtil.getRGB( 'rgb(0%,20%,40%)' ), [0, 51, 102], 'Parse rgb string with percentages' ); |
| 18 | + deepEqual( $.colorUtil.getRGB( 'rgb(0%, 20%, 40%)' ), [0, 51, 102], 'Parse rgb string with percentages and spaces' ); |
| 19 | + deepEqual( $.colorUtil.getRGB( '#f2ddee' ), [242, 221, 238], 'Hex string: 6 char lowercase' ); |
| 20 | + deepEqual( $.colorUtil.getRGB( '#f2DDEE' ), [242, 221, 238], 'Hex string: 6 char uppercase' ); |
| 21 | + deepEqual( $.colorUtil.getRGB( '#f2DdEe' ), [242, 221, 238], 'Hex string: 6 char mixed' ); |
| 22 | + deepEqual( $.colorUtil.getRGB( '#eee' ), [238, 238, 238], 'Hex string: 3 char lowercase' ); |
| 23 | + deepEqual( $.colorUtil.getRGB( '#EEE' ), [238, 238, 238], 'Hex string: 3 char uppercase' ); |
| 24 | + deepEqual( $.colorUtil.getRGB( '#eEe' ), [238, 238, 238], 'Hex string: 3 char mixed' ); |
| 25 | + deepEqual( $.colorUtil.getRGB( 'rgba(0, 0, 0, 0)' ), [255, 255, 255], 'Zero rgba for Safari 3; Transparent (whitespace)' ); |
33 | 26 | |
| 27 | + // Perhaps this is a bug in colorUtil, but it is the current behaviour so, let's keep |
| 28 | + // track of it, so we will know in case it would ever change. |
| 29 | + strictEqual( $.colorUtil.getRGB( 'rgba(0,0,0,0)' ), undefined, 'Zero rgba without whitespace' ); |
| 30 | + |
| 31 | + deepEqual( $.colorUtil.getRGB( 'lightGreen' ), [144, 238, 144], 'Color names (lightGreen)' ); |
| 32 | + deepEqual( $.colorUtil.getRGB( 'lightGreen' ), [144, 238, 144], 'Color names (transparent)' ); |
| 33 | + strictEqual( $.colorUtil.getRGB( 'mediaWiki' ), undefined, 'Inexisting color name' ); |
34 | 34 | }); |
35 | 35 | |
36 | | -test( 'rgbToHsl', function(){ |
37 | | - expect(4); |
| 36 | +test( 'rgbToHsl', function() { |
| 37 | + expect(1); |
38 | 38 | |
39 | | - var hsl = jQuery.colorUtil.rgbToHsl( 144, 238, 144 ); |
| 39 | + var hsl = $.colorUtil.rgbToHsl( 144, 238, 144 ); |
| 40 | + |
| 41 | + // Cross-browser differences in decimals... |
| 42 | + // Round to two decimals so they can be more reliably checked. |
40 | 43 | var dualDecimals = function(a,b){ |
41 | 44 | return Math.round(a*100)/100; |
42 | 45 | }; |
| 46 | + // Re-create the rgbToHsl return array items, limited to two decimals. |
| 47 | + var ret = [dualDecimals(hsl[0]), dualDecimals(hsl[1]), dualDecimals(hsl[2])]; |
43 | 48 | |
44 | | - ok( hsl, 'Basic return evaluation' ); |
45 | | - deepEqual( dualDecimals(hsl[0]) , 0.33, 'rgb(144, 238, 144): H 0.33' ); |
46 | | - deepEqual( dualDecimals(hsl[1]) , 0.73, 'rgb(144, 238, 144): S 0.73' ); |
47 | | - deepEqual( dualDecimals(hsl[2]) , 0.75, 'rgb(144, 238, 144): L 0.75' ); |
48 | | - |
| 49 | + deepEqual( ret, [0.33, 0.73, 0.75], 'rgb(144, 238, 144): hsl(0.33, 0.73, 0.75)' ); |
49 | 50 | }); |
50 | 51 | |
51 | | -test( 'hslToRgb', function(){ |
52 | | - expect(4); |
| 52 | +test( 'hslToRgb', function() { |
| 53 | + expect(1); |
53 | 54 | |
54 | | - var rgb = jQuery.colorUtil.hslToRgb( 0.3, 0.7, 0.8 ); |
| 55 | + var rgb = $.colorUtil.hslToRgb( 0.3, 0.7, 0.8 ); |
55 | 56 | |
56 | | - ok( rgb, 'Basic return evaluation' ); |
57 | | - deepEqual( Math.round(rgb[0]) , 183, 'hsl(0.3, 0.7, 0.8): R 183' ); |
58 | | - deepEqual( Math.round(rgb[1]) , 240, 'hsl(0.3, 0.7, 0.8): G 240' ); |
59 | | - deepEqual( Math.round(rgb[2]) , 168, 'hsl(0.3, 0.7, 0.8): B 168' ); |
| 57 | + // Cross-browser differences in decimals... |
| 58 | + // Re-create the hslToRgb return array items, rounded to whole numbers. |
| 59 | + var ret = [Math.round(rgb[0]), Math.round(rgb[1]), Math.round(rgb[2])]; |
60 | 60 | |
| 61 | + deepEqual( ret ,[183, 240, 168], 'hsl(0.3, 0.7, 0.8): rgb(183, 240, 168)' ); |
61 | 62 | }); |
62 | 63 | |
63 | | -test( 'getColorBrightness', function(){ |
| 64 | +test( 'getColorBrightness', function() { |
64 | 65 | expect(2); |
65 | 66 | |
66 | | - var a = jQuery.colorUtil.getColorBrightness( 'red', +0.1 ); |
| 67 | + var a = $.colorUtil.getColorBrightness( 'red', +0.1 ); |
| 68 | + equal( a, 'rgb(255,50,50)', 'Start with named color "red", brighten 10%' ); |
67 | 69 | |
68 | | - equal( a, 'rgb(255,50,50)', 'Start with named color, brighten 10%' ); |
69 | | - |
70 | | - var b = jQuery.colorUtil.getColorBrightness( 'rgb(200,50,50)', -0.2 ); |
71 | | - |
72 | | - equal( b, 'rgb(118,29,29)', 'Start with rgb string, darken 10%' ); |
73 | | - |
| 70 | + var b = $.colorUtil.getColorBrightness( 'rgb(200,50,50)', -0.2 ); |
| 71 | + equal( b, 'rgb(118,29,29)', 'Start with rgb string "rgb(200,50,50)", darken 20%' ); |
74 | 72 | }); |
Index: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.mwPrototypes.js |
— | — | @@ -1,58 +1,56 @@ |
2 | 2 | module( 'jquery.mwPrototypes.js' ); |
3 | 3 | |
4 | | -test( 'String functions', function(){ |
| 4 | +test( 'String functions', function() { |
5 | 5 | |
6 | | - equal( $j.trimLeft( ' foo bar ' ), 'foo bar ', 'trimLeft' ); |
7 | | - equal( $j.trimRight( ' foo bar ' ), ' foo bar', 'trimRight' ); |
8 | | - equal( $j.ucFirst( 'foo'), 'Foo', 'ucFirst' ); |
| 6 | + equal( $.trimLeft( ' foo bar ' ), 'foo bar ', 'trimLeft' ); |
| 7 | + equal( $.trimRight( ' foo bar ' ), ' foo bar', 'trimRight' ); |
| 8 | + equal( $.ucFirst( 'foo'), 'Foo', 'ucFirst' ); |
9 | 9 | |
10 | | - equal( $j.escapeRE( '<!-- ([{+mW+}]) $^|?>' ), |
| 10 | + equal( $.escapeRE( '<!-- ([{+mW+}]) $^|?>' ), |
11 | 11 | '<!\\-\\- \\(\\[\\{\\+mW\\+\\}\\]\\) \\$\\^\\|\\?>', 'escapeRE - Escape specials' ); |
12 | | - equal( $j.escapeRE( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ), |
| 12 | + equal( $.escapeRE( 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ), |
13 | 13 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'escapeRE - Leave uppercase alone' ); |
14 | | - equal( $j.escapeRE( 'abcdefghijklmnopqrstuvwxyz' ), |
| 14 | + equal( $.escapeRE( 'abcdefghijklmnopqrstuvwxyz' ), |
15 | 15 | 'abcdefghijklmnopqrstuvwxyz', 'escapeRE - Leave lowercase alone' ); |
16 | | - equal( $j.escapeRE( '0123456789' ), '0123456789', 'escapeRE - Leave numbers alone' ); |
17 | | - |
| 16 | + equal( $.escapeRE( '0123456789' ), '0123456789', 'escapeRE - Leave numbers alone' ); |
18 | 17 | }); |
19 | 18 | |
20 | | -test( 'Is functions', function(){ |
| 19 | +test( 'Is functions', function() { |
21 | 20 | |
22 | | - deepEqual( $j.isDomElement( document.getElementById( 'qunit-header' ) ), true, |
| 21 | + strictEqual( $.isDomElement( document.getElementById( 'qunit-header' ) ), true, |
23 | 22 | 'isDomElement: #qunit-header Node' ); |
24 | | - deepEqual( $j.isDomElement( document.getElementById( 'random-name' ) ), false, |
| 23 | + strictEqual( $.isDomElement( document.getElementById( 'random-name' ) ), false, |
25 | 24 | 'isDomElement: #random-name (null)' ); |
26 | | - deepEqual( $j.isDomElement( document.getElementsByTagName( 'div' ) ), false, |
| 25 | + strictEqual( $.isDomElement( document.getElementsByTagName( 'div' ) ), false, |
27 | 26 | 'isDomElement: getElementsByTagName Array' ); |
28 | | - deepEqual( $j.isDomElement( document.getElementsByTagName( 'div' )[0] ), true, |
| 27 | + strictEqual( $.isDomElement( document.getElementsByTagName( 'div' )[0] ), true, |
29 | 28 | 'isDomElement: getElementsByTagName(..)[0] Node' ); |
30 | | - deepEqual( $j.isDomElement( $j( 'div' ) ), false, |
| 29 | + strictEqual( $.isDomElement( $( 'div' ) ), false, |
31 | 30 | 'isDomElement: jQuery object' ); |
32 | | - deepEqual( $j.isDomElement( $j( 'div' ).get(0) ), true, |
| 31 | + strictEqual( $.isDomElement( $( 'div' ).get(0) ), true, |
33 | 32 | 'isDomElement: jQuery object > Get node' ); |
34 | | - deepEqual( $j.isDomElement( document.createElement( 'div' ) ), true, |
| 33 | + strictEqual( $.isDomElement( document.createElement( 'div' ) ), true, |
35 | 34 | 'isDomElement: createElement' ); |
36 | | - deepEqual( $j.isDomElement( { foo: 1 } ), false, |
| 35 | + strictEqual( $.isDomElement( { foo: 1 } ), false, |
37 | 36 | 'isDomElement: Object' ); |
38 | 37 | |
39 | | - equal( $j.isEmpty( 'string' ), false, 'isEmptry: "string"' ); |
40 | | - equal( $j.isEmpty( '0' ), true, 'isEmptry: "0"' ); |
41 | | - equal( $j.isEmpty( [] ), true, 'isEmptry: []' ); |
42 | | - equal( $j.isEmpty( {} ), true, 'isEmptry: {}' ); |
43 | | - // Documented behaviour |
44 | | - equal( $j.isEmpty( { length: 0 } ), true, 'isEmptry: { length: 0 }' ); |
| 38 | + strictEqual( $.isEmpty( 'string' ), false, 'isEmptry: "string"' ); |
| 39 | + strictEqual( $.isEmpty( '0' ), true, 'isEmptry: "0"' ); |
| 40 | + strictEqual( $.isEmpty( [] ), true, 'isEmptry: []' ); |
| 41 | + strictEqual( $.isEmpty( {} ), true, 'isEmptry: {}' ); |
45 | 42 | |
| 43 | + // Documented behaviour |
| 44 | + strictEqual( $.isEmpty( { length: 0 } ), true, 'isEmptry: { length: 0 }' ); |
46 | 45 | }); |
47 | 46 | |
48 | | -test( 'Comparison functions', function(){ |
| 47 | +test( 'Comparison functions', function() { |
49 | 48 | |
50 | | - ok( $j.compareArray( [0, 'a', [], [2, 'b'] ], [0, "a", [], [2, "b"] ] ), |
| 49 | + ok( $.compareArray( [0, 'a', [], [2, 'b'] ], [0, "a", [], [2, "b"] ] ), |
51 | 50 | 'compareArray: Two deep arrays that are excactly the same' ); |
52 | | - ok( !$j.compareArray( [1], [2] ), 'compareArray: Two different arrays (false)' ); |
| 51 | + ok( !$.compareArray( [1], [2] ), 'compareArray: Two different arrays (false)' ); |
53 | 52 | |
54 | | - ok( $j.compareObject( {}, {} ), 'compareObject: Two empty objects' ); |
55 | | - ok( $j.compareObject( { foo: 1 }, { foo: 1 } ), 'compareObject: Two the same objects' ); |
56 | | - ok( !$j.compareObject( { bar: true }, { baz: false } ), |
| 53 | + ok( $.compareObject( {}, {} ), 'compareObject: Two empty objects' ); |
| 54 | + ok( $.compareObject( { foo: 1 }, { foo: 1 } ), 'compareObject: Two the same objects' ); |
| 55 | + ok( !$.compareObject( { bar: true }, { baz: false } ), |
57 | 56 | 'compareObject: Two different objects (false)' ); |
58 | | - |
59 | | -}); |
\ No newline at end of file |
| 57 | +}); |
Index: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.autoEllipsis.js |
— | — | @@ -1,8 +1,8 @@ |
2 | 2 | module( 'jquery.autoEllipsis.js' ); |
3 | 3 | |
4 | | -test( '-- Initial check', function(){ |
| 4 | +test( '-- Initial check', function() { |
5 | 5 | expect(1); |
6 | | - ok( jQuery.fn.autoEllipsis, 'jQuery.fn.autoEllipsis defined' ); |
| 6 | + ok( $.fn.autoEllipsis, 'jQuery.fn.autoEllipsis defined' ); |
7 | 7 | }); |
8 | 8 | |
9 | 9 | function createWrappedDiv( text ) { |
— | — | @@ -31,11 +31,11 @@ |
32 | 32 | |
33 | 33 | // Verify that, and only one, span element was created |
34 | 34 | var $span = $wrapper.find( '> span' ); |
35 | | - deepEqual( $span.length, 1, 'autoEllipsis wrapped the contents in a span element' ); |
| 35 | + strictEqual( $span.length, 1, 'autoEllipsis wrapped the contents in a span element' ); |
36 | 36 | |
37 | 37 | // Check that the text fits by turning on word wrapping |
38 | 38 | $span.css( 'whiteSpace', 'nowrap' ); |
39 | | - deepEqual( $span.width() <= $span.parent().width(), true, "Text fits (span's width is no larger than its parent's width)" ); |
| 39 | + strictEqual( $span.width() <= $span.parent().width(), true, "Text fits (span's width is no larger than its parent's width)" ); |
40 | 40 | |
41 | 41 | // Add one character using scary black magic |
42 | 42 | var spanText = $span.text(); |
— | — | @@ -44,7 +44,7 @@ |
45 | 45 | |
46 | 46 | // Put this text in the span and verify it doesn't fit |
47 | 47 | $span.text( spanText ); |
48 | | - deepEqual( $span.width() > $span.parent().width(), true, 'Fit is maximal (adding one character makes it not fit any more)' ); |
| 48 | + strictEqual( $span.width() > $span.parent().width(), true, 'Fit is maximal (adding one character makes it not fit any more)' ); |
49 | 49 | |
50 | 50 | // Clean up |
51 | 51 | $wrapper.remove(); |
Index: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.client.js |
— | — | @@ -1,28 +1,27 @@ |
2 | 2 | module( 'jquery.client.js' ); |
3 | 3 | |
4 | | -test( '-- Initial check', function(){ |
| 4 | +test( '-- Initial check', function() { |
5 | 5 | expect(1); |
6 | 6 | ok( jQuery.client, 'jQuery.client defined' ); |
7 | 7 | }); |
8 | 8 | |
9 | | -test( 'profile', function(){ |
| 9 | +test( 'profile', function() { |
10 | 10 | expect(7); |
11 | 11 | var p = $.client.profile(); |
12 | | - var unk = 'unknown'; |
13 | | - var unkOrType = function( val, type ) { |
14 | | - return typeof val === type || val === unk; |
| 12 | + var unknownOrType = function( val, type, summary ) { |
| 13 | + return ok( typeof val === type || val === 'unknown', summary ); |
15 | 14 | }; |
16 | 15 | |
17 | | - equal( typeof p, 'object', 'profile() returns an object' ); |
18 | | - ok( unkOrType( p.layout, 'string' ), 'p.layout is a string (or "unknown")' ); |
19 | | - ok( unkOrType( p.layoutVersion, 'number' ), 'p.layoutVersion is a number (or "unknown")' ); |
20 | | - ok( unkOrType( p.platform, 'string' ), 'p.platform is a string (or "unknown")' ); |
21 | | - ok( unkOrType( p.version, 'string' ), 'p.version is a string (or "unknown")' ); |
22 | | - ok( unkOrType( p.versionBase, 'string' ), 'p.versionBase is a string (or "unknown")' ); |
| 16 | + equal( typeof p, 'object', 'profile returns an object' ); |
| 17 | + unknownOrType( p.layout, 'string', 'p.layout is a string (or "unknown")' ); |
| 18 | + unknownOrType( p.layoutVersion, 'number', 'p.layoutVersion is a number (or "unknown")' ); |
| 19 | + unknownOrType( p.platform, 'string', 'p.platform is a string (or "unknown")' ); |
| 20 | + unknownOrType( p.version, 'string', 'p.version is a string (or "unknown")' ); |
| 21 | + unknownOrType( p.versionBase, 'string', 'p.versionBase is a string (or "unknown")' ); |
23 | 22 | equal( typeof p.versionNumber, 'number', 'p.versionNumber is a number' ); |
24 | 23 | }); |
25 | 24 | |
26 | | -test( 'test', function(){ |
| 25 | +test( 'test', function() { |
27 | 26 | expect(1); |
28 | 27 | |
29 | 28 | // Example from WikiEditor |
— | — | @@ -54,6 +53,6 @@ |
55 | 54 | // then do a basic return value type check |
56 | 55 | var testMatch = $.client.test( testMap ); |
57 | 56 | |
58 | | - equal( typeof testMatch, 'boolean', 'test() returns a boolean value' ); |
| 57 | + equal( typeof testMatch, 'boolean', 'test returns a boolean value' ); |
59 | 58 | |
60 | 59 | }); |
Index: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.tabIndex.js |
— | — | @@ -1,53 +1,50 @@ |
2 | 2 | module( 'jquery.tabIndex.js' ); |
3 | 3 | |
4 | | -test( '-- Initial check', function(){ |
| 4 | +test( '-- Initial check', function() { |
5 | 5 | expect(2); |
6 | 6 | |
7 | 7 | ok( $.fn.firstTabIndex, '$.fn.firstTabIndex defined' ); |
8 | 8 | ok( $.fn.lastTabIndex, '$.fn.lastTabIndex defined' ); |
9 | | - |
10 | 9 | }); |
11 | 10 | |
12 | | -test( 'firstTabIndex', function(){ |
| 11 | +test( 'firstTabIndex', function() { |
13 | 12 | expect(2); |
14 | 13 | |
15 | | - var testEnvironment = |
| 14 | + var testEnvironment = |
16 | 15 | '<form>' + |
17 | 16 | '<input tabindex="7" />' + |
18 | 17 | '<input tabindex="9" />' + |
19 | 18 | '<textarea tabindex="2">Foobar</textarea>' + |
20 | 19 | '<textarea tabindex="5">Foobar</textarea>' + |
21 | 20 | '</form>'; |
22 | | - var $testA = $( '<div />' ).html( testEnvironment ).appendTo( 'body' ); |
23 | 21 | |
24 | | - deepEqual( $testA.firstTabIndex(), 2, 'First tabindex should be 2 within this context.' ); |
| 22 | + var $testA = $( '<div>' ).html( testEnvironment ).appendTo( 'body' ); |
| 23 | + strictEqual( $testA.firstTabIndex(), 2, 'First tabindex should be 2 within this context.' ); |
25 | 24 | |
26 | | - var $testB = $( '<div />' ); |
| 25 | + var $testB = $( '<div>' ); |
| 26 | + strictEqual( $testB.firstTabIndex(), null, 'Return null if none available.' ); |
27 | 27 | |
28 | | - deepEqual( $testB.firstTabIndex(), null, 'Return null if none available.' ); |
29 | | - |
30 | 28 | // Clean up |
31 | | - $testA.add( $testB).remove(); |
| 29 | + $testA.add( $testB ).remove(); |
32 | 30 | }); |
33 | 31 | |
34 | | -test( 'lastTabIndex', function(){ |
| 32 | +test( 'lastTabIndex', function() { |
35 | 33 | expect(2); |
36 | 34 | |
37 | | - var testEnvironment = |
| 35 | + var testEnvironment = |
38 | 36 | '<form>' + |
39 | 37 | '<input tabindex="7" />' + |
40 | 38 | '<input tabindex="9" />' + |
41 | 39 | '<textarea tabindex="2">Foobar</textarea>' + |
42 | 40 | '<textarea tabindex="5">Foobar</textarea>' + |
43 | 41 | '</form>'; |
44 | | - var $testA = $( '<div />' ).html( testEnvironment ).appendTo( 'body' ); |
45 | 42 | |
46 | | - deepEqual( $testA.lastTabIndex(), 9, 'Last tabindex should be 9 within this context.' ); |
| 43 | + var $testA = $( '<div>' ).html( testEnvironment ).appendTo( 'body' ); |
| 44 | + strictEqual( $testA.lastTabIndex(), 9, 'Last tabindex should be 9 within this context.' ); |
47 | 45 | |
48 | | - var $testB = $( '<div />' ); |
| 46 | + var $testB = $( '<div>' ); |
| 47 | + strictEqual( $testB.lastTabIndex(), null, 'Return null if none available.' ); |
49 | 48 | |
50 | | - deepEqual( $testB.lastTabIndex(), null, 'Return null if none available.' ); |
51 | | - |
52 | 49 | // Clean up |
53 | | - $testA.add( $testB).remove(); |
54 | | -}); |
\ No newline at end of file |
| 50 | + $testA.add( $testB ).remove(); |
| 51 | +}); |
Index: trunk/phase3/tests/qunit/suites/resources/mediawiki.util/mediawiki.util.js |
— | — | @@ -1,39 +1,38 @@ |
2 | 2 | module( 'mediawiki.util.js' ); |
3 | 3 | |
4 | | -test( '-- Initial check', function(){ |
| 4 | +test( '-- Initial check', function() { |
| 5 | + expect(1); |
5 | 6 | |
6 | 7 | ok( mw.util, 'mw.util defined' ); |
7 | | - |
8 | 8 | }); |
9 | 9 | |
10 | | -test( 'rawurlencode', function(){ |
| 10 | +test( 'rawurlencode', function() { |
| 11 | + expect(1); |
11 | 12 | |
12 | 13 | equal( mw.util.rawurlencode( 'Test:A & B/Here' ), 'Test%3AA%20%26%20B%2FHere' ); |
13 | | - |
14 | 14 | }); |
15 | 15 | |
16 | | -test( 'wikiUrlencode', function(){ |
| 16 | +test( 'wikiUrlencode', function() { |
| 17 | + expect(1); |
17 | 18 | |
18 | 19 | equal( mw.util.wikiUrlencode( 'Test:A & B/Here' ), 'Test:A_%26_B/Here' ); |
19 | | - |
20 | 20 | }); |
21 | 21 | |
22 | | -test( 'wikiGetlink', function(){ |
| 22 | +test( 'wikiGetlink', function() { |
| 23 | + expect(2); |
23 | 24 | |
24 | 25 | // Not part of startUp module |
25 | 26 | mw.config.set( 'wgArticlePath', '/wiki/$1' ); |
26 | 27 | |
27 | 28 | var hrefA = mw.util.wikiGetlink( 'Sandbox' ); |
28 | | - |
29 | 29 | equal( hrefA, '/wiki/Sandbox', 'Simple title; Get link for "Sandbox"' ); |
30 | 30 | |
31 | 31 | var hrefB = mw.util.wikiGetlink( 'Foo:Sandbox ? 5+5=10 ! (test)/subpage' ); |
32 | | - |
33 | | - equal( hrefB, '/wiki/Foo:Sandbox_%3F_5%2B5%3D10_%21_%28test%29/subpage', 'Advanced title; Get link for "Foo:Sandbox ? 5+5=10 ! (test)/subpage"' ); |
34 | | - |
| 32 | + equal( hrefB, '/wiki/Foo:Sandbox_%3F_5%2B5%3D10_%21_%28test%29/subpage', |
| 33 | + 'Advanced title; Get link for "Foo:Sandbox ? 5+5=10 ! (test)/subpage"' ); |
35 | 34 | }); |
36 | 35 | |
37 | | -test( 'wikiScript', function(){ |
| 36 | +test( 'wikiScript', function() { |
38 | 37 | expect(2); |
39 | 38 | |
40 | 39 | mw.config.set({ |
— | — | @@ -43,26 +42,28 @@ |
44 | 43 | }); |
45 | 44 | |
46 | 45 | equal( mw.util.wikiScript(), mw.config.get( 'wgScript' ), 'Defaults to index.php and is equal to wgScript' ); |
47 | | - deepEqual( mw.util.wikiScript( 'api' ), '/w/api.php' ); |
| 46 | + equal( mw.util.wikiScript( 'api' ), '/w/api.php', 'API path' ); |
48 | 47 | |
49 | 48 | }); |
50 | 49 | |
51 | | -test( 'addCSS', function(){ |
| 50 | +test( 'addCSS', function() { |
52 | 51 | expect(3); |
53 | 52 | |
54 | 53 | var a = mw.util.addCSS( '#bodyContent { visibility: hidden; }' ); |
55 | | - ok( a, 'function works' ); |
56 | | - deepEqual( a.disabled, false, 'property "disabled" is available and set to false' ); |
| 54 | + ok( a instanceof CSSStyleSheet, 'Object is an instance of CSSStyleSheet' ); |
| 55 | + strictEqual( a.disabled, false, 'property "disabled" is available and set to false' ); |
57 | 56 | |
58 | 57 | var $b = $('#bodyContent'); |
59 | 58 | equal( $b.css('visibility'), 'hidden', 'Added style properties are in effect' ); |
60 | 59 | |
| 60 | + // Clean up |
| 61 | + $( a.ownerNode ).remove(); |
61 | 62 | }); |
62 | 63 | |
63 | | -test( 'toggleToc', function(){ |
| 64 | +test( 'toggleToc', function() { |
64 | 65 | expect(3); |
65 | 66 | |
66 | | - deepEqual( mw.util.toggleToc(), null, 'Return null if there is no table of contents on the page.' ); |
| 67 | + strictEqual( mw.util.toggleToc(), null, 'Return null if there is no table of contents on the page.' ); |
67 | 68 | |
68 | 69 | var tocHtml = |
69 | 70 | '<table id="toc" class="toc"><tr><td>' + |
— | — | @@ -71,7 +72,7 @@ |
72 | 73 | '<span class="toctoggle"> [<a href="#" class="internal" id="togglelink">Hide</a> ]</span>' + |
73 | 74 | '</div>' + |
74 | 75 | '<ul><li></li></ul>' + |
75 | | - '</td></tr></table>'; |
| 76 | + '</td></tr></table>'; |
76 | 77 | var $toc = $(tocHtml).appendTo( 'body' ); |
77 | 78 | var $toggleLink = $( '#togglelink' ); |
78 | 79 | |
— | — | @@ -79,49 +80,48 @@ |
80 | 81 | // QUnit should not finish this test() untill they are all done |
81 | 82 | stop(); |
82 | 83 | |
83 | | - var actionC = function(){ |
| 84 | + var actionC = function() { |
84 | 85 | start(); |
85 | 86 | |
86 | 87 | // Clean up |
87 | 88 | $toc.remove(); |
88 | 89 | }; |
89 | | - var actionB = function(){ |
90 | | - deepEqual( mw.util.toggleToc( $toggleLink, actionC ), true, 'Return boolean true if the TOC is now visible.' ); |
| 90 | + var actionB = function() { |
| 91 | + strictEqual( mw.util.toggleToc( $toggleLink, actionC ), true, 'Return boolean true if the TOC is now visible.' ); |
91 | 92 | }; |
92 | | - var actionA = function(){ |
93 | | - deepEqual( mw.util.toggleToc( $toggleLink, actionB ), false, 'Return boolean false if the TOC is now hidden.' ); |
| 93 | + var actionA = function() { |
| 94 | + strictEqual( mw.util.toggleToc( $toggleLink, actionB ), false, 'Return boolean false if the TOC is now hidden.' ); |
94 | 95 | }; |
95 | | - |
| 96 | + |
96 | 97 | actionA(); |
97 | | - |
98 | | - |
99 | 98 | }); |
100 | 99 | |
101 | | -test( 'getParamValue', function(){ |
| 100 | +test( 'getParamValue', function() { |
| 101 | + expect(2); |
102 | 102 | |
103 | 103 | var url = 'http://mediawiki.org/?foo=wrong&foo=right#&foo=bad'; |
104 | 104 | |
105 | 105 | equal( mw.util.getParamValue( 'foo', url ), 'right', 'Use latest one, ignore hash' ); |
106 | | - deepEqual( mw.util.getParamValue( 'bar', url ), null, 'Return null when not found' ); |
107 | | - |
| 106 | + strictEqual( mw.util.getParamValue( 'bar', url ), null, 'Return null when not found' ); |
108 | 107 | }); |
109 | 108 | |
110 | | -test( 'tooltipAccessKey', function(){ |
| 109 | +test( 'tooltipAccessKey', function() { |
| 110 | + expect(3); |
111 | 111 | |
112 | 112 | equal( typeof mw.util.tooltipAccessKeyPrefix, 'string', 'mw.util.tooltipAccessKeyPrefix must be a string' ); |
113 | 113 | ok( mw.util.tooltipAccessKeyRegexp instanceof RegExp, 'mw.util.tooltipAccessKeyRegexp instance of RegExp' ); |
114 | 114 | ok( mw.util.updateTooltipAccessKeys, 'mw.util.updateTooltipAccessKeys' ); |
115 | | - |
116 | 115 | }); |
117 | 116 | |
118 | | -test( '$content', function(){ |
| 117 | +test( '$content', function() { |
| 118 | + expect(2); |
119 | 119 | |
120 | 120 | ok( mw.util.$content instanceof jQuery, 'mw.util.$content instance of jQuery' ); |
121 | | - deepEqual( mw.util.$content.length, 1, 'mw.util.$content must have length of 1' ); |
122 | | - |
| 121 | + strictEqual( mw.util.$content.length, 1, 'mw.util.$content must have length of 1' ); |
123 | 122 | }); |
124 | 123 | |
125 | | -test( 'addPortletLink', function(){ |
| 124 | +test( 'addPortletLink', function() { |
| 125 | + expect(5); |
126 | 126 | |
127 | 127 | var A = mw.util.addPortletLink( 'p-tb', 'http://mediawiki.org/wiki/ResourceLoader', |
128 | 128 | 'ResourceLoader', 't-rl', 'More info about ResourceLoader on MediaWiki.org ', 'l', '#t-specialpages' ); |
— | — | @@ -142,55 +142,124 @@ |
143 | 143 | |
144 | 144 | // Clean up |
145 | 145 | $( [A, B, C] ).remove(); |
146 | | - |
147 | 146 | }); |
148 | 147 | |
149 | | -test( 'jsMessage', function(){ |
| 148 | +test( 'jsMessage', function() { |
| 149 | + expect(1); |
150 | 150 | |
151 | 151 | var a = mw.util.jsMessage( "MediaWiki is <b>Awesome</b>." ); |
152 | | - |
153 | 152 | ok( a, 'Basic checking of return value' ); |
154 | 153 | |
155 | 154 | // Clean up |
156 | 155 | $( '#mw-js-message' ).remove(); |
157 | | - |
158 | 156 | }); |
159 | 157 | |
160 | | -test( 'validateEmail', function(){ |
| 158 | +test( 'validateEmail', function() { |
161 | 159 | expect(6); |
162 | 160 | |
163 | | - deepEqual( mw.util.validateEmail( "" ), null, 'Should return null for empty string ' ); |
164 | | - deepEqual( mw.util.validateEmail( "user@localhost" ), true, 'Return true for a valid e-mail address' ); |
| 161 | + strictEqual( mw.util.validateEmail( "" ), null, 'Should return null for empty string ' ); |
| 162 | + strictEqual( mw.util.validateEmail( "user@localhost" ), true, 'Return true for a valid e-mail address' ); |
165 | 163 | |
166 | 164 | // testEmailWithCommasAreInvalids |
167 | | - deepEqual( mw.util.validateEmail( "user,foo@example.org" ), false, 'Emails with commas are invalid' ); |
168 | | - deepEqual( mw.util.validateEmail( "userfoo@ex,ample.org" ), false, 'Emails with commas are invalid' ); |
| 165 | + strictEqual( mw.util.validateEmail( "user,foo@example.org" ), false, 'Emails with commas are invalid' ); |
| 166 | + strictEqual( mw.util.validateEmail( "userfoo@ex,ample.org" ), false, 'Emails with commas are invalid' ); |
169 | 167 | |
170 | 168 | // testEmailWithHyphens |
171 | | - deepEqual( mw.util.validateEmail( "user-foo@example.org" ), true, 'Emails may contain a hyphen' ); |
172 | | - deepEqual( mw.util.validateEmail( "userfoo@ex-ample.org" ), true, 'Emails may contain a hyphen' ); |
173 | | - |
| 169 | + strictEqual( mw.util.validateEmail( "user-foo@example.org" ), true, 'Emails may contain a hyphen' ); |
| 170 | + strictEqual( mw.util.validateEmail( "userfoo@ex-ample.org" ), true, 'Emails may contain a hyphen' ); |
174 | 171 | }); |
175 | 172 | |
176 | | -test( 'isIPv6Address', function(){ |
177 | | - expect(6); |
| 173 | +test( 'isIPv6Address', function() { |
| 174 | + expect(40); |
178 | 175 | |
179 | | - // Based on IPTest.php > IPv6 |
180 | | - deepEqual( mw.util.isIPv6Address( "" ), false, 'Empty string is not an IP' ); |
181 | | - deepEqual( mw.util.isIPv6Address( ":fc:100::" ), false, 'IPv6 starting with lone ":"' ); |
182 | | - deepEqual( mw.util.isIPv6Address( "fc:100::" ), true ); |
183 | | - deepEqual( mw.util.isIPv6Address( "fc:100:a:d:1:e:ac::" ), true ); |
184 | | - deepEqual( mw.util.isIPv6Address( ":::" ), false ); |
185 | | - deepEqual( mw.util.isIPv6Address( "::0:" ), false ); |
| 176 | + // Shortcuts |
| 177 | + var assertFalseIPv6 = function( addy, summary ) { |
| 178 | + return strictEqual( mw.util.isIPv6Address( addy ), false, summary ); |
| 179 | + }, |
| 180 | + assertTrueIPv6 = function( addy, summary ) { |
| 181 | + return strictEqual( mw.util.isIPv6Address( addy ), true, summary ); |
| 182 | + }; |
186 | 183 | |
| 184 | + // Based on IPTest.php > testisIPv6 |
| 185 | + assertFalseIPv6( ':fc:100::', 'IPv6 starting with lone ":"' ); |
| 186 | + assertFalseIPv6( 'fc:100:::', 'IPv6 ending with a ":::"' ); |
| 187 | + assertFalseIPv6( 'fc:300', 'IPv6 with only 2 words' ); |
| 188 | + assertFalseIPv6( 'fc:100:300', 'IPv6 with only 3 words' ); |
| 189 | + |
| 190 | + $.each( |
| 191 | + ['fc:100::', |
| 192 | + 'fc:100:a::', |
| 193 | + 'fc:100:a:d::', |
| 194 | + 'fc:100:a:d:1::', |
| 195 | + 'fc:100:a:d:1:e::', |
| 196 | + 'fc:100:a:d:1:e:ac::'], function( i, addy ){ |
| 197 | + assertTrueIPv6( addy, addy + ' is a valid IP' ); |
| 198 | + }); |
| 199 | + |
| 200 | + assertFalseIPv6( 'fc:100:a:d:1:e:ac:0::', 'IPv6 with 8 words ending with "::"' ); |
| 201 | + assertFalseIPv6( 'fc:100:a:d:1:e:ac:0:1::', 'IPv6 with 9 words ending with "::"' ); |
| 202 | + |
| 203 | + assertFalseIPv6( ':::' ); |
| 204 | + assertFalseIPv6( '::0:', 'IPv6 ending in a lone ":"' ); |
| 205 | + |
| 206 | + assertTrueIPv6( '::', 'IPv6 zero address' ); |
| 207 | + $.each( |
| 208 | + ['::0', |
| 209 | + '::fc', |
| 210 | + '::fc:100', |
| 211 | + '::fc:100:a', |
| 212 | + '::fc:100:a:d', |
| 213 | + '::fc:100:a:d:1', |
| 214 | + '::fc:100:a:d:1:e', |
| 215 | + '::fc:100:a:d:1:e:ac', |
| 216 | + |
| 217 | + 'fc:100:a:d:1:e:ac:0'], function( i, addy ){ |
| 218 | + assertTrueIPv6( addy, addy + ' is a valid IP' ); |
| 219 | + }); |
| 220 | + |
| 221 | + assertFalseIPv6( '::fc:100:a:d:1:e:ac:0', 'IPv6 with "::" and 8 words' ); |
| 222 | + assertFalseIPv6( '::fc:100:a:d:1:e:ac:0:1', 'IPv6 with 9 words' ); |
| 223 | + |
| 224 | + assertFalseIPv6( ':fc::100', 'IPv6 starting with lone ":"' ); |
| 225 | + assertFalseIPv6( 'fc::100:', 'IPv6 ending with lone ":"' ); |
| 226 | + assertFalseIPv6( 'fc:::100', 'IPv6 with ":::" in the middle' ); |
| 227 | + |
| 228 | + assertTrueIPv6( 'fc::100', 'IPv6 with "::" and 2 words' ); |
| 229 | + assertTrueIPv6( 'fc::100:a', 'IPv6 with "::" and 3 words' ); |
| 230 | + assertTrueIPv6( 'fc::100:a:d', 'IPv6 with "::" and 4 words' ); |
| 231 | + assertTrueIPv6( 'fc::100:a:d:1', 'IPv6 with "::" and 5 words' ); |
| 232 | + assertTrueIPv6( 'fc::100:a:d:1:e', 'IPv6 with "::" and 6 words' ); |
| 233 | + assertTrueIPv6( 'fc::100:a:d:1:e:ac', 'IPv6 with "::" and 7 words' ); |
| 234 | + assertTrueIPv6( '2001::df', 'IPv6 with "::" and 2 words' ); |
| 235 | + assertTrueIPv6( '2001:5c0:1400:a::df', 'IPv6 with "::" and 5 words' ); |
| 236 | + assertTrueIPv6( '2001:5c0:1400:a::df:2', 'IPv6 with "::" and 6 words' ); |
| 237 | + |
| 238 | + assertFalseIPv6( 'fc::100:a:d:1:e:ac:0', 'IPv6 with "::" and 8 words' ); |
| 239 | + assertFalseIPv6( 'fc::100:a:d:1:e:ac:0:1', 'IPv6 with 9 words' ); |
187 | 240 | }); |
188 | 241 | |
189 | | -test( 'isIPv4Address', function(){ |
190 | | - expect(3); |
| 242 | +test( 'isIPv4Address', function() { |
| 243 | + expect(11); |
191 | 244 | |
192 | | - // Based on IPTest.php > IPv4 |
193 | | - deepEqual( mw.util.isIPv4Address( "" ), false, 'Empty string is not an IP' ); |
194 | | - deepEqual( mw.util.isIPv4Address( "...." ), false ); |
195 | | - deepEqual( mw.util.isIPv4Address( "1.24.52.13" ), true ); |
| 245 | + // Shortcuts |
| 246 | + var assertFalseIPv4 = function( addy, summary ) { |
| 247 | + return strictEqual( mw.util.isIPv4Address( addy ), false, summary ); |
| 248 | + }, |
| 249 | + assertTrueIPv4 = function( addy, summary ) { |
| 250 | + return strictEqual( mw.util.isIPv4Address( addy ), true, summary ); |
| 251 | + }; |
196 | 252 | |
| 253 | + // Based on IPTest.php > testisIPv4 |
| 254 | + assertFalseIPv4( false, 'Boolean false is not an IP' ); |
| 255 | + assertFalseIPv4( true, 'Boolean true is not an IP' ); |
| 256 | + assertFalseIPv4( '', 'Empty string is not an IP' ); |
| 257 | + assertFalseIPv4( 'abc', '"abc" is not an IP' ); |
| 258 | + assertFalseIPv4( ':', 'Colon is not an IP' ); |
| 259 | + assertFalseIPv4( '124.24.52', 'IPv4 not enough quads' ); |
| 260 | + assertFalseIPv4( '24.324.52.13', 'IPv4 out of range' ); |
| 261 | + assertFalseIPv4( '.24.52.13', 'IPv4 starts with period' ); |
| 262 | + |
| 263 | + assertTrueIPv4( '124.24.52.13', '124.24.52.134 is a valid IP' ); |
| 264 | + assertTrueIPv4( '1.24.52.13', '1.24.52.13 is a valid IP' ); |
| 265 | + assertFalseIPv4( '74.24.52.13/20', 'IPv4 ranges are not recogzized as valid IPs' ); |
197 | 266 | }); |
Index: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.user.js |
— | — | @@ -1,30 +1,29 @@ |
2 | 2 | module( 'mediawiki.user.js' ); |
3 | 3 | |
4 | | -test( '-- Initial check', function(){ |
| 4 | +test( '-- Initial check', function() { |
| 5 | + expect(1); |
5 | 6 | |
6 | 7 | ok( mw.user, 'mw.user defined' ); |
7 | | - |
8 | 8 | }); |
9 | 9 | |
10 | 10 | |
11 | | -test( 'options', function(){ |
| 11 | +test( 'options', function() { |
| 12 | + expect(1); |
12 | 13 | |
13 | 14 | ok( mw.user.options instanceof mw.Map, 'options instance of mw.Map' ); |
14 | | - |
15 | 15 | }); |
16 | 16 | |
17 | | -test( 'User login status', function(){ |
| 17 | +test( 'User login status', function() { |
| 18 | + expect(5); |
18 | 19 | |
19 | | - deepEqual( mw.user.name(), null, 'user.name() When anonymous' ); |
20 | | - ok( mw.user.anonymous(), 'user.anonymous() When anonymous' ); |
| 20 | + strictEqual( mw.user.name(), null, 'user.name should return null when anonymous' ); |
| 21 | + ok( mw.user.anonymous(), 'user.anonymous should reutrn true when anonymous' ); |
21 | 22 | |
22 | 23 | // Not part of startUp module |
23 | 24 | mw.config.set( 'wgUserName', 'John' ); |
24 | 25 | |
25 | | - equal( mw.user.name(), 'John', 'user.name() When logged-in as John' ); |
26 | | - ok( !mw.user.anonymous(), 'user.anonymous() When logged-in' ); |
| 26 | + equal( mw.user.name(), 'John', 'user.name returns username when logged-in' ); |
| 27 | + ok( !mw.user.anonymous(), 'user.anonymous returns false when logged-in' ); |
27 | 28 | |
28 | | - equal( mw.user.id(), 'John', 'user.id() When logged-in as John' ); |
29 | | - |
30 | | - |
31 | | -}); |
\ No newline at end of file |
| 29 | + equal( mw.user.id(), 'John', 'user.id Returns username when logged-in' ); |
| 30 | +}); |
Index: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.js |
— | — | @@ -1,86 +1,80 @@ |
2 | 2 | module( 'mediawiki.js' ); |
3 | 3 | |
4 | | -test( '-- Initial check', function(){ |
| 4 | +test( '-- Initial check', function() { |
| 5 | + expect(8); |
5 | 6 | |
6 | 7 | ok( window.jQuery, 'jQuery defined' ); |
| 8 | + ok( window.$, '$j defined' ); |
7 | 9 | ok( window.$j, '$j defined' ); |
8 | | - equal( window.$j, window.jQuery, '$j alias to jQuery' ); |
| 10 | + strictEqual( window.$, window.jQuery, '$ alias to jQuery' ); |
| 11 | + strictEqual( window.$j, window.jQuery, '$j alias to jQuery' ); |
9 | 12 | |
10 | 13 | ok( window.mediaWiki, 'mediaWiki defined' ); |
11 | 14 | ok( window.mw, 'mw defined' ); |
12 | | - equal( window.mw, window.mediaWiki, 'mw alias to mediaWiki' ); |
13 | | - |
| 15 | + strictEqual( window.mw, window.mediaWiki, 'mw alias to mediaWiki' ); |
14 | 16 | }); |
15 | 17 | |
16 | | -test( 'mw.Map', function(){ |
17 | | - expect(20); |
| 18 | +test( 'mw.Map', function() { |
| 19 | + expect(15); |
18 | 20 | |
19 | 21 | ok( mw.Map, 'mw.Map defined' ); |
20 | | - ok( mw.Map.prototype.get, 'get prototype defined' ); |
21 | | - ok( mw.Map.prototype.set, 'set prototype defined' ); |
22 | | - ok( mw.Map.prototype.exists, 'exists prototype defined' ); |
23 | 22 | |
24 | | - var conf = new mw.Map(); |
| 23 | + var conf = new mw.Map(), |
| 24 | + funky = function() {}, |
| 25 | + arry = [], |
| 26 | + nummy = 7; |
25 | 27 | |
26 | | - var funky = function(){}; |
27 | | - var arry = []; |
28 | | - var nummy = 7; |
| 28 | + strictEqual( conf.get( 'inexistantKey' ), null, 'Map.get returns null if selection was a string and the key was not found' ); |
| 29 | + strictEqual( conf.set( 'myKey', 'myValue' ), true, 'Map.set returns boolean true if a value was set for a valid key string' ); |
| 30 | + strictEqual( conf.set( funky, 'Funky' ), false, 'Map.set returns boolean false if key was invalid (Function)' ); |
| 31 | + strictEqual( conf.set( arry, 'Arry' ), false, 'Map.set returns boolean false if key was invalid (Array)' ); |
| 32 | + strictEqual( conf.set( nummy, 'Nummy' ), false, 'Map.set returns boolean false if key was invalid (Number)' ); |
| 33 | + equal( conf.get( 'myKey' ), 'myValue', 'Map.get returns a single value value correctly' ); |
29 | 34 | |
30 | | - deepEqual( conf.get( 'inexistantKey' ), null, 'Map.get() returns null if selection was a string and the key was not found' ); |
31 | | - deepEqual( conf.set( 'myKey', 'myValue' ), true, 'Map.set() returns boolean true if a value was set for a valid key string' ); |
32 | | - deepEqual( conf.set( funky, 'Funky' ), false, 'Map.set() returns boolean false if key was invalid (Function)' ); |
33 | | - deepEqual( conf.set( arry, 'Arry' ), false, 'Map.set() returns boolean false if key was invalid (Array)' ); |
34 | | - deepEqual( conf.set( nummy, 'Nummy' ), false, 'Map.set() returns boolean false if key was invalid (Number)' ); |
35 | | - equal( conf.get( 'myKey' ), 'myValue', 'Map.get() returns a single value value correctly' ); |
36 | | - |
37 | 35 | var someValues = { |
38 | 36 | 'foo': 'bar', |
39 | 37 | 'lorem': 'ipsum', |
40 | 38 | 'MediaWiki': true |
41 | 39 | }; |
42 | | - deepEqual( conf.set( someValues ), true, 'Map.set() returns boolean true if multiple values were set by passing an object' ); |
| 40 | + strictEqual( conf.set( someValues ), true, 'Map.set returns boolean true if multiple values were set by passing an object' ); |
43 | 41 | deepEqual( conf.get( ['foo', 'lorem'] ), { |
44 | 42 | 'foo': 'bar', |
45 | 43 | 'lorem': 'ipsum' |
46 | | - }, 'Map.get() returns multiple values correctly as an object' ); |
| 44 | + }, 'Map.get returns multiple values correctly as an object' ); |
47 | 45 | |
48 | 46 | deepEqual( conf.get( ['foo', 'notExist'] ), { |
49 | 47 | 'foo': 'bar', |
50 | 48 | 'notExist': null |
51 | | - }, 'Map.get() return includes keys that were not found as null values' ); |
| 49 | + }, 'Map.get return includes keys that were not found as null values' ); |
52 | 50 | |
53 | | - deepEqual( conf.exists( 'foo' ), true, 'Map.exists() returns boolean true if a key exists' ); |
54 | | - deepEqual( conf.exists( 'notExist' ), false, 'Map.exists() returns boolean false if a key does not exists' ); |
55 | | - deepEqual( conf.get() === conf.values, true, 'Map.get() returns the entire values object by reference (if called without arguments)' ); |
| 51 | + strictEqual( conf.exists( 'foo' ), true, 'Map.exists returns boolean true if a key exists' ); |
| 52 | + strictEqual( conf.exists( 'notExist' ), false, 'Map.exists returns boolean false if a key does not exists' ); |
| 53 | + strictEqual( conf.get() === conf.values, true, 'Map.get returns the entire values object by reference (if called without arguments)' ); |
56 | 54 | |
57 | 55 | conf.set( 'globalMapChecker', 'Hi' ); |
58 | 56 | |
59 | | - deepEqual( 'globalMapChecker' in window, false, 'new mw.Map() did not store its values in the global window object by default' ); |
60 | | - ok( !window.globalMapChecker, 'new mw.Map() did not store its values in the global window object by default' ); |
| 57 | + ok( false === 'globalMapChecker' in window, 'new mw.Map did not store its values in the global window object by default' ); |
61 | 58 | |
62 | 59 | var globalConf = new mw.Map( true ); |
63 | 60 | globalConf.set( 'anotherGlobalMapChecker', 'Hello' ); |
64 | 61 | |
65 | | - deepEqual( 'anotherGlobalMapChecker' in window, true, 'new mw.Map( true ) did store its values in the global window object' ); |
66 | | - ok( window.anotherGlobalMapChecker, 'new mw.Map( true ) did store its values in the global window object' ); |
| 62 | + ok( 'anotherGlobalMapChecker' in window, 'new mw.Map( true ) did store its values in the global window object' ); |
67 | 63 | |
68 | | - // Whitelist this global variable for QUnit 'noglobal' mode |
| 64 | + // Whitelist this global variable for QUnit's 'noglobal' mode |
69 | 65 | if ( QUnit.config.noglobals ) { |
70 | 66 | QUnit.config.pollution.push( 'anotherGlobalMapChecker' ); |
71 | 67 | } |
72 | 68 | }); |
73 | 69 | |
74 | | -test( 'mw.config', function(){ |
| 70 | +test( 'mw.config', function() { |
75 | 71 | expect(1); |
76 | 72 | |
77 | | - deepEqual( mw.config instanceof mw.Map, true, 'mw.config instance of mw.Map' ); |
| 73 | + ok( mw.config instanceof mw.Map, 'mw.config instance of mw.Map' ); |
78 | 74 | }); |
79 | 75 | |
80 | | -test( 'mw.messages / mw.message / mw.msg', function(){ |
81 | | - expect(18); |
| 76 | +test( 'mw.message & mw.messages', function() { |
| 77 | + expect(16); |
82 | 78 | |
83 | | - ok( mw.message, 'mw.message defined' ); |
84 | | - ok( mw.msg, 'mw.msg defined' ); |
85 | 79 | ok( mw.messages, 'messages defined' ); |
86 | 80 | ok( mw.messages instanceof mw.Map, 'mw.messages instance of mw.Map' ); |
87 | 81 | ok( mw.messages.set( 'hello', 'Hello <b>awesome</b> world' ), 'mw.messages.set: Register' ); |
— | — | @@ -88,7 +82,7 @@ |
89 | 83 | var hello = mw.message( 'hello' ); |
90 | 84 | |
91 | 85 | equal( hello.format, 'parse', 'Message property "format" defaults to "parse"' ); |
92 | | - deepEqual( hello.map === mw.messages, true, 'Message property "map" defaults to the global instance in mw.messages' ); |
| 86 | + strictEqual( hello.map, mw.messages, 'Message property "map" defaults to the global instance in mw.messages' ); |
93 | 87 | equal( hello.key, 'hello', 'Message property "key" (currect key)' ); |
94 | 88 | deepEqual( hello.parameters, [], 'Message property "parameters" defaults to an empty array' ); |
95 | 89 | |
— | — | @@ -96,34 +90,34 @@ |
97 | 91 | ok( hello.params, 'Message prototype "params"' ); |
98 | 92 | |
99 | 93 | hello.format = 'plain'; |
100 | | - equal( hello.toString(), 'Hello <b>awesome</b> world', 'Message.toString() returns the message as a string with the current "format"' ); |
| 94 | + equal( hello.toString(), 'Hello <b>awesome</b> world', 'Message.toString returns the message as a string with the current "format"' ); |
101 | 95 | |
102 | | - equal( hello.escaped(), 'Hello <b>awesome</b> world', 'Message.escaped() returns the escaped message' ); |
103 | | - equal( hello.format, 'escaped', 'Message.escaped() correctly updated the "format" property' ); |
| 96 | + equal( hello.escaped(), 'Hello <b>awesome</b> world', 'Message.escaped returns the escaped message' ); |
| 97 | + equal( hello.format, 'escaped', 'Message.escaped correctly updated the "format" property' ); |
104 | 98 | |
105 | 99 | hello.parse(); |
106 | | - equal( hello.format, 'parse', 'Message.parse() correctly updated the "format" property' ); |
| 100 | + equal( hello.format, 'parse', 'Message.parse correctly updated the "format" property' ); |
107 | 101 | |
108 | 102 | hello.plain(); |
109 | | - equal( hello.format, 'plain', 'Message.plain() correctly updated the "format" property' ); |
| 103 | + equal( hello.format, 'plain', 'Message.plain correctly updated the "format" property' ); |
110 | 104 | |
111 | | - deepEqual( hello.exists(), true, 'Message.exists() returns true for existing messages' ); |
| 105 | + strictEqual( hello.exists(), true, 'Message.exists returns true for existing messages' ); |
112 | 106 | |
113 | 107 | var goodbye = mw.message( 'goodbye' ); |
114 | | - deepEqual( goodbye.exists(), false, 'Message.exists() returns false for inexisting messages' ); |
| 108 | + strictEqual( goodbye.exists(), false, 'Message.exists returns false for inexisting messages' ); |
115 | 109 | |
116 | | - equal( goodbye.toString(), '<goodbye>', 'Message.toString() returns <key> if key does not exist' ); |
| 110 | + equal( goodbye.toString(), '<goodbye>', 'Message.toString returns <key> if key does not exist' ); |
117 | 111 | |
118 | 112 | }); |
119 | 113 | |
120 | | -test( 'mw.msg', function(){ |
| 114 | +test( 'mw.msg', function() { |
121 | 115 | expect(2); |
122 | 116 | |
123 | 117 | equal( mw.msg( 'hello' ), 'Hello <b>awesome</b> world', 'Gets message with default options (existing message)' ); |
124 | 118 | equal( mw.msg( 'goodbye' ), '<goodbye>', 'Gets message with default options (inexisting message)' ); |
125 | 119 | }); |
126 | 120 | |
127 | | -test( 'mw.loader', function(){ |
| 121 | +test( 'mw.loader', function() { |
128 | 122 | expect(5); |
129 | 123 | |
130 | 124 | // Regular expression to extract the path for the QUnit tests |
— | — | @@ -154,62 +148,74 @@ |
155 | 149 | ); |
156 | 150 | |
157 | 151 | // Asynchronous ahead |
158 | | - stop(); |
| 152 | + stop(1500); |
159 | 153 | |
160 | 154 | // Extract path |
161 | 155 | var tests_path = rePath.exec( location.href ); |
162 | 156 | |
163 | 157 | mw.loader.implement( 'is.awesome', [tests_path + 'sample/awesome.js'], {}, {} ); |
164 | 158 | |
165 | | - mw.loader.using( 'is.awesome', function(){ |
| 159 | + mw.loader.using( 'is.awesome', function() { |
166 | 160 | |
167 | | - // awesome.js declares this function |
| 161 | + // /sample/awesome.js declares the "mw.loader.testCallback" function |
| 162 | + // which contains a call to start() and ok() |
168 | 163 | mw.loader.testCallback(); |
169 | 164 | |
170 | | - }, function(){ |
| 165 | + }, function() { |
171 | 166 | start(); |
172 | | - deepEqual( true, false, 'Implementing a module, error callback fired!' ); |
| 167 | + ok( false, 'Error callback fired while implementing "is.awesome" module' ); |
173 | 168 | }); |
174 | 169 | |
175 | 170 | }); |
176 | 171 | |
177 | 172 | test( 'mw.loader.bug29107' , function() { |
178 | | - expect( 1 ); |
| 173 | + expect(2); |
179 | 174 | |
180 | | - // Async! Include a timeout, as failure on this bug lead to neither the |
| 175 | + // Message doesn't exist already |
| 176 | + ok( !mw.messages.exists( 'bug29107' ) ); |
| 177 | + |
| 178 | + // Async! Include a timeout, as failure in this test leads to neither the |
181 | 179 | // success nor failure callbacks getting called. |
182 | 180 | stop(1500); |
183 | 181 | |
184 | 182 | mw.loader.implement( 'bug29107.messages-only', [], {}, {'bug29107': 'loaded'} ); |
185 | 183 | mw.loader.using( 'bug29107.messages-only', function() { |
186 | 184 | start(); |
187 | | - ok( mw.messages.exists( 'bug29107' ), 'Bug 29107: messages-only module should load ok' ); |
188 | | - }, function(){ |
| 185 | + ok( mw.messages.exists( 'bug29107' ), 'Bug 29107: messages-only module should implement ok' ); |
| 186 | + }, function() { |
189 | 187 | start(); |
190 | | - deepEqual( true, false, 'Implementing a module, error callback fired!' ); |
| 188 | + ok( false, 'Error callback fired while implementing "bug29107.messages-only" module' ); |
191 | 189 | }); |
192 | 190 | }); |
193 | 191 | |
194 | | -test( 'mw.html', function(){ |
| 192 | +test( 'mw.html', function() { |
| 193 | + expect(7); |
195 | 194 | |
| 195 | + raises( function(){ |
| 196 | + mw.html.escape(); |
| 197 | + }, TypeError, 'html.escape throws a TypeError if argument given is not a string' ); |
| 198 | + |
196 | 199 | equal( mw.html.escape( '<mw awesome="awesome" value=\'test\' />' ), |
197 | | - '<mw awesome="awesome" value='test' />', 'html.escape()' ); |
| 200 | + '<mw awesome="awesome" value='test' />', 'html.escape escapes html snippet' ); |
198 | 201 | |
199 | | - equal( mw.html.element( 'div' ), '<div/>', 'mw.html.element() DIV (simple)' ); |
| 202 | + equal( mw.html.element(), |
| 203 | + '<undefined/>', 'html.element Always return a valid html string (even without arguments)' ); |
200 | 204 | |
| 205 | + equal( mw.html.element( 'div' ), '<div/>', 'html.element DIV (simple)' ); |
| 206 | + |
201 | 207 | equal( mw.html.element( 'div', |
202 | 208 | { id: 'foobar' } ), |
203 | 209 | '<div id="foobar"/>', |
204 | | - 'mw.html.element() DIV (attribs)' ); |
| 210 | + 'html.element DIV (attribs)' ); |
205 | 211 | |
206 | 212 | equal( mw.html.element( 'div', |
207 | 213 | null, 'a' ), |
208 | 214 | '<div>a</div>', |
209 | | - 'mw.html.element() DIV (content)' ); |
| 215 | + 'html.element DIV (content)' ); |
210 | 216 | |
211 | 217 | equal( mw.html.element( 'a', |
212 | 218 | { href: 'http://mediawiki.org/w/index.php?title=RL&action=history' }, 'a' ), |
213 | 219 | '<a href="http://mediawiki.org/w/index.php?title=RL&action=history">a</a>', |
214 | | - 'mw.html.element() DIV (attribs + content)' ); |
| 220 | + 'html.element DIV (attribs + content)' ); |
215 | 221 | |
216 | 222 | }); |