stub in javascript

Solutions on MaxInterview for stub in javascript by the best coders in the world

showing results for - "stub in javascript"
Chris
27 Nov 2016
1function getCharacters(callback) {
2  $.get('http://api.example.com/characters', callback);
3}
4
Diego Alejandro
31 Sep 2017
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