Skip to content

Instantly share code, notes, and snippets.

@khaosdoctor
Created July 12, 2017 02:23
Show Gist options
  • Save khaosdoctor/0a596ed9f47d873ae34a59d2eaff0cb9 to your computer and use it in GitHub Desktop.
Save khaosdoctor/0a596ed9f47d873ae34a59d2eaff0cb9 to your computer and use it in GitHub Desktop.
Faker example
var xhr, requests;
before(function {
xhr = sinon.useFakeXMLHttpRequest();
requests = [];
xhr.onCreate = function (req) { requests.push(req); };
});
after(function () {
xhr.restore(); // Limpa o objeto quando estamos trabalhando com globais
});
it("Faz uma chamada GET falsa", function () {
getTodos(42, sinon.spy()); // Veja o spy aqui
assert.equals(requests.length, 1);
assert.match(requests[0].url, "/todo/42/items");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment