// ajaxAdapterTests
(function (testFns) {
  var breeze = testFns.breeze;
  var core = breeze.core;
  var expectedError = new Error('deliberate error');
  if (testFns.DEBUG_ODATA) {
    // because ajax adapter is not used for OData
    expectedError = new Error('Metadata query failed for: http://localhost:9011/bad/address/$metadata; Not Found');
  }

  var originalAjaxAdapter;

  module("ajaxAdapter", {
    beforeEach: function () {
      //testFns.setup();
      originalAjaxAdapter = breeze.config.getAdapterInstance('ajax');
    },
    afterEach: function () {
      // restore pre-test default adapter instance in case we changed it in a test
      breeze.config.initializeAdapterInstance('ajax', originalAjaxAdapter.name, true);
    }
  });

  /*********************************************************
   * exception in ajax adapter should be caught in promise
   * Because Breeze bug "2590 dataserviceadapter throws if ajax call throws",
   * the exception bubbles out synchronously and the test fails
   *********************************************************/
  test("exception in ajax adapter should be caught in promise", 2, function (assert) {
    var done = assert.async();
    var em = new breeze.EntityManager('/bad/address/');
    var wasCaught = false;

    // Make sure the ajaxAdapter throws when used
    // if you leave this line and bug #2590 is not fixed, the test will fail
    // Regardless, if you comment this out, then the "bad url" will be caught properly
    // and passed to the catch and the test passes
    var ajaxStub = sinon.stub(originalAjaxAdapter, 'ajax').throws(expectedError);
    try {
      breeze.EntityQuery.from("Todos").using(em).execute()
          .catch(function (err) {
            equal(err.message, expectedError.message, "ajax adapter threw expected error");
            ok(true, "the exception was passed to the promise's catch");
          })
          .finally(fin);

    } catch (err) {
      ok(false, "the attempt to query with bad adapter threw sync exception");
      ajaxStub.restore();
      done();
    }

    function fin() {
      ajaxStub.restore();
      done();
    }
  });

  /*********************************************************
   * jQuery ajax adapter default settings are inherited
   *********************************************************/
  testFns.skipIf("odata", "does not use ajax adapter").
  test("jQuery ajax adapter default settings are inherited", 3, function (assert) {
    var done = assert.async();
    // get jQuery ajax adapter and ensure it is the default adapter for this test
    var adapter = breeze.config.getAdapterInstance('ajax', 'jQuery');
    breeze.config.initializeAdapterInstance('ajax', adapter.name, true);

    var ajaxStub = sinon.stub(jQuery, 'ajax').throws(expectedError);

    inheritedDefaultSettingsTest(adapter, ajaxStub, done);
  });

  /*********************************************************
   * Angular ajax adapter default settings are inherited
   *********************************************************/
  testFns.skipIf("odata", "does not use ajax adapter").
  test("Angular ajax adapter default settings are inherited", 3, function (assert) {
    var done = assert.async();
    // get Angular ajax adapter and ensure it is the default adapter for this test
    var adapter = breeze.config.getAdapterInstance('ajax', 'angular');
    breeze.config.initializeAdapterInstance('ajax', adapter.name, true);

    var ajaxStub = sinon.stub(adapter, '$http').throws(expectedError);

    inheritedDefaultSettingsTest(adapter, ajaxStub, done);

  });

  function inheritedDefaultSettingsTest(adapter, ajaxStub, done) {
    // copy the original default settings so can restore at end of test
    var defSettings = adapter.defaultSettings;
    var originalDefaultSettings = core.extend({}, defSettings);
    // add a default header to the default settings that will be used.
    var fooHeader = 'foo header';
    defSettings.headers = { foo_header: fooHeader };

    new breeze.EntityManager('/bad/address/')
        .fetchMetadata() // triggers a call to the server
        .then(unexpectedSuccess, expectedFailure).finally(fin);

    // should fail; we're only interested in how ajax was called
    function expectedFailure(err) {
      equal(err, expectedError, "ajax fn threw expected error");
      var ajaxSettings = ajaxStub.args[0][0]; // 1st arg of 1st call
      ok(ajaxSettings != null, 'ajax was called with a settings object');
      var actualHeader = ajaxSettings.headers && ajaxSettings.headers['foo_header'];
      equal(actualHeader, fooHeader,
              "received expected default 'foo_header' with value: " + fooHeader);
    }

    function fin() {
      // restore
      adapter.defaultSettings = originalDefaultSettings;
      ajaxStub.restore();
      done();
    }
  }

  /////
  function unexpectedSuccess() {
    ok(false, "server request succeeded when it shouldn't; Disaster!");
  }

})(breezeTestFns);
@@ -2431,33 +2431,33 @@
 are inherited%22, 
-3
+4
 , function (asse
@@ -2641,24 +2641,81 @@
  'jQuery');%0A
+    ok(!!adapter, %22Could not load adapter ajax jQuery%22);%0A
     breeze.c
@@ -3214,9 +3214,9 @@
 d%22, 
-3
+4
 , fu
@@ -3339,32 +3339,32 @@
 r for this test%0A
-
     var adapter 
@@ -3414,24 +3414,217 @@
 'angular');%0A
+    // breeze %3E= 2.0 calls it 'angularjs'%0A    adapter = adapter %7C%7C breeze.config.getAdapterInstance('ajax', 'angularjs');%0A    ok(!!adapter, %22Could not load adapter ajax angular or angularjs%22);%0A
     breeze.c

Update ajaxAdapterTests to work with breeze-client 2.x