Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @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();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement