qunit: Don't assume synchronous Deferred.resolve
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 23 Nov 2016 17:53:28 +0000 (09:53 -0800)
committerBartosz Dziewoński <matma.rex@gmail.com>
Wed, 30 Nov 2016 02:23:31 +0000 (02:23 +0000)
commit1806dcd0eb149c8241ed7c28d9507f60bd5f9bd3
tree57c658cd8c52bd83373468c75a8683a7076bbf9c
parente8ec72c26d1b1ac9a55d2a4d4e24a1d98e400a22
qunit: Don't assume synchronous Deferred.resolve

* mw.loader.test: Most test did this correctly already by returning
  a Promise to QUnit.test, or by using assert.async().
  However two tests did not.

* mediawiki.jqueryMsg.test: Previously the async() handles were
  obtained within the task execution loop. Before jQuery 3.0,
  simple .then() operations when they are already resolved happen
  synchronously, so the current handle was resolved and the next
  handle obtained in the same go and QUnit never saw the state
  as having no unresolved async handles.

  With jQuery 3.0 the test fails because QUnit would end the test
  after the first iteration.

  Fix by simply obtaining all the async() handles when creating the
  list of tasks, instead of within the individual task execution.
  This way they're all reserved and they'll count down as we go.

* mediawiki.api.test: Consistently use 'respondImmediately' for
  the tests that were missing it, and return promise to QUnit.test()

  Also update hardcoded API urls that encoded space as '+', which may
  now be encoded as '%20'.

Bug: T124742
Change-Id: If7ee1c6025be70fecc0a93d4ac155da4db6571ab
tests/qunit/suites/resources/mediawiki.api/mediawiki.ForeignApi.test.js
tests/qunit/suites/resources/mediawiki.api/mediawiki.api.category.test.js
tests/qunit/suites/resources/mediawiki.api/mediawiki.api.messages.test.js
tests/qunit/suites/resources/mediawiki.api/mediawiki.api.options.test.js
tests/qunit/suites/resources/mediawiki.api/mediawiki.api.parse.test.js
tests/qunit/suites/resources/mediawiki.api/mediawiki.api.upload.test.js
tests/qunit/suites/resources/mediawiki.api/mediawiki.api.watch.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.loader.test.js