User:PerfektesChaos/js/isbnLib/qunit

A qunit test will check functionality of isbnLib.

After loading the code a test suite is executed and results will be displayed in JS console.

Every API function is tested at least by one example.

If no error messages occur the library seems to be fine.

For re-run reload browser page.

Installation

edit
if ( ! mw.loader.getState( "ext.gadget.isbnLib.qunit" ) ) {
   mw.loader.state( { "ext.gadget.isbnLib.qunit": "loading" } );
   mw.loader.load( "https://en.wikipedia.org/w/index.php?"
                   + "title=User:PerfektesChaos/js/"
                   + "isbnLib/qunit.js"
                   + "&bcache=1&maxage=100"
                   + "&action=raw&ctype=text/javascript" );
}

Configuration

edit

An individual test suite may be added to the built-in basic test series.

The following code might be provided before loading:

if ( typeof mw.libs.isbnLib !== "object" ) {
   mw.libs.isbnLib = { };
}
mw.libs.isbnLib.qunit = [ ];

mw.libs.isbnLib.qunit is an Array of objects.

For every object in the Array the following components will be evaluated:

  • f – function to be run; mandatory. Either
    • string – name of a public function in API
    • function – any function defined anywhere
  • a – Array of arguments applied to .f()
  • r – atomic value (boolean number string) to be compared with the result, throwing message indicating mismatch

Codes

edit
Source code
ResourceLoader
  • ext.gadget.isbnLib.qunit
  • Dependencies:
    • ext.gadget.isbnLib/*
mw.libs isbnLib