-
-
Save antonioaguilar/dec7e385eff89ca77fe530665440b197 to your computer and use it in GitHub Desktop.
Revisions
-
pherris revised this gist
Feb 7, 2017 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -60,7 +60,7 @@ var Request = { mockResponse = mockRes; }, __setMockError(mockErr) { mockError = mockErr; } }; -
pherris revised this gist
Apr 17, 2015 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,6 +11,9 @@ var mockResponse = { ok() { return true; }, body: { walla: true }, get: jest.genMockFunction(), toError: jest.genMockFunction() }; -
pherris created this gist
Apr 17, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,64 @@ 'use strict'; //mock for superagent - __mocks__/superagent.js var mockDelay; var mockError; var mockResponse = { status() { return 200; }, ok() { return true; }, get: jest.genMockFunction(), toError: jest.genMockFunction() }; var Request = { post() { return this; }, get() { return this; }, send() { return this; }, query() { return this; }, field() { return this; }, set() { return this; }, accept() { return this; }, timeout() { return this; }, end: jest.genMockFunction().mockImplementation(function(callback) { if (mockDelay) { this.delayTimer = setTimeout(callback, 0, mockError, mockResponse); return; } callback(mockError, mockResponse); }), //expose helper methods for tests to set __setMockDelay(boolValue) { mockDelay = boolValue; }, __setMockResponse(mockRes) { mockResponse = mockRes; }, __setMockError(mockErr) { mockErr = mockErr; } }; module.exports = Request;