Created
July 12, 2017 02:23
-
-
Save khaosdoctor/0a596ed9f47d873ae34a59d2eaff0cb9 to your computer and use it in GitHub Desktop.
Faker example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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