jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/373106 )
Change subject: QUnit: Assert amount via method call ...................................................................... QUnit: Assert amount via method call Set the amount of asserts to expect via assert method instead of via (optional) test method second parameter. Ticket: T170515 Change-Id: I0bce92d112421dbff4924ca8faf8e2f2e9a0b0ce --- M README.md M package-lock.json M package.json M tests/qunit/dm/SearchModel.test.js M tests/qunit/ui/NamespaceFilters.test.js M tests/qunit/ui/NamespacePresets.test.js M tests/qunit/ui/SearchPreview.test.js M tests/qunit/ui/TemplateSearch.test.js 8 files changed, 400 insertions(+), 46 deletions(-) Approvals: Gabriel Birke: Looks good to me, approved jenkins-bot: Verified diff --git a/README.md b/README.md index 803aed7..6251622 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,13 @@ Special:Search by providing an advanced parameters form and improving how namespaces for a search query are selected. +## Dependencies + +This is a mediawiki extension. +Consequently its functionality is tested in integration with a mediawiki installation and the global libraries it provides. +The dependencies in `package.json` try to mimic up-to-date versions of these dependencies for e.g. IDE support, but will not +actually be obeyed when using AdvancedSearch in a wiki. + ## Development This project uses [npm](https://docs.npmjs.com/) and [grunt](https://gruntjs.com/) to run diff --git a/package-lock.json b/package-lock.json index de8b7b0..22b1a22 100644 --- a/package-lock.json +++ b/package-lock.json @@ -71,6 +71,16 @@ "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", "dev": true }, + "anymatch": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz", + "integrity": "sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==", + "dev": true, + "requires": { + "micromatch": "2.3.11", + "normalize-path": "2.1.1" + } + }, "argparse": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.9.tgz", @@ -140,6 +150,12 @@ "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", "dev": true }, + "async-each": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", + "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", + "dev": true + }, "autoprefixer": { "version": "6.7.7", "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-6.7.7.tgz", @@ -169,6 +185,12 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "binary-extensions": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.10.0.tgz", + "integrity": "sha1-muuabF6IY4qtFx4Wf1kAq+JINdA=", "dev": true }, "brace-expansion": { @@ -256,6 +278,22 @@ "has-ansi": "2.0.0", "strip-ansi": "3.0.1", "supports-color": "2.0.0" + } + }, + "chokidar": { + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.6.1.tgz", + "integrity": "sha1-L0RHq16W5Q+z14n9kNTHLg5McMI=", + "dev": true, + "requires": { + "anymatch": "1.3.2", + "async-each": "1.0.1", + "glob-parent": "2.0.0", + "inherits": "2.0.3", + "is-binary-path": "1.0.1", + "is-glob": "2.0.1", + "path-is-absolute": "1.0.1", + "readdirp": "2.1.0" } }, "circular-json": { @@ -361,6 +399,15 @@ "resolved": "https://registry.npmjs.org/colors/-/colors-1.1.2.tgz", "integrity": "sha1-FopHAXVran9RoSzgyXv6KMCE7WM=", "dev": true + }, + "commander": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", + "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", + "dev": true, + "requires": { + "graceful-readlink": "1.0.1" + } }, "concat-map": { "version": "0.0.1", @@ -526,6 +573,15 @@ "rimraf": "2.6.1" } }, + "detect-file": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/detect-file/-/detect-file-0.1.0.tgz", + "integrity": "sha1-STXe39lIhkjgBrASlWbpOGcR6mM=", + "dev": true, + "requires": { + "fs-exists-sync": "0.1.0" + } + }, "doctrine": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", @@ -627,6 +683,12 @@ "version": "1.3.16", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.16.tgz", "integrity": "sha1-0OAmc1dUdwkBrjAaIWZMukXZL30=", + "dev": true + }, + "ensure-posix-path": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/ensure-posix-path/-/ensure-posix-path-1.0.2.tgz", + "integrity": "sha1-pls+QtC3HPxYXrd0+ZQ8jZuRsMI=", "dev": true }, "error-ex": { @@ -837,6 +899,12 @@ "clone-regexp": "1.0.0" } }, + "exists-stat": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/exists-stat/-/exists-stat-1.0.0.tgz", + "integrity": "sha1-BmDjUlouidnkRhKUQMJy7foktSk=", + "dev": true + }, "exit": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", @@ -865,6 +933,15 @@ "dev": true, "requires": { "fill-range": "2.2.3" + } + }, + "expand-tilde": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-1.2.2.tgz", + "integrity": "sha1-C4HrqJflo9MdHD0QL48BRB5VlEk=", + "dev": true, + "requires": { + "os-homedir": "1.0.2" } }, "extglob": { @@ -997,6 +1074,12 @@ "samsam": "1.1.2" } }, + "fs-exists-sync": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz", + "integrity": "sha1-mC1ok6+RjnLQjeyehnP/K1qNat0=", + "dev": true + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -1069,6 +1152,28 @@ "is-glob": "2.0.1" } }, + "global-modules": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-0.2.3.tgz", + "integrity": "sha1-6lo77ULG1s6ZWk+KEmm12uIjgo0=", + "dev": true, + "requires": { + "global-prefix": "0.1.5", + "is-windows": "0.2.0" + } + }, + "global-prefix": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-0.1.5.tgz", + "integrity": "sha1-jTvGuNo8qBEqFg2NSW/wRiv+948=", + "dev": true, + "requires": { + "homedir-polyfill": "1.0.1", + "ini": "1.3.4", + "is-windows": "0.2.0", + "which": "1.2.14" + } + }, "globals": { "version": "9.18.0", "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", @@ -1099,6 +1204,12 @@ "version": "4.1.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", + "dev": true + }, + "graceful-readlink": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", + "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", "dev": true }, "grunt": { @@ -1314,6 +1425,15 @@ "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", "dev": true }, + "homedir-polyfill": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/homedir-polyfill/-/homedir-polyfill-1.0.1.tgz", + "integrity": "sha1-TCu8inWJmP7r9e1oWA921GdotLw=", + "dev": true, + "requires": { + "parse-passwd": "1.0.0" + } + }, "hooker": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/hooker/-/hooker-0.2.3.tgz", @@ -1381,6 +1501,12 @@ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, + "ini": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", + "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=", + "dev": true + }, "inquirer": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-0.12.0.tgz", @@ -1425,6 +1551,15 @@ "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", "dev": true + }, + "is-binary-path": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", + "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", + "dev": true, + "requires": { + "binary-extensions": "1.10.0" + } }, "is-buffer": { "version": "1.1.5", @@ -1591,6 +1726,12 @@ "integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=", "dev": true }, + "is-windows": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-0.2.0.tgz", + "integrity": "sha1-3hqm1j6indJIc3tp8f+LgALSEIw=", + "dev": true + }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -1616,6 +1757,12 @@ "version": "2.1.9", "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.1.9.tgz", "integrity": "sha1-8OgK4DmkvWVLXygfyT8EqRSn/M4=", + "dev": true + }, + "js-reporters": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/js-reporters/-/js-reporters-1.2.0.tgz", + "integrity": "sha1-fPLLaYGWaEeQNQ0MTKB/Su2ewX4=", "dev": true }, "js-tokens": { @@ -1811,6 +1958,15 @@ "resolved": "https://registry.npmjs.org/map-obj/-/map-obj-1.0.1.tgz", "integrity": "sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=", "dev": true + }, + "matcher-collection": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/matcher-collection/-/matcher-collection-1.0.4.tgz", + "integrity": "sha1-L2auCGmZbynkPQtiyD3R1D5YF1U=", + "dev": true, + "requires": { + "minimatch": "3.0.4" + } }, "meow": { "version": "3.7.0", @@ -2089,6 +2245,12 @@ "error-ex": "1.3.1" } }, + "parse-passwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", + "integrity": "sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY=", + "dev": true + }, "path-exists": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz", @@ -2279,6 +2441,44 @@ "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", "dev": true }, + "qunitjs": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/qunitjs/-/qunitjs-2.4.0.tgz", + "integrity": "sha1-WPOoHoRmh/Ln9jfFvtycJn+IcmE=", + "dev": true, + "requires": { + "chokidar": "1.6.1", + "commander": "2.9.0", + "exists-stat": "1.0.0", + "findup-sync": "0.4.3", + "js-reporters": "1.2.0", + "resolve": "1.3.2", + "walk-sync": "0.3.1" + }, + "dependencies": { + "findup-sync": { + "version": "0.4.3", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.4.3.tgz", + "integrity": "sha1-QAQ5Kee8YK3wt/SCfExudaDeyhI=", + "dev": true, + "requires": { + "detect-file": "0.1.0", + "is-glob": "2.0.1", + "micromatch": "2.3.11", + "resolve-dir": "0.1.1" + } + }, + "resolve": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.3.2.tgz", + "integrity": "sha1-HwRCyeDLuBNuh7kwX5MvRsfygjU=", + "dev": true, + "requires": { + "path-parse": "1.0.5" + } + } + } + }, "randomatic": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", @@ -2363,6 +2563,18 @@ "safe-buffer": "5.1.1", "string_decoder": "1.0.3", "util-deprecate": "1.0.2" + } + }, + "readdirp": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz", + "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", + "dev": true, + "requires": { + "graceful-fs": "4.1.11", + "minimatch": "3.0.4", + "readable-stream": "2.3.3", + "set-immediate-shim": "1.0.1" } }, "readline2": { @@ -2457,6 +2669,16 @@ "path-parse": "1.0.5" } }, + "resolve-dir": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/resolve-dir/-/resolve-dir-0.1.1.tgz", + "integrity": "sha1-shklmlYC+sXFxJatiUpujMQwJh4=", + "dev": true, + "requires": { + "expand-tilde": "1.2.2", + "global-modules": "0.2.3" + } + }, "resolve-from": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-1.0.1.tgz", @@ -2513,6 +2735,12 @@ "version": "5.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", + "dev": true + }, + "set-immediate-shim": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", + "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", "dev": true }, "shelljs": { @@ -3041,6 +3269,16 @@ "spdx-expression-parse": "1.0.4" } }, + "walk-sync": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/walk-sync/-/walk-sync-0.3.1.tgz", + "integrity": "sha1-VYoWrqyMDbWcAotzxm85doTs5GU=", + "dev": true, + "requires": { + "ensure-posix-path": "1.0.2", + "matcher-collection": "1.0.4" + } + }, "which": { "version": "1.2.14", "resolved": "https://registry.npmjs.org/which/-/which-1.2.14.tgz", diff --git a/package.json b/package.json index 40a3d18..fad174c 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "grunt-eslint": "19.0.0", "grunt-jsonlint": "1.1.0", "grunt-stylelint": "0.7.0", + "qunitjs": "^2.4.0", "sinon": "^1.17.3", "stylelint-config-wikimedia": "0.4.1" } diff --git a/tests/qunit/dm/SearchModel.test.js b/tests/qunit/dm/SearchModel.test.js index eedb3b2..54bf3fb 100644 --- a/tests/qunit/dm/SearchModel.test.js +++ b/tests/qunit/dm/SearchModel.test.js @@ -13,17 +13,23 @@ QUnit.module( 'ext.advancedSearch.dm.SearchModel' ); - QUnit.test( 'Default model has no options', 1, function ( assert ) { + QUnit.test( 'Default model has no options', function ( assert ) { + assert.expect( 1 ); + var model = new SearchModel(); assert.deepEqual( model.getOptions(), {} ); } ); - QUnit.test( 'Default model has article namespace', 1, function ( assert ) { + QUnit.test( 'Default model has article namespace', function ( assert ) { + assert.expect( 1 ); + var model = new SearchModel(); assert.deepEqual( model.getNamespaces(), [ '0' ] ); } ); - QUnit.test( 'Options that were set can be retrieved', 1, function ( assert ) { + QUnit.test( 'Options that were set can be retrieved', function ( assert ) { + assert.expect( 1 ); + var model = new SearchModel(); model.storeOption( 'not', 'octopi' ); model.storeOption( 'prefix', 'Page' ); @@ -41,7 +47,9 @@ return model; } - QUnit.test( 'Setting empty JSON string does nothing', 2, function ( assert ) { + QUnit.test( 'Setting empty JSON string does nothing', function ( assert ) { + assert.expect( 2 ); + var model = createModelWithValues(), expected = createModelWithValues(); model.setAllFromJSON( '' ); @@ -50,7 +58,9 @@ assert.deepEqual( model.getNamespaces(), expected.getNamespaces() ); } ); - QUnit.test( 'Setting invalid JSON string does nothing', 2, function ( assert ) { + QUnit.test( 'Setting invalid JSON string does nothing', function ( assert ) { + assert.expect( 2 ); + var model = createModelWithValues(), expected = createModelWithValues(); model.setAllFromJSON( '{ "unclosed_string": "str }' ); @@ -59,7 +69,9 @@ assert.deepEqual( model.getNamespaces(), expected.getNamespaces() ); } ); - QUnit.test( 'Setting valid JSON overrides previous state', 2, function ( assert ) { + QUnit.test( 'Setting valid JSON overrides previous state', function ( assert ) { + assert.expect( 2 ); + var model = createModelWithValues(); model.setAllFromJSON( '{"options":{"or":[ "fish", "turtle" ],"prefix":"Sea"},"namespaces":["0","2"]}' ); @@ -70,26 +82,34 @@ assert.deepEqual( model.getNamespaces(), [ '0', '2' ] ); } ); - QUnit.test( 'Namespaces default to main namespace out of the box', 1, function ( assert ) { + QUnit.test( 'Namespaces default to main namespace out of the box', function ( assert ) { + assert.expect( 1 ); + var model = new SearchModel(); assert.deepEqual( model.getNamespaces(), [ SearchModel.MAIN_NAMESPACE ] ); } ); - QUnit.test( 'Setting namespaces to empty keeps default namespace', 1, function ( assert ) { + QUnit.test( 'Setting namespaces to empty keeps default namespace', function ( assert ) { + assert.expect( 1 ); + var model = new SearchModel(); model.setNamespaces( [] ); assert.deepEqual( model.getNamespaces(), [ SearchModel.MAIN_NAMESPACE ] ); } ); - QUnit.test( 'Adding filetype option forces file namespace', 1, function ( assert ) { + QUnit.test( 'Adding filetype option forces file namespace', function ( assert ) { + assert.expect( 1 ); + var model = new SearchModel(); model.storeOption( 'filetype', 'image' ); assert.deepEqual( model.getNamespaces(), [ SearchModel.MAIN_NAMESPACE, SearchModel.FILE_NAMESPACE ] ); } ); - QUnit.test( 'When filetype option is set, file namespace cannot be removed', 1, function ( assert ) { + QUnit.test( 'When filetype option is set, file namespace cannot be removed', function ( assert ) { + assert.expect( 1 ); + var model = new SearchModel(); model.storeOption( 'filetype', 'image' ); model.setNamespaces( [] ); @@ -97,7 +117,9 @@ assert.deepEqual( model.getNamespaces(), [ SearchModel.FILE_NAMESPACE ] ); } ); - QUnit.test( 'File dimension data is reset on filetype change', 2, function ( assert ) { + QUnit.test( 'File dimension data is reset on filetype change', function ( assert ) { + assert.expect( 2 ); + var model = new SearchModel(); model.storeOption( 'filetype', 'jpeg' ); model.storeOption( 'filew', [ '>', '1500' ] ); @@ -109,7 +131,9 @@ assert.deepEqual( model.getOption( 'fileh' ), [ '>', '' ] ); } ); - QUnit.test( 'File dimension data containers reset on filetype remove', 2, function ( assert ) { + QUnit.test( 'File dimension data containers reset on filetype remove', function ( assert ) { + assert.expect( 2 ); + var model = new SearchModel(); model.storeOption( 'filetype', 'video' ); model.storeOption( 'filew', [ '', '800' ] ); @@ -121,7 +145,9 @@ assert.deepEqual( model.getOption( 'fileh' ), [ '>', '' ] ); } ); - QUnit.test( 'File types support dimensions configured', 5, function ( assert ) { + QUnit.test( 'File types support dimensions configured', function ( assert ) { + assert.expect( 5 ); + var model = new SearchModel(); model.storeOption( 'filetype', 'bitmap' ); @@ -140,7 +166,9 @@ assert.notOk( model.filetypeSupportsDimensions() ); } ); - QUnit.test( 'Setting namespace to existing value does not trigger emitUpdate', 1, function ( assert ) { + QUnit.test( 'Setting namespace to existing value does not trigger emitUpdate', function ( assert ) { + assert.expect( 1 ); + var model = new SearchModel(); model.setNamespaces( [ '1', '2', '3' ] ); @@ -150,7 +178,9 @@ assert.notOk( updateSpy.called ); } ); - QUnit.test( 'Changing namespaces triggers emitUpdate', 2, function ( assert ) { + QUnit.test( 'Changing namespaces triggers emitUpdate', function ( assert ) { + assert.expect( 2 ); + var model = new SearchModel(); var updateSpy = sandbox.spy( model, 'emitUpdate' ); @@ -161,7 +191,9 @@ assert.ok( updateSpy.calledTwice ); } ); - QUnit.test( 'Storing an option triggers emitUpdate', 1, function ( assert ) { + QUnit.test( 'Storing an option triggers emitUpdate', function ( assert ) { + assert.expect( 1 ); + var model = new SearchModel(); var updateSpy = sandbox.spy( model, 'emitUpdate' ); @@ -170,7 +202,9 @@ assert.ok( updateSpy.calledOnce ); } ); - QUnit.test( 'Storing an option with the same scalar value does not trigger emitUpdate', 1, function ( assert ) { + QUnit.test( 'Storing an option with the same scalar value does not trigger emitUpdate', function ( assert ) { + assert.expect( 1 ); + var model = new SearchModel(); model.storeOption( 'lorem', 'ipsum' ); @@ -181,7 +215,9 @@ assert.notOk( updateSpy.called ); } ); - QUnit.test( 'Storing an option with the same array value does not trigger emitUpdate', 1, function ( assert ) { + QUnit.test( 'Storing an option with the same array value does not trigger emitUpdate', function ( assert ) { + assert.expect( 1 ); + var model = new SearchModel(); model.storeOption( 'lorem', [ 'hakuna', 'matata' ] ); @@ -192,7 +228,9 @@ assert.notOk( updateSpy.called ); } ); - QUnit.test( 'Removing an option triggers emitUpdate', 1, function ( assert ) { + QUnit.test( 'Removing an option triggers emitUpdate', function ( assert ) { + assert.expect( 1 ); + var model = new SearchModel(); model.storeOption( 'lorem', 'ipsum' ); @@ -203,7 +241,9 @@ assert.ok( updateSpy.calledOnce ); } ); - QUnit.test( 'Removing an unset option does not trigger emitUpdate', 1, function ( assert ) { + QUnit.test( 'Removing an unset option does not trigger emitUpdate', function ( assert ) { + assert.expect( 1 ); + var model = new SearchModel(); model.storeOption( 'lorem', 'ipsum' ); diff --git a/tests/qunit/ui/NamespaceFilters.test.js b/tests/qunit/ui/NamespaceFilters.test.js index 8b3441c..7cd62f0 100644 --- a/tests/qunit/ui/NamespaceFilters.test.js +++ b/tests/qunit/ui/NamespaceFilters.test.js @@ -5,12 +5,16 @@ QUnit.module( 'ext.advancedSearch.ui.NamespaceFilters' ); QUnit.test( 'User namespace icons are set by default', function ( assert ) { + assert.expect( 2 ); + var filter = new NamespaceFilters( new Model(), {} ); assert.equal( filter.getNamespaceIcon( 2 ), 'userAvatar' ); assert.equal( filter.getNamespaceIcon( 3 ), 'userTalk' ); } ); QUnit.test( 'When namespace icons are not set, default icons are returned', function ( assert ) { + assert.expect( 2 ); + var filter = new NamespaceFilters( new Model(), { namespaceIcons: {} } ); @@ -19,6 +23,8 @@ } ); QUnit.test( 'Namespace object key-value-pairs are appended to menu options', function ( assert ) { + assert.expect( 5 ); + var filter = new NamespaceFilters( new Model(), { options: [ { data: 'test', @@ -43,6 +49,8 @@ } ); QUnit.test( 'Namespaces without labels are skipped', function ( assert ) { + assert.expect( 3 ); + var filter = new NamespaceFilters( new Model(), { namespaces: { 0: '', @@ -66,6 +74,8 @@ }; QUnit.test( 'StoreUpdate event handler updates hidden namespace fields', function ( assert ) { + assert.expect( 2 ); + var model = new Model(), filter = new NamespaceFilters( model, { namespaces: { @@ -81,7 +91,9 @@ assert.namespaceElementsPresent( filter.$namespaceContainer, [ '1', '3' ] ); } ); - QUnit.test( 'Lonely namespace can not be removed', 1, function ( assert ) { + QUnit.test( 'Lonely namespace can not be removed', function ( assert ) { + assert.expect( 1 ); + var model = new Model(), filter = new NamespaceFilters( model, { namespaces: { @@ -96,7 +108,9 @@ assert.equal( filter.getItems()[ 0 ].isDisabled(), true ); } ); - QUnit.test( 'On multiple namespaces either one can be removed', 3, function ( assert ) { + QUnit.test( 'On multiple namespaces either one can be removed', function ( assert ) { + assert.expect( 3 ); + var model = new Model(), filter = new NamespaceFilters( model, { namespaces: { @@ -113,7 +127,9 @@ assert.equal( filter.getItems()[ 2 ].isDisabled(), false ); } ); - QUnit.test( 'Value update propagates to model', 1, function ( assert ) { + QUnit.test( 'Value update propagates to model', function ( assert ) { + assert.expect( 1 ); + var model = new Model(), filter = new NamespaceFilters( model, { namespaces: { diff --git a/tests/qunit/ui/NamespacePresets.test.js b/tests/qunit/ui/NamespacePresets.test.js index 2eba4e2..4cd66d2 100644 --- a/tests/qunit/ui/NamespacePresets.test.js +++ b/tests/qunit/ui/NamespacePresets.test.js @@ -12,6 +12,8 @@ } QUnit.test( 'Selecting namespace adds its preset', function ( assert ) { + assert.expect( 1 ); + var model = new Model(), presets = new NamespacePresets( model, { presets: { @@ -26,6 +28,8 @@ } ); QUnit.test( 'Unselecting namespace removes its preset', function ( assert ) { + assert.expect( 1 ); + var model = new Model(), presets = new NamespacePresets( model, { presets: { @@ -41,6 +45,8 @@ } ); QUnit.test( 'Changing the store namespaces to the preset namespaces, selects preset irrespective of order', function ( assert ) { + assert.expect( 4 ); + var model = new Model(), presets = new NamespacePresets( model, { presets: { diff --git a/tests/qunit/ui/SearchPreview.test.js b/tests/qunit/ui/SearchPreview.test.js index 84c89dc..8cdaf1b 100644 --- a/tests/qunit/ui/SearchPreview.test.js +++ b/tests/qunit/ui/SearchPreview.test.js @@ -23,7 +23,9 @@ QUnit.module( 'ext.advancedSearch.ui.SearchPreview' ); - QUnit.test( 'Label gets setup', 1, function ( assert ) { + QUnit.test( 'Label gets setup', function ( assert ) { + assert.expect( 1 ); + config = { label: 'something' }; @@ -32,7 +34,9 @@ assert.equal( 'something', searchPreview.label.getLabel() ); } ); - QUnit.test( 'Store data subscribed to and synced initially', 3, function ( assert ) { + QUnit.test( 'Store data subscribed to and synced initially', function ( assert ) { + assert.expect( 3 ); + var updatePreviewSpy = sandbox.spy( SearchPreview.prototype, 'updatePreview' ); var searchPreview = new SearchPreview( store, config ); @@ -42,7 +46,9 @@ assert.ok( updatePreviewSpy.calledOnce ); } ); - QUnit.test( 'Store state is reflected in preview', 5, function ( assert ) { + QUnit.test( 'Store state is reflected in preview', function ( assert ) { + assert.expect( 5 ); + var generateTagSpy = sandbox.spy( SearchPreview.prototype, 'generateTag' ); store.getOption.withArgs( 'somename' ).returns( 'field one value' ); @@ -62,7 +68,9 @@ assert.ok( generateTagSpy.withArgs( 'another', 'field two value' ).calledOnce ); } ); - QUnit.test( 'Options are correctly selected for preview', 16, function ( assert ) { + QUnit.test( 'Options are correctly selected for preview', function ( assert ) { + assert.expect( 16 ); + var searchPreview = new SearchPreview( store, config ); assert.notOk( searchPreview.skipOptionInPreview( 'plain', 'searchme' ) ); @@ -85,7 +93,9 @@ assert.ok( searchPreview.skipOptionInPreview( 'filew', [ '>', null ] ) ); } ); - QUnit.test( 'Tag is generated', 5, function ( assert ) { + QUnit.test( 'Tag is generated', function ( assert ) { + assert.expect( 5 ); + var messageStub = sandbox.stub( mw, 'msg' ).withArgs( 'advancedsearch-field-somename' ).returns( 'my label:' ); var searchPreview = new SearchPreview( store, config ); var tag = searchPreview.generateTag( 'somename', 'my field value' ); @@ -100,7 +110,9 @@ assert.equal( $( '.oo-ui-labelElement-label', element ).html(), 'my label:' ); } ); - QUnit.test( 'Tag content is HTML-safe', 1, function ( assert ) { + QUnit.test( 'Tag content is HTML-safe', function ( assert ) { + assert.expect( 1 ); + var searchPreview = new SearchPreview( store, config ); var tag = searchPreview.generateTag( 'whatever', '<script>alert("evil");</script>' ); @@ -109,7 +121,9 @@ assert.equal( $( '.content', element ).html(), '<bdi><script>alert("evil");</script></bdi>' ); } ); - QUnit.test( 'Tag label is HTML-safe', 1, function ( assert ) { + QUnit.test( 'Tag label is HTML-safe', function ( assert ) { + assert.expect( 1 ); + sandbox.stub( mw, 'msg' ).withArgs( 'advancedsearch-field-whatever' ).returns( '<div>block</div>' ); var searchPreview = new SearchPreview( store, config ); var tag = searchPreview.generateTag( 'whatever', 'lorem' ); @@ -119,7 +133,9 @@ assert.equal( $( '.oo-ui-labelElement-label', element ).html(), '<div>block</div>' ); } ); - QUnit.test( 'Tag removals clears store', 1, function ( assert ) { + QUnit.test( 'Tag removals clears store', function ( assert ) { + assert.expect( 1 ); + var searchPreview = new SearchPreview( store, config ); var tag = searchPreview.generateTag( 'somename', 'my field value' ); @@ -127,7 +143,9 @@ assert.ok( store.removeOption.withArgs( 'somename' ).calledOnce ); } ); - QUnit.test( 'Showing renders pills', 1, function ( assert ) { + QUnit.test( 'Showing renders pills', function ( assert ) { + assert.expect( 1 ); + config.previewOptions = [ 'one', 'two' ]; store.getOption.withArgs( 'one' ).returns( 'field one value' ); @@ -139,7 +157,9 @@ assert.equal( searchPreview.$element.find( '.mw-advancedSearch-searchPreview-previewPill' ).length, 2 ); } ); - QUnit.test( 'Hiding removes pills', 1, function ( assert ) { + QUnit.test( 'Hiding removes pills', function ( assert ) { + assert.expect( 1 ); + config.previewOptions = [ 'one', 'two' ]; var searchPreview = new SearchPreview( store, config ); @@ -148,7 +168,9 @@ assert.equal( searchPreview.$element.find( '.mw-advancedSearch-searchPreview-previewPill' ).length, 0 ); } ); - QUnit.test( 'Scalar values get formatted well', 3, function ( assert ) { + QUnit.test( 'Scalar values get formatted well', function ( assert ) { + assert.expect( 3 ); + var searchPreview = new SearchPreview( store, config ); assert.equal( searchPreview.formatValue( 'someOption', '' ), '' ); @@ -156,7 +178,9 @@ assert.equal( searchPreview.formatValue( 'someOption', ' stray whitespace ' ), 'stray whitespace' ); } ); - QUnit.test( 'Array values get formatted well', 3, function ( assert ) { + QUnit.test( 'Array values get formatted well', function ( assert ) { + assert.expect( 3 ); + var searchPreview = new SearchPreview( store, config ); assert.equal( searchPreview.formatValue( 'someOption', [ 'some', 'words', 'in', 'combination' ] ), 'some, words, in, combination' ); @@ -164,7 +188,9 @@ assert.equal( searchPreview.formatValue( 'someOption', [ '', ' stray', 'whitespace ' ] ), 'stray, whitespace' ); } ); - QUnit.test( 'Dimension values get formatted well', 5, function ( assert ) { + QUnit.test( 'Dimension values get formatted well', function ( assert ) { + assert.expect( 5 ); + var searchPreview = new SearchPreview( store, config ); var translationStub = sandbox.stub( mw, 'msg' ); translationStub.withArgs( 'advancedSearch-filesize-equals-symbol' ).returns( '=' ); diff --git a/tests/qunit/ui/TemplateSearch.test.js b/tests/qunit/ui/TemplateSearch.test.js index 86d1f66..8ce7e09 100644 --- a/tests/qunit/ui/TemplateSearch.test.js +++ b/tests/qunit/ui/TemplateSearch.test.js @@ -25,7 +25,9 @@ QUnit.module( 'ext.advancedSearch.ui.TemplateSearch' ); - QUnit.test( 'Store data subscribed to and synced initially', 4, function ( assert ) { + QUnit.test( 'Store data subscribed to and synced initially', function ( assert ) { + assert.expect( 4 ); + var setValueSpy = sandbox.spy( TemplateSearch.prototype, 'setValue' ); store.getOption.withArgs( 'hastemplate' ).returns( [ 'Burg' ] ); @@ -37,7 +39,9 @@ assert.deepEqual( templateSearch.getValue(), [ 'Burg' ] ); } ); - QUnit.test( 'Store update is applied', 1, function ( assert ) { + QUnit.test( 'Store update is applied', function ( assert ) { + assert.expect( 1 ); + store.getOption.withArgs( 'hastemplate' ).returns( [ 'from', 'beyond' ] ); var templateSearch = new TemplateSearch( store, config ); @@ -47,12 +51,16 @@ assert.deepEqual( templateSearch.getValue(), [ 'from', 'beyond' ] ); } ); - QUnit.test( 'Mixin method overridden to prevent problems', 1, function ( assert ) { + QUnit.test( 'Mixin method overridden to prevent problems', function ( assert ) { + assert.expect( 1 ); + var templateSearch = new TemplateSearch( store, config ); assert.notOk( templateSearch.isReadOnly() ); } ); - QUnit.test( 'API response processed correctly', 8, function ( assert ) { + QUnit.test( 'API response processed correctly', function ( assert ) { + assert.expect( 8 ); + var templateSearch = new TemplateSearch( store, config ); var apiData = [ @@ -88,7 +96,9 @@ assert.equal( result[ 2 ].getData(), 'Johannes' ); } ); - QUnit.test( 'Items already selected are not suggested', 4, function ( assert ) { + QUnit.test( 'Items already selected are not suggested', function ( assert ) { + assert.expect( 4 ); + var templateSearch = new TemplateSearch( store, config ); templateSearch.setValue( [ 'Jochen', 'Johannes' ] ); var apiData = [ @@ -118,13 +128,17 @@ assert.equal( result[ 0 ].getData(), 'Jens' ); } ); - QUnit.test( 'Page titles post-processes nicely', 2, function ( assert ) { + QUnit.test( 'Page titles post-processes nicely', function ( assert ) { + assert.expect( 2 ); + var templateSearch = new TemplateSearch( store, config ); assert.equal( templateSearch.removeNamespace( 'Test' ), 'Test' ); assert.equal( templateSearch.removeNamespace( 'Template:Test' ), 'Test' ); } ); - QUnit.test( 'Value picked from menu is added to tags and stored', 6, function ( assert ) { + QUnit.test( 'Value picked from menu is added to tags and stored', function ( assert ) { + assert.expect( 6 ); + var templateSearch = new TemplateSearch( store, config ); templateSearch.addTag( 'Preexisting' ); templateSearch.input.setValue( 'My Templ' ); @@ -147,13 +161,17 @@ assert.equal( templateSearch.input.getValue(), '' ); } ); - QUnit.test( 'Native browser autocomplete is not used', 1, function ( assert ) { + QUnit.test( 'Native browser autocomplete is not used', function ( assert ) { + assert.expect( 1 ); + var templateSearch = new TemplateSearch( store, config ); assert.equal( $( templateSearch.$input ).attr( 'autocomplete' ), 'off' ); } ); - QUnit.test( 'Well-formed API request yields result', 4, function ( assert ) { + QUnit.test( 'Well-formed API request yields result', function ( assert ) { + assert.expect( 4 ); + config.api = new mw.Api(); var getStub = sandbox.stub( config.api, 'get' ).withArgs( { action: 'opensearch', @@ -186,7 +204,9 @@ } ); } ); - QUnit.test( 'Empty query does not trigger API request', 3, function ( assert ) { + QUnit.test( 'Empty query does not trigger API request', function ( assert ) { + assert.expect( 3 ); + config.api = new mw.Api(); var getStub = sandbox.stub( config.api, 'get' ); -- To view, visit https://gerrit.wikimedia.org/r/373106 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I0bce92d112421dbff4924ca8faf8e2f2e9a0b0ce Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/AdvancedSearch Gerrit-Branch: master Gerrit-Owner: Pablo Grass (WMDE) <[email protected]> Gerrit-Reviewer: Addshore <[email protected]> Gerrit-Reviewer: Andrew-WMDE <[email protected]> Gerrit-Reviewer: Gabriel Birke <[email protected]> Gerrit-Reviewer: Kai Nissen (WMDE) <[email protected]> Gerrit-Reviewer: Pablo Grass (WMDE) <[email protected]> Gerrit-Reviewer: Tobias Gritschacher <[email protected]> Gerrit-Reviewer: WMDE-Fisch <[email protected]> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
