Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include negative Test case Class to cover util class #231

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions classes/strike_tst_lookupController.cls
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,30 @@ private class strike_tst_lookupController {

System.assertEquals(c.Id, record.get('value'));
}

@isTest static void test_negative() {
Account a = new Account(Name='Test Account');
insert a;

Contact c = new Contact(
LastName='Contact',
FirstName='Test',
AccountId = a.Id);
insert c;

String jsonString =
'{"searchField":"FirstName", "subtitleField": "InvalidField", "object": "Contact", "filter": "Name = \'Test Contact\'", "searchTerm": "Test"}';

Test.startTest();
String responseString = strike_lookupController.getRecords(jsonString);
Test.stopTest();

Map<String, Object> response = (Map<String, Object>)JSON.deserializeUntyped(responseString);
Map<string, Object> results = (Map<String, Object>)response.get('results');
List<Object> data =(List<Object>)results.get('data');

System.assertEquals(null, data);
}
}
/* --------------------------------------------------
Copyright 2017 Appiphony, LLC
Expand Down