From f6d65e533c62f6deb21342d4901ece24497b433e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 4 Jun 2015 07:31:04 +0200 Subject: Update to MediaWiki 1.25.1 --- .../resources/jquery/jquery.accessKeyLabel.test.js | 14 +- .../resources/jquery/jquery.byteLimit.test.js | 2 +- .../suites/resources/jquery/jquery.client.test.js | 638 --------------------- .../resources/jquery/jquery.getAttrs.test.js | 7 +- .../resources/jquery/jquery.placeholder.test.js | 6 +- .../jquery/jquery.tablesorter.parsers.test.js | 223 +++++++ .../resources/jquery/jquery.tablesorter.test.js | 51 +- 7 files changed, 274 insertions(+), 667 deletions(-) delete mode 100644 tests/qunit/suites/resources/jquery/jquery.client.test.js create mode 100644 tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js (limited to 'tests/qunit/suites/resources/jquery') diff --git a/tests/qunit/suites/resources/jquery/jquery.accessKeyLabel.test.js b/tests/qunit/suites/resources/jquery/jquery.accessKeyLabel.test.js index f6ea1b48..4484467d 100644 --- a/tests/qunit/suites/resources/jquery/jquery.accessKeyLabel.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.accessKeyLabel.test.js @@ -7,7 +7,7 @@ } ) ); var getAccessKeyPrefixTestData = [ - //ua string, platform string, expected prefix + // ua string, platform string, expected prefix // Internet Explorer ['Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)', 'Win32', 'alt-'], ['Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)', 'Win32', 'alt-'], @@ -27,11 +27,11 @@ ['Mozilla/5.0 (Macintosh; Intel Mac OS X 10_5_8) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30', 'MacIntel', 'ctrl-option-'], ['Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.68 Safari/534.30', 'Linux i686', 'alt-shift-'] ], - //strings appended to title to make sure updateTooltipAccessKeys handles them correctly + // strings appended to title to make sure updateTooltipAccessKeys handles them correctly updateTooltipAccessKeysTestData = [ '', ' [a]', ' [test-a]', ' [alt-b]' ]; function makeInput( title, accessKey ) { - //The properties aren't escaped, so make sure you don't call this function with values that need to be escaped! + // The properties aren't escaped, so make sure you don't call this function with values that need to be escaped! return ''; } @@ -46,10 +46,10 @@ } ); QUnit.test( 'updateTooltipAccessKeys - current browser', 2, function ( assert ) { - var title = $( makeInput ( 'Title', 'a' ) ).updateTooltipAccessKeys().prop( 'title' ), - //The new title should be something like "Title [alt-a]", but the exact label will depend on the browser. - //The "a" could be capitalized, and the prefix could be anything, e.g. a simple "^" for ctrl- - //(no browser is known using such a short prefix, though) or "Alt+Umschalt+" in German Firefox. + var title = $( makeInput( 'Title', 'a' ) ).updateTooltipAccessKeys().prop( 'title' ), + // The new title should be something like "Title [alt-a]", but the exact label will depend on the browser. + // The "a" could be capitalized, and the prefix could be anything, e.g. a simple "^" for ctrl- + // (no browser is known using such a short prefix, though) or "Alt+Umschalt+" in German Firefox. result = /^Title \[(.+)[aA]\]$/.exec( title ); assert.ok( result, 'title should match expected structure.' ); assert.notEqual( result[1], 'test-', 'Prefix used for testing shouldn\'t be used in production.' ); diff --git a/tests/qunit/suites/resources/jquery/jquery.byteLimit.test.js b/tests/qunit/suites/resources/jquery/jquery.byteLimit.test.js index 22d2af19..0cb9cc81 100644 --- a/tests/qunit/suites/resources/jquery/jquery.byteLimit.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.byteLimit.test.js @@ -60,7 +60,7 @@ ); QUnit.start(); - }, 10 ); + } ); } ); } diff --git a/tests/qunit/suites/resources/jquery/jquery.client.test.js b/tests/qunit/suites/resources/jquery/jquery.client.test.js deleted file mode 100644 index c6dd91c4..00000000 --- a/tests/qunit/suites/resources/jquery/jquery.client.test.js +++ /dev/null @@ -1,638 +0,0 @@ -( function ( $ ) { - - QUnit.module( 'jquery.client', QUnit.newMwEnvironment() ); - - var uacount = 0, - // Object keyed by userAgent. Value is an array (human-readable name, client-profile object, navigator.platform value) - uas = { - // Internet Explorer 6 - // Internet Explorer 7 - 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)': { - title: 'Internet Explorer 7', - platform: 'Win32', - profile: { - name: 'msie', - layout: 'trident', - layoutVersion: 'unknown', - platform: 'win', - version: '7.0', - versionBase: '7', - versionNumber: 7 - }, - wikiEditor: { - ltr: true, - rtl: false - } - }, - // Internet Explorer 8 - // Internet Explorer 9 - // Internet Explorer 10 - 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)': { - title: 'Internet Explorer 10', - platform: 'Win32', - profile: { - name: 'msie', - layout: 'trident', - layoutVersion: 6, - platform: 'win', - version: '10.0', - versionBase: '10', - versionNumber: 10 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - // Internet Explorer 11 - 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv 11.0) like Gecko': { - title: 'Internet Explorer 11', - platform: 'Win32', - profile: { - name: 'msie', - layout: 'trident', - layoutVersion: 7, - platform: 'win', - version: '11.0', - versionBase: '11', - versionNumber: 11 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - // Internet Explorer 11 - Windows 8.1 x64 Modern UI - 'Mozilla/5.0 (Windows NT 6.3; Win64; x64; Trident/7.0; rv:11.0) like Gecko': { - title: 'Internet Explorer 11', - platform: 'Win64', - profile: { - name: 'msie', - layout: 'trident', - layoutVersion: 7, - platform: 'win', - version: '11.0', - versionBase: '11', - versionNumber: 11 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - // Internet Explorer 11 - Windows 8.1 x64 desktop UI - 'Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko': { - title: 'Internet Explorer 11', - platform: 'WOW64', - profile: { - name: 'msie', - layout: 'trident', - layoutVersion: 7, - platform: 'win', - version: '11.0', - versionBase: '11', - versionNumber: 11 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - // Firefox 2 - // Firefox 3.5 - 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.19) Gecko/20110420 Firefox/3.5.19': { - title: 'Firefox 3.5', - platform: 'MacIntel', - profile: { - name: 'firefox', - layout: 'gecko', - layoutVersion: 20110420, - platform: 'mac', - version: '3.5.19', - versionBase: '3', - versionNumber: 3.5 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - // Firefox 3.6 - 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110422 Ubuntu/10.10 (maverick) Firefox/3.6.17': { - title: 'Firefox 3.6', - platform: 'Linux i686', - profile: { - name: 'firefox', - layout: 'gecko', - layoutVersion: 20110422, - platform: 'linux', - version: '3.6.17', - versionBase: '3', - versionNumber: 3.6 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - // Firefox 4 - 'Mozilla/5.0 (Windows NT 6.0; rv:2.0.1) Gecko/20100101 Firefox/4.0.1': { - title: 'Firefox 4', - platform: 'Win32', - profile: { - name: 'firefox', - layout: 'gecko', - layoutVersion: 20100101, - platform: 'win', - version: '4.0.1', - versionBase: '4', - versionNumber: 4 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - // Firefox 10 nightly build - 'Mozilla/5.0 (X11; Linux x86_64; rv:10.0a1) Gecko/20111103 Firefox/10.0a1': { - title: 'Firefox 10 nightly', - platform: 'Linux', - profile: { - name: 'firefox', - layout: 'gecko', - layoutVersion: 20111103, - platform: 'linux', - version: '10.0a1', - versionBase: '10', - versionNumber: 10 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - // Iceweasel 10.0.6 - 'Mozilla/5.0 (X11; Linux i686; rv:10.0.6) Gecko/20100101 Iceweasel/10.0.6': { - title: 'Iceweasel 10.0.6', - platform: 'Linux', - profile: { - name: 'iceweasel', - layout: 'gecko', - layoutVersion: 20100101, - platform: 'linux', - version: '10.0.6', - versionBase: '10', - versionNumber: 10 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - // Iceweasel 15.0.1 - 'Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20100101 Firefox/15.0.1 Iceweasel/15.0.1': { - title: 'Iceweasel 15.0.1', - platform: 'Linux', - profile: { - name: 'iceweasel', - layout: 'gecko', - layoutVersion: 20100101, - platform: 'linux', - version: '15.0.1', - versionBase: '15', - versionNumber: 15 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - // Firefox 5 - // Safari 3 - // Safari 4 - 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; nl-nl) AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7': { - title: 'Safari 4', - platform: 'MacIntel', - profile: { - name: 'safari', - layout: 'webkit', - layoutVersion: 531, - platform: 'mac', - version: '4.0.5', - versionBase: '4', - versionNumber: 4 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - 'Mozilla/5.0 (Windows; U; Windows NT 6.0; cs-CZ) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7': { - title: 'Safari 4', - platform: 'Win32', - profile: { - name: 'safari', - layout: 'webkit', - layoutVersion: 533, - platform: 'win', - version: '4.0.5', - versionBase: '4', - versionNumber: 4 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - // Safari 5 - // Safari 6 - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_3) AppleWebKit/536.29.13 (KHTML, like Gecko) Version/6.0.4 Safari/536.29.13': { - title: 'Safari 6', - platform: 'MacIntel', - profile: { - name: 'safari', - layout: 'webkit', - layoutVersion: 536, - platform: 'mac', - version: '6.0.4', - versionBase: '6', - versionNumber: 6 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - // Safari 6.0.5+ (doesn't have the comma in "KHTML, like Gecko") - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 1084) AppleWebKit/536.30.1 (KHTML like Gecko) Version/6.0.5 Safari/536.30.1': { - title: 'Safari 6', - platform: 'MacIntel', - profile: { - name: 'safari', - layout: 'webkit', - layoutVersion: 536, - platform: 'mac', - version: '6.0.5', - versionBase: '6', - versionNumber: 6 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - // Opera 10+ - 'Opera/9.80 (Windows NT 5.1)': { - title: 'Opera 10+ (exact version unspecified)', - platform: 'Win32', - profile: { - name: 'opera', - layout: 'presto', - layoutVersion: 'unknown', - platform: 'win', - version: '10', - versionBase: '10', - versionNumber: 10 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - // Opera 12 - 'Opera/9.80 (Windows NT 5.1) Presto/2.12.388 Version/12.11': { - title: 'Opera 12', - platform: 'Win32', - profile: { - name: 'opera', - layout: 'presto', - layoutVersion: 'unknown', - platform: 'win', - version: '12.11', - versionBase: '12', - versionNumber: 12.11 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - // Opera 15 (WebKit-based) - 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.52 Safari/537.36 OPR/15.0.1147.130': { - title: 'Opera 15', - platform: 'Win32', - profile: { - name: 'opera', - layout: 'webkit', - layoutVersion: 537, - platform: 'win', - version: '15.0.1147.130', - versionBase: '15', - versionNumber: 15 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - // Chrome 5 - // Chrome 6 - // Chrome 7 - // Chrome 8 - // Chrome 9 - // Chrome 10 - // Chrome 11 - // Chrome 12 - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_5_8) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30': { - title: 'Chrome 12', - platform: 'MacIntel', - profile: { - name: 'chrome', - layout: 'webkit', - layoutVersion: 534, - platform: 'mac', - version: '12.0.742.112', - versionBase: '12', - versionNumber: 12 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.68 Safari/534.30': { - title: 'Chrome 12', - platform: 'Linux i686', - profile: { - name: 'chrome', - layout: 'webkit', - layoutVersion: 534, - platform: 'linux', - version: '12.0.742.68', - versionBase: '12', - versionNumber: 12 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - // Android WebKit Browser 2.3 - 'Mozilla/5.0 (Linux; U; Android 2.3.5; en-us; HTC Vision Build/GRI40) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1': { - title: 'Android WebKit Browser 2.3', - platform: 'Linux armv7l', - profile: { - name: 'android', - layout: 'webkit', - layoutVersion: 533, - platform: 'linux', - version: '2.3.5', - versionBase: '2', - versionNumber: 2.3 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - // Rekonq (bug 34924) - 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.34 (KHTML, like Gecko) rekonq Safari/534.34': { - title: 'Rekonq', - platform: 'Linux i686', - profile: { - name: 'rekonq', - layout: 'webkit', - layoutVersion: 534, - platform: 'linux', - version: '534.34', - versionBase: '534', - versionNumber: 534.34 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - // Konqueror - 'Mozilla/5.0 (X11; Linux i686) KHTML/4.9.1 (like Gecko) Konqueror/4.9': { - title: 'Konqueror', - platform: 'Linux i686', - profile: { - name: 'konqueror', - layout: 'khtml', - layoutVersion: 'unknown', - platform: 'linux', - version: '4.9.1', - versionBase: '4', - versionNumber: 4.9 - }, - wikiEditor: { - // '4.9' is less than '4.11'. - ltr: false, - rtl: false - }, - wikiEditorLegacy: { - // The check is missing in legacyTestMap - ltr: true, - rtl: true - } - }, - // Amazon Silk - 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.0.13.81_10003810) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true': { - title: 'Silk', - platform: 'Desktop', - profile: { - name: 'silk', - layout: 'webkit', - layoutVersion: 533, - platform: 'unknown', - version: '1.0.13.81_10003810', - versionBase: '1', - versionNumber: 1 - }, - wikiEditor: { - ltr: true, - rtl: true - } - }, - 'Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; KFTT Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Silk/2.1 Mobile Safari/535.19 Silk-Accelerated=true': { - title: 'Silk', - platform: 'Mobile', - profile: { - name: 'silk', - layout: 'webkit', - layoutVersion: 535, - platform: 'unknown', - version: '2.1', - versionBase: '2', - versionNumber: 2.1 - }, - wikiEditor: { - ltr: true, - rtl: true - } - } - }, - testMap = { - // Example from WikiEditor, modified to provide version identifiers as strings and with - // Konqueror 4.11 check added. - 'ltr': { - 'msie': [['>=', '7.0']], - 'firefox': [['>=', '2']], - 'opera': [['>=', '9.6']], - 'safari': [['>=', '3']], - 'chrome': [['>=', '3']], - 'netscape': [['>=', '9']], - 'konqueror': [['>=', '4.11']], - 'blackberry': false, - 'ipod': false, - 'iphone': false - }, - 'rtl': { - 'msie': [['>=', '8']], - 'firefox': [['>=', '2']], - 'opera': [['>=', '9.6']], - 'safari': [['>=', '3']], - 'chrome': [['>=', '3']], - 'netscape': [['>=', '9']], - 'konqueror': [['>=', '4.11']], - 'blackberry': false, - 'ipod': false, - 'iphone': false - } - }, - legacyTestMap = { - // Original example from WikiEditor. - // This is using the old, but still supported way of providing version identifiers as numbers - // instead of strings; with this method, 4.9 would be considered larger than 4.11. - 'ltr': { - 'msie': [['>=', 7.0]], - 'firefox': [['>=', 2]], - 'opera': [['>=', 9.6]], - 'safari': [['>=', 3]], - 'chrome': [['>=', 3]], - 'netscape': [['>=', 9]], - 'blackberry': false, - 'ipod': false, - 'iphone': false - }, - 'rtl': { - 'msie': [['>=', 8]], - 'firefox': [['>=', 2]], - 'opera': [['>=', 9.6]], - 'safari': [['>=', 3]], - 'chrome': [['>=', 3]], - 'netscape': [['>=', 9]], - 'blackberry': false, - 'ipod': false, - 'iphone': false - } - } - ; - - // Count test cases - $.each( uas, function () { - uacount++; - } ); - - QUnit.test( 'profile( navObject )', 7, function ( assert ) { - var p = $.client.profile(); - - function unknownOrType( val, type, summary ) { - assert.ok( typeof val === type || val === 'unknown', summary ); - } - - assert.equal( typeof p, 'object', 'profile returns an object' ); - unknownOrType( p.layout, 'string', 'p.layout is a string (or "unknown")' ); - unknownOrType( p.layoutVersion, 'number', 'p.layoutVersion is a number (or "unknown")' ); - unknownOrType( p.platform, 'string', 'p.platform is a string (or "unknown")' ); - unknownOrType( p.version, 'string', 'p.version is a string (or "unknown")' ); - unknownOrType( p.versionBase, 'string', 'p.versionBase is a string (or "unknown")' ); - assert.equal( typeof p.versionNumber, 'number', 'p.versionNumber is a number' ); - } ); - - QUnit.test( 'profile( navObject ) - samples', uacount, function ( assert ) { - // Loop through and run tests - $.each( uas, function ( rawUserAgent, data ) { - // Generate a client profile object and compare recursively - var ret = $.client.profile( { - userAgent: rawUserAgent, - platform: data.platform - } ); - assert.deepEqual( ret, data.profile, 'Client profile support check for ' + data.title + ' (' + data.platform + '): ' + rawUserAgent ); - } ); - } ); - - QUnit.test( 'test( testMap )', 4, function ( assert ) { - // .test() uses eval, make sure no exceptions are thrown - // then do a basic return value type check - var testMatch = $.client.test( testMap ), - ie7Profile = $.client.profile( { - 'userAgent': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)', - 'platform': '' - } ); - - assert.equal( typeof testMatch, 'boolean', 'map with ltr/rtl split returns a boolean value' ); - - testMatch = $.client.test( testMap.ltr ); - - assert.equal( typeof testMatch, 'boolean', 'simple map (without ltr/rtl split) returns a boolean value' ); - - assert.equal( $.client.test( { - 'msie': null - }, ie7Profile ), true, 'returns true if any version of a browser are allowed (null)' ); - - assert.equal( $.client.test( { - 'msie': false - }, ie7Profile ), false, 'returns false if all versions of a browser are not allowed (false)' ); - } ); - - QUnit.test( 'test( testMap, exactMatchOnly )', 2, function ( assert ) { - var ie7Profile = $.client.profile( { - 'userAgent': 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)', - 'platform': '' - } ); - - assert.equal( $.client.test( { - 'firefox': [['>=', 2]] - }, ie7Profile, false ), true, 'returns true if browser not found and exactMatchOnly not set' ); - - assert.equal( $.client.test( { - 'firefox': [['>=', 2]] - }, ie7Profile, true ), false, 'returns false if browser not found and exactMatchOnly is set' ); - } ); - - QUnit.test( 'test( testMap ), test( legacyTestMap ) - WikiEditor sample', uacount * 2 * 2, function ( assert ) { - var $body = $( 'body' ), - bodyClasses = $body.attr( 'class' ); - - // Loop through and run tests - $.each( uas, function ( agent, data ) { - $.each( ['ltr', 'rtl'], function ( i, dir ) { - var profile, testMatch, legacyTestMatch; - $body.removeClass( 'ltr rtl' ).addClass( dir ); - profile = $.client.profile( { - userAgent: agent, - platform: data.platform - } ); - testMatch = $.client.test( testMap, profile ); - legacyTestMatch = $.client.test( legacyTestMap, profile ); - $body.removeClass( dir ); - - assert.equal( - testMatch, - data.wikiEditor[dir], - 'testing comparison based on ' + dir + ', ' + agent - ); - assert.equal( - legacyTestMatch, - data.wikiEditorLegacy ? data.wikiEditorLegacy[dir] : data.wikiEditor[dir], - 'testing comparison based on ' + dir + ', ' + agent + ' (legacyTestMap)' - ); - } ); - } ); - - // Restore body classes - $body.attr( 'class', bodyClasses ); - } ); -}( jQuery ) ); diff --git a/tests/qunit/suites/resources/jquery/jquery.getAttrs.test.js b/tests/qunit/suites/resources/jquery/jquery.getAttrs.test.js index 0b7e87ee..ca3f418c 100644 --- a/tests/qunit/suites/resources/jquery/jquery.getAttrs.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.getAttrs.test.js @@ -1,13 +1,14 @@ ( function ( $ ) { QUnit.module( 'jquery.getAttrs', QUnit.newMwEnvironment() ); - QUnit.test( 'Check', 1, function ( assert ) { + QUnit.test( 'getAttrs()', 1, function ( assert ) { var attrs = { foo: 'bar', - 'class': 'lorem' + 'class': 'lorem', + 'data-foo': 'data value' }, $el = $( '
' ).attr( attrs ); - assert.deepEqual( $el.getAttrs(), attrs, 'getAttrs() return object should match the attributes set, no more, no less' ); + assert.propEqual( $el.getAttrs(), attrs, 'keys and values match' ); } ); }( jQuery ) ); diff --git a/tests/qunit/suites/resources/jquery/jquery.placeholder.test.js b/tests/qunit/suites/resources/jquery/jquery.placeholder.test.js index bbea8297..78c185f1 100644 --- a/tests/qunit/suites/resources/jquery/jquery.placeholder.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.placeholder.test.js @@ -1,10 +1,10 @@ -(function ($) { +( function ($) { QUnit.module('jquery.placeholder', QUnit.newMwEnvironment()); QUnit.test('caches results of feature tests', 2, function (assert) { - assert.strictEqual(typeof $.fn.placeholder.input, 'boolean', '$.fn.placeholder.input'); - assert.strictEqual(typeof $.fn.placeholder.textarea, 'boolean', '$.fn.placeholder.textarea'); + assert.strictEqual( typeof $.fn.placeholder.input, 'boolean', '$.fn.placeholder.input'); + assert.strictEqual( typeof $.fn.placeholder.textarea, 'boolean', '$.fn.placeholder.textarea'); }); if ($.fn.placeholder.input && $.fn.placeholder.textarea) { diff --git a/tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js b/tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js new file mode 100644 index 00000000..97a3ae12 --- /dev/null +++ b/tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js @@ -0,0 +1,223 @@ +( function ( $, mw ) { + /** + * This module tests the input/output capabilities of the parsers of tablesorter. + * It does not test actual sorting. + */ + + var text, ipv4, + simpleMDYDatesInMDY, simpleMDYDatesInDMY, oldMDYDates, complexMDYDates, clobberedDates, MYDates, YDates, + currencyData, transformedCurrencyData; + + QUnit.module( 'jquery.tablesorter.parsers', QUnit.newMwEnvironment( { + setup: function () { + this.liveMonths = mw.language.months; + mw.language.months = { + 'keys': { + 'names': ['january', 'february', 'march', 'april', 'may_long', 'june', + 'july', 'august', 'september', 'october', 'november', 'december'], + 'genitive': ['january-gen', 'february-gen', 'march-gen', 'april-gen', 'may-gen', 'june-gen', + 'july-gen', 'august-gen', 'september-gen', 'october-gen', 'november-gen', 'december-gen'], + 'abbrev': ['jan', 'feb', 'mar', 'apr', 'may', 'jun', + 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'] + }, + 'names': ['January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December'], + 'genitive': ['January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December'], + 'abbrev': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] + }; + }, + teardown: function () { + mw.language.months = this.liveMonths; + }, + config: { + wgContentLanguage: 'en', + /* default date format of the content language */ + wgDefaultDateFormat: 'dmy', + /* These two are important for numeric interpretations */ + wgSeparatorTransformTable: ['', ''], + wgDigitTransformTable: ['', ''] + } + } ) ); + + /** + * For a value, check if the parser recognizes it and how it transforms it + * + * @param {String} msg text to pass on to qunit describing the test case + * @param {String[]} parserId of the parser that will be tested + * @param {String[][]} data Array of testcases. Each testcase, array of + * inputValue: The string value that we want to test the parser for + * recognized: If we expect that this value's type is detectable by the parser + * outputValue: The value the parser has converted the input to + * msg: describing the testcase + * @param {function($table)} callback something to do before we start the testcase + */ + function parserTest( msg, parserId, data, callback ) { + QUnit.test( msg, data.length * 2, function ( assert ) { + var extractedR, extractedF, parser; + + if (callback !== undefined ) { + callback(); + } + + parser = $.tablesorter.getParser( parserId ); + $.each( data, function ( index, testcase ) { + extractedR = parser.is( testcase[0] ); + extractedF = parser.format( testcase[0] ); + + assert.strictEqual( extractedR, testcase[1], 'Detect: ' + testcase[3] ); + assert.strictEqual( extractedF, testcase[2], 'Sortkey: ' + testcase[3] ); + } ); + + } ); + } + + text = [ + [ 'Mars', true, 'mars', 'Simple text' ], + [ 'Mẘas', true, 'mẘas', 'Non ascii character' ], + [ 'A sentence', true, 'a sentence', 'A sentence with space chars' ] + ]; + parserTest( 'Textual keys', 'text', text ); + + ipv4 = [ + // Some randomly generated fake IPs + ['0.0.0.0', true, 0, 'An IP address' ], + ['255.255.255.255', true, 255255255255, 'An IP address' ], + ['45.238.27.109', true, 45238027109, 'An IP address' ], + ['1.238.27.1', true, 1238027001, 'An IP address with small numbers' ], + ['238.27.1', false, 238027001, 'A malformed IP Address' ], + ['1', false, 1, 'A super malformed IP Address' ], + ['Just text', false, 0, 'A line with just text' ], + ['45.238.27.109Postfix', false, 45238027109, 'An IP address with a connected postfix' ], + ['45.238.27.109 postfix', false, 45238027109, 'An IP address with a seperated postfix' ] + ]; + parserTest( 'IPv4', 'IPAddress', ipv4 ); + + simpleMDYDatesInMDY = [ + ['January 17, 2010', true, 20100117, 'Long middle endian date'], + ['Jan 17, 2010', true, 20100117, 'Short middle endian date'], + ['1/17/2010', true, 20100117, 'Numeric middle endian date'], + ['01/17/2010', true, 20100117, 'Numeric middle endian date with padding on month'], + ['01/07/2010', true, 20100107, 'Numeric middle endian date with padding on day'], + ['01/07/0010', true, 20100107, 'Numeric middle endian date with padding on year'], + ['5.12.1990', true, 19900512, 'Numeric middle endian date with . separator'] + ]; + parserTest( 'MDY Dates using mdy content language', 'date', simpleMDYDatesInMDY ); + + simpleMDYDatesInDMY = [ + ['January 17, 2010', true, 20100117, 'Long middle endian date'], + ['Jan 17, 2010', true, 20100117, 'Short middle endian date'], + ['1/17/2010', true, 20101701, 'Numeric middle endian date'], + ['01/17/2010', true, 20101701, 'Numeric middle endian date with padding on month'], + ['01/07/2010', true, 20100701, 'Numeric middle endian date with padding on day'], + ['01/07/0010', true, 20100701, 'Numeric middle endian date with padding on year'], + ['5.12.1990', true, 19901205, 'Numeric middle endian date with . separator'] + ]; + parserTest( 'MDY Dates using dmy content language', 'date', simpleMDYDatesInDMY, function () { + mw.config.set( { + 'wgDefaultDateFormat': 'dmy', + 'wgContentLanguage': 'de' + } ); + } ); + + oldMDYDates = [ + ['January 19, 1400 BC', false, '99999999', 'BC'], + ['January 19, 1400BC', false, '99999999', 'Connected BC'], + ['January, 19 1400 B.C.', false, '99999999', 'B.C.'], + ['January 19, 1400 AD', false, '99999999', 'AD'], + ['January, 19 10', true, 20100119, 'AD'], + ['January, 19 1', false, '99999999', 'AD'] + ]; + parserTest( 'Very old MDY dates', 'date', oldMDYDates ); + + complexMDYDates = [ + ['January, 19 2010', true, 20100119, 'Comma after month'], + ['January 19, 2010', true, 20100119, 'Comma after day'], + ['January/19/2010', true, 20100119, 'Forward slash separator'], + ['04 22 1991', true, 19910422, 'Month with 0 padding'], + ['April 21 1991', true, 19910421, 'Space separation'], + ['04 22 1991', true, 19910422, 'Month with 0 padding'], + ['December 12 \'10', true, 20101212, ''], + ['Dec 12 \'10', true, 20101212, ''], + ['Dec. 12 \'10', true, 20101212, ''] + ]; + parserTest( 'MDY Dates', 'date', complexMDYDates ); + + clobberedDates = [ + ['January, 19 2010 - January, 20 2010', false, '99999999', 'Date range with hyphen'], + ['January, 19 2010 — January, 20 2010', false, '99999999', 'Date range with mdash'], + ['prefixJanuary, 19 2010', false, '99999999', 'Connected prefix'], + ['prefix January, 19 2010', false, '99999999', 'Prefix'], + ['December 12 2010postfix', false, '99999999', 'ConnectedPostfix'], + ['December 12 2010 postfix', false, '99999999', 'Postfix'], + ['A simple text', false, '99999999', 'Plain text in date sort'], + ['04l22l1991', false, '99999999', 'l char as separator'], + ['January\\19\\2010', false, '99999999', 'backslash as date separator'] + ]; + parserTest( 'Clobbered Dates', 'date', clobberedDates ); + + MYDates = [ + ['December 2010', false, '99999999', 'Plain month year'], + ['Dec 2010', false, '99999999', 'Abreviated month year'], + ['12 2010', false, '99999999', 'Numeric month year'] + ]; + parserTest( 'MY Dates', 'date', MYDates ); + + YDates = [ + ['2010', false, '99999999', 'Plain 4-digit year'], + ['876', false, '99999999', '3-digit year'], + ['76', false, '99999999', '2-digit year'], + ['\'76', false, '99999999', '2-digit millenium bug year'], + ['2010 BC', false, '99999999', '4-digit year BC'] + ]; + parserTest( 'Y Dates', 'date', YDates ); + + currencyData = [ + ['1.02 $', true, 1.02, ''], + ['$ 3.00', true, 3, ''], + ['€ 2,99', true, 299, ''], + ['$ 1.00', true, 1, ''], + ['$3.50', true, 3.50, ''], + ['$ 1.50', true, 1.50, ''], + ['€ 0.99', true, 0.99, ''], + ['$ 299.99', true, 299.99, ''], + ['$ 2,299.99', true, 2299.99, ''], + ['$ 2,989', true, 2989, ''], + ['$ 2 299.99', true, 2299.99, ''], + ['$ 2 989', true, 2989, ''], + ['$ 2.989', true, 2.989, ''] + ]; + parserTest( 'Currency', 'currency', currencyData ); + + transformedCurrencyData = [ + ['1.02 $', true, 102, ''], + ['$ 3.00', true, 300, ''], + ['€ 2,99', true, 2.99, ''], + ['$ 1.00', true, 100, ''], + ['$3.50', true, 350, ''], + ['$ 1.50', true, 150, ''], + ['€ 0.99', true, 99, ''], + ['$ 299.99', true, 29999, ''], + ['$ 2\'299,99', true, 2299.99, ''], + ['$ 2,989', true, 2.989, ''], + ['$ 2 299.99', true, 229999, ''], + ['2 989 $', true, 2989, ''], + ['299.99 $', true, 29999, ''], + ['2\'299,99 $', true, 2299.99, ''], + ['2,989 $', true, 2.989, ''], + ['2 299.99 $', true, 229999, ''], + ['2 989 $', true, 2989, ''] + ]; + parserTest( 'Currency with european separators', 'currency', transformedCurrencyData, function () { + mw.config.set( { + // We expect 22'234.444,22 + // Map from ascii separators => localized separators + wgSeparatorTransformTable: [', . ,', '\' , .'], + wgDigitTransformTable: ['', ''] + } ); + } ); + + // TODO add numbers sorting tests for bug 8115 with a different language + +}( jQuery, mediaWiki ) ); diff --git a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js index 92dad9ff..f63aa27a 100644 --- a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js @@ -156,9 +156,29 @@ ]; QUnit.module( 'jquery.tablesorter', QUnit.newMwEnvironment( { + setup: function () { + this.liveMonths = mw.language.months; + mw.language.months = { + 'keys': { + 'names': ['january', 'february', 'march', 'april', 'may_long', 'june', + 'july', 'august', 'september', 'october', 'november', 'december'], + 'genitive': ['january-gen', 'february-gen', 'march-gen', 'april-gen', 'may-gen', 'june-gen', + 'july-gen', 'august-gen', 'september-gen', 'october-gen', 'november-gen', 'december-gen'], + 'abbrev': ['jan', 'feb', 'mar', 'apr', 'may', 'jun', + 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'] + }, + 'names': ['January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December'], + 'genitive': ['January', 'February', 'March', 'April', 'May', 'June', + 'July', 'August', 'September', 'October', 'November', 'December'], + 'abbrev': ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] + }; + }, + teardown: function () { + mw.language.months = this.liveMonths; + }, config: { - wgMonthNames: ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], - wgMonthNamesShort: ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], wgDefaultDateFormat: 'dmy', wgSeparatorTransformTable: ['', ''], wgDigitTransformTable: ['', ''], @@ -1160,11 +1180,11 @@ '' ); $table.tablesorter(); - assert.equal( $table.find( '#A2' ).prop( 'headerIndex' ), + assert.equal( $table.find( '#A2' ).data( 'headerIndex' ), undefined, 'A2 should not be a sort header' ); - assert.equal( $table.find( '#C1' ).prop( 'headerIndex' ), + assert.equal( $table.find( '#C1' ).data( 'headerIndex' ), 2, 'C1 should be a sort header' ); @@ -1181,11 +1201,11 @@ '' ); $table.tablesorter(); - assert.equal( $table.find( '#C2' ).prop( 'headerIndex' ), + assert.equal( $table.find( '#C2' ).data( 'headerIndex' ), 2, 'C2 should be a sort header' ); - assert.equal( $table.find( '#C1' ).prop( 'headerIndex' ), + assert.equal( $table.find( '#C1' ).data( 'headerIndex' ), undefined, 'C1 should not be a sort header' ); @@ -1209,18 +1229,19 @@ // bug 53211 - exploding rowspans in more complex cases QUnit.test( 'Rowspan exploding with row headers and colspans', 1, function ( assert ) { - var $table = $( '' + - '' + - '' + - '' + - '' + - '' + - '
nfoobaz
foobar
1foobarbaz
2foobarbaz
' ); + var $table = $( '' + + '' + + '' + + '' + + '' + + '' + + '
nfoobaz
foobar
1foobarbaz
2foobarbaz
' ); $table.tablesorter(); - assert.equal( $table.find( 'tr:eq(1) th:eq(1)').prop('headerIndex'), + assert.equal( $table.find( 'tr:eq(1) th:eq(1)').data('headerIndex'), 2, - 'Incorrect index of sort header' ); + 'Incorrect index of sort header' + ); } ); -- cgit v1.2.3-54-g00ecf