qunit: Add SinonJS utility
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 5 Feb 2014 05:18:28 +0000 (21:18 -0800)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 11 Feb 2014 10:13:55 +0000 (02:13 -0800)
commit7884ef52f6d7f36418bbcefdf13daf437b408622
tree0cbbabff9fc3536a6d465258139b1002eb1d26e7
parentf1a1cd5d79b23ea70b18de0a08e95861d3f15263
qunit: Add SinonJS utility

To be used in mediawiki.api tests and elsewhere.

For now they are opt-in and disabled by default,
individual tests can enable fake timers, servers and/or
xhrs by calling this.sandbox to access the dedicated
sinon sandbox for that test.

Clock example:

    QUnit.test( 'example', function ( assert ) {
        var clock = this.sandbox.useFakeTimers();

        setTimeout( function () {
            assert.ok( true, 'test' );
        } );

        clock.tick(1);
    } );

Server example:

    QUnit.test( 'example', function ( assert ) {
        this.server = this.sandbox.useFakeServer();

        new mw.Api().getToken( 'foo' ).done( function ( token ) {
            assert.equal( token, '0123abc', 'Token' );
        } );

        // assert.equal( this.server.requests.length, 1, 'Requests' );

        this.server.respond( function ( request ) {
            request.respond( 200, { 'Content-Type': 'application/json' },
                '{ "tokens": { "testactiontoken": "0123abc" } }'
            );
        } );
    } );

Change-Id: I789fb71903f26dbbfe781f010dc5cd3756759943
.jshintignore
resources/sinonjs/sinon-1.8.1.js [new file with mode: 0644]
resources/sinonjs/sinon-ie-1.8.1.js [new file with mode: 0644]
tests/qunit/QUnitTestResources.php
tests/qunit/data/testrunner.js