Last active
October 3, 2019 23:24
-
-
Save shinchit/b66ac5aba45a38be5cc6bbdf14806f18 to your computer and use it in GitHub Desktop.
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
@isTest | |
public with sharing class Some_Test { | |
private static final Map<String, String> lang2key = new Map<String, String>{'English' => 'en_US', 'Japanese' => 'ja', 'Simplefied_Chinese' => 'zh_CN'}; | |
private static User setLang(String lang) { | |
User me = [SELECT Id, LanguageLocaleKey FROM USER WHERE Id = :UserInfo.getUserId() LIMIT 1]; | |
me.LanguageLocaleKey = lang2key.get(lang); | |
update me; | |
return me; | |
} | |
@isTest static void testGetSomeLabel() { | |
Test.startTest(); | |
System.runAs(Some_Test.setLang('English')) { | |
// getSomeLabel(String key) returns key's label. | |
String someLabel = Some.getSomeLabel('key'); | |
System.assertEquals('Key', someLabel, 'label is not correct'); | |
} | |
System.runAs(Some_Test.setLang('Japanese')) { | |
// getSomeLabel(String key) returns key's label. | |
String someLabel = Some.getSomeLabel('key'); | |
System.assertEquals('キー', someLabel, 'ラベルが正しくありません'); | |
} | |
Test.stopTest(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment