1function getCharacters(callback) {
2 $.get('http://api.example.com/characters', callback);
3}
4
1describe('getCharacters()', function () {
2 it('should get the characters from an external API', function () {
3 const spy = sinon.spy();
4 const fakedGet = sinon.stub($, 'get');
5 fakedGet.yields();
6
7 getCharacters(spy);
8 expect(spy.calledOnce).toBeTruthy();
9 });
10});
11