How to use faux-jax - 5 common examples

To help you get started, we’ve selected a few faux-jax examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github algolia / algoliasearch-client-javascript / test / spec / browser / request-strategy / handles-JSONP-syntax-error.js View on Github external
}, function run(err, res, body) {
    t.error(err, 'No error while calling /1/indexes/JSONP-syntax-error/reset');
    t.deepEqual(body, {calls: 0}, 'No JSONP calls done');

    fauxJax.install();

    index.search('JSONP Failure', searchCallback);

    fauxJax.on('request', function(req) {
      // we should pass here as much time as the number of hosts (2)
      t.pass();
      // simulate network error
      req.onerror();
    });
  });
github algolia / algoliasearch-client-javascript / test / spec / browser / request-strategy / uses-JSONP.js View on Github external
}, function run(err) {
    t.error(err, 'No error while reseting the /1/indexes/request-strategy-uses-JSONP route');

    fauxJax.install();

    index.search('hello', searchCallback);

    fauxJax.on('request', function(req) {
      nbRequests++;
      req.respond(500, {}, JSON.stringify({message: 'Try again', status: 500}));
    });
  });
});
github algolia / algoliasearch-client-javascript / test / spec / browser / request-strategy / slow-JSONP-response.js View on Github external
}, function run(err) {
      t.error(err, 'No error while reseting the /1/indexes/slow-response route');

      fauxJax.install();
      fauxJax.on('request', function(req) {
        req.respond(500, {}, JSON.stringify({status: 500, message: 'woops!'}));
      });
      index.search('hello', searchCallback);
    });
  });
github algolia / algoliasearch-client-javascript / test / spec / browser / jquery.js View on Github external
index.search('jquery-timeout-promise').then(function searchDone(content) {
    fauxJax.restore();

    t.deepEqual(
      content, {
        yaw: 'JQUERY! timeout'
      },
      'Content matches'
    );
  });
github algolia / algoliasearch-client-javascript / test / spec / browser / angular.js View on Github external
index.search('angular-first').then(function searchDone(content) {
        fauxJax.restore();

        t.deepEqual(
          content, {
            message: 'YEAH!'
          },
          'Content matches'
        );
      });

faux-jax

Intercept and respond to requests in the browser (XMLHttpRequest, XDomainRequest) and Node.js (http(s) module)

MIT
Latest version published 8 years ago

Package Health Score

48 / 100
Full package analysis

Popular faux-jax functions