Created
August 9, 2017 03:13
-
-
Save JitendraZaa/b9ede4702edbdec2720343ad8735fe2f to your computer and use it in GitHub Desktop.
For Blog post
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
| /** | |
| * Author : Jitendra Zaa | |
| * Desc : Test class for Lightning controller WikiHttpRequest | |
| * */ | |
| @isTest | |
| public class MockWikiHttpRequest implements HttpCalloutMock { | |
| // Implement this interface method | |
| public HTTPResponse respond(HTTPRequest req) { | |
| // Create a fake response | |
| HttpResponse res = new HttpResponse(); | |
| res.setHeader('Content-Type', 'application/json'); | |
| res.setBody('["jitendra", ["Jitendra"], ["Jitendra may refer to:"] , ["https://en.wikipedia.org/wiki/Jitendra"] ]'); | |
| res.setStatusCode(200); | |
| return res; | |
| } | |
| @isTest | |
| static void getWikiResponse_Test(){ | |
| Test.setMock(HttpCalloutMock.class, new MockWikiHttpRequest()); | |
| String response = WikiHttpRequest.getWikiResponse('Jitendra',1); | |
| System.assertEquals(response, | |
| '["jitendra", ["Jitendra"], ["Jitendra may refer to:"] , ["https://en.wikipedia.org/wiki/Jitendra"] ]') ; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment