mediawiki.api: Refactor to use server.respondImmediately
authorTimo Tijhof <krinklemail@gmail.com>
Mon, 6 Jul 2015 14:12:30 +0000 (15:12 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Wed, 8 Jul 2015 10:37:46 +0000 (10:37 +0000)
commit69f0d1d34b26d58c70817d1cfeb52d5b56d05135
treeafbdfad65af631ef29abfed94524d58d2cfc4b47
parent9b4791e260e84f4d8a88edc24f630836a4d040a1
mediawiki.api: Refactor to use server.respondImmediately

* Simplifies code a lot and removes the need to explicitly flush
  and handle the request queue with respond().
  This was especially annoying when a request spawned others as
  they wouldn't be in the queue yet.

* Make tests more explicit and resilient by specifying what they
  respond to instead of assigning to requests[i] directly.
  This also makes the failure better if one request isn't made,
  instead of throwing for accessing properties on undefined objects.

* Avoid relying on test order for badToken().
  Follows-up 7b05096bcae0. Tests should be atomic and not rely on
  order. This is already important as QUnit re-orders failed tests.
  And in the future they may run concurrently.

  Resolve using a unique name (like the other tests).

  Also, the previous test wasn't asserting that badToken() works,
  it was merely asserting that getToken() works and that it wasn't
  yet cached. The new test will fetch and purge its own token.

Change-Id: I26d22ace6c5df19d7144779be1a625aede79749f
tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js