-
Notifications
You must be signed in to change notification settings - Fork 579
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1503 from JeroenSfdc/patch-11
Create CollectionProcessorsUtilsTest
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...ponents/CollectionProcessors/force-app/main/default/classes/CollectionProcessorsUtilsTest
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,47 @@ | ||
@IsTest | ||
private without sharing class CollectionProcessorsUtilsTest { | ||
|
||
@IsTest | ||
private static void testGetLocalMonthNumbers() { | ||
Map<String, String> results = CollectionProcessorsUtils.getLocalMonthNumbers(); | ||
Assert.areEqual(12, results.size()); | ||
} | ||
|
||
// This does not cover getFormattedValue(fieldValue, fieldType, format) completely! | ||
@IsTest | ||
private static void testGetFormattedValue() { | ||
String fieldType = 'datetime'; | ||
String fieldValue = Datetime.newInstance(2023, 1, 15, 10,0,0) | ||
.format('yyyy-MM-dd\'T\'HH:mm:ss\'Z\''); // pre-formatted | ||
String result = CollectionProcessorsUtils.getFormattedValue(fieldValue, fieldType, 'dd-MM-yyyy'); | ||
Assert.areEqual('2023-01-15T10:00:00Z', result); | ||
|
||
fieldValue = Datetime.newInstance(2023, 1, 15, 10,0,0) | ||
.format(); // in user's locale | ||
result = CollectionProcessorsUtils.getFormattedValue(fieldValue, fieldType, 'dd-MM-yyyy'); | ||
Assert.areEqual('15-01-2023', result); | ||
|
||
fieldType = 'date'; | ||
result = CollectionProcessorsUtils.getFormattedValue(fieldValue, fieldType, 'dd-MM-yyyy'); | ||
Assert.areEqual('15-01-2023', result); | ||
|
||
// Overloaded method without format | ||
result = CollectionProcessorsUtils.getFormattedValue(fieldValue, fieldType); | ||
Assert.areEqual('2023-01-15 10:00:00', result); | ||
} | ||
|
||
@IsTest | ||
private static void testReplaceConstants() { | ||
String sourceString = 'My string $GlobalConstant.True to assert'; | ||
String result = CollectionProcessorsUtils.replaceConstants(sourceString); | ||
Assert.areEqual('My string "true" to assert', result); | ||
} | ||
|
||
@IsTest | ||
private static void testGetFieldTypes() { | ||
Map<String, String> resultMap = new Map<String, String>(); | ||
Account acc = new Account(); | ||
resultMap = CollectionProcessorsUtils.getFieldTypes(acc, new List<String>{'Name', 'Site'}); | ||
Assert.areEqual('{"Site":"STRING","Name":"STRING"}', JSON.serialize(resultMap)); | ||
} | ||
} |