-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bfc1858
commit a8f80f6
Showing
3 changed files
with
94 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
88 changes: 88 additions & 0 deletions
88
force-app/main/default/classes/SplitStringInvocableTest.cls
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
@IsTest | ||
private class SplitStringInvocableTest { | ||
private static final String INPUT_TEXT_SEMICOLONS = 'monday;tuesday;wednesday;thursday;friday'; | ||
private static final String INPUT_TEXT_COMMAS = 'monday,tuesday,wednesday,thursday,friday'; | ||
private static final List<String> WEEK_DAYS; | ||
|
||
static { | ||
WEEK_DAYS = INPUT_TEXT_SEMICOLONS.split(';'); | ||
} | ||
|
||
@IsTest | ||
static void it_should_return_list_of_string_given_a_semi_colon_delimited_string() { | ||
List<SplitStringInvocable.Request> requests = new List<SplitStringInvocable.Request>(); | ||
SplitStringInvocable.Request request = new SplitStringInvocable.Request(); | ||
request.inputText = INPUT_TEXT_SEMICOLONS; | ||
request.delimiter = ';'; | ||
requests.add(request); | ||
|
||
Test.startTest(); | ||
|
||
List<List<String>> result = SplitStringInvocable.execute(requests); | ||
|
||
Test.stopTest(); | ||
|
||
System.Assert.isFalse(result.isEmpty()); | ||
System.Assert.areEqual(1, result.size()); | ||
|
||
List<String> stringList = result.get(0); | ||
System.Assert.isFalse(stringList.isEmpty()); | ||
System.Assert.areEqual(5, stringList.size()); | ||
System.Assert.areEqual(WEEK_DAYS, stringList); | ||
} | ||
|
||
@IsTest | ||
static void it_should_return_list_of_string_given_a_comma_delimited_string() { | ||
List<SplitStringInvocable.Request> requests = new List<SplitStringInvocable.Request>(); | ||
SplitStringInvocable.Request request = new SplitStringInvocable.Request(); | ||
request.inputText = INPUT_TEXT_COMMAS; | ||
request.delimiter = ','; | ||
requests.add(request); | ||
|
||
Test.startTest(); | ||
|
||
List<List<String>> result = SplitStringInvocable.execute(requests); | ||
|
||
Test.stopTest(); | ||
|
||
System.Assert.isFalse(result.isEmpty()); | ||
System.Assert.areEqual(1, result.size()); | ||
|
||
List<String> stringList = result.get(0); | ||
System.Assert.isFalse(stringList.isEmpty()); | ||
System.Assert.areEqual(5, stringList.size()); | ||
System.Assert.areEqual(WEEK_DAYS, stringList); | ||
} | ||
|
||
@IsTest | ||
static void it_should_handle_multiple_requests() { | ||
List<SplitStringInvocable.Request> requests = new List<SplitStringInvocable.Request>(); | ||
SplitStringInvocable.Request r1 = new SplitStringInvocable.Request(); | ||
r1.inputText = INPUT_TEXT_SEMICOLONS; | ||
r1.delimiter = ';'; | ||
requests.add(r1); | ||
SplitStringInvocable.Request r2 = new SplitStringInvocable.Request(); | ||
r2.inputText = INPUT_TEXT_COMMAS; | ||
r2.delimiter = ','; | ||
requests.add(r2); | ||
|
||
Test.startTest(); | ||
|
||
List<List<String>> result = SplitStringInvocable.execute(requests); | ||
|
||
Test.stopTest(); | ||
|
||
System.Assert.isFalse(result.isEmpty()); | ||
System.Assert.areEqual(2, result.size()); | ||
|
||
List<String> listOne = result.get(0); | ||
System.Assert.isFalse(listOne.isEmpty()); | ||
System.Assert.areEqual(5, listOne.size()); | ||
System.Assert.areEqual(WEEK_DAYS, listOne); | ||
|
||
List<String> listTwo = result.get(1); | ||
System.Assert.isFalse(listTwo.isEmpty()); | ||
System.Assert.areEqual(5, listTwo.size()); | ||
System.Assert.areEqual(WEEK_DAYS, listTwo); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
force-app/main/default/classes/SplitStringInvocableTest.cls-meta.xml
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata"> | ||
<apiVersion>59.0</apiVersion> | ||
<status>Active</status> | ||
</ApexClass> |