use of org.edx.mobile.user.Account in project edx-app-android by edx.
the class UserProfileInteractorTest method whenProfileObserved_withInvalidLanguageCode_emitsProfileWithNoLanguage.
@Test
public void whenProfileObserved_withInvalidLanguageCode_emitsProfileWithNoLanguage() {
final Account account = configureBareMockAccount();
when(account.getLanguageProficiencies()).thenReturn(Collections.singletonList(new LanguageProficiency(ProfileValues.INVALID_LANGUAGE_CODE)));
createAndObserveInteractor();
verify(profileObserver).onData(refEq(new UserProfileViewModel(UserProfileViewModel.LimitedProfileMessage.NONE, null, null, new UserProfileBioModel(UserProfileBioModel.ContentType.NO_ABOUT_ME, null))));
}
use of org.edx.mobile.user.Account in project edx-app-android by edx.
the class UserProfileInteractorTest method whenProfileObserved_withNoAboutMe_withPrivateAccount_asAnonymousUser_emitsLimitedProfileMessageAndEmptyContent.
@Test
public void whenProfileObserved_withNoAboutMe_withPrivateAccount_asAnonymousUser_emitsLimitedProfileMessageAndEmptyContent() throws Exception {
final Account account = configureBareMockAccount();
when(account.getAccountPrivacy()).thenReturn(Account.Privacy.PRIVATE);
createAndObserveInteractor();
verify(profileObserver).onData(refEq(new UserProfileViewModel(UserProfileViewModel.LimitedProfileMessage.OTHER_USERS_PROFILE, null, null, new UserProfileBioModel(UserProfileBioModel.ContentType.EMPTY, null))));
}
use of org.edx.mobile.user.Account in project edx-app-android by edx.
the class UserProfileInteractorTest method onAccountUpdatedEvent_withMatchingUsername_emitsUpdatedProfileContent.
@Test
public void onAccountUpdatedEvent_withMatchingUsername_emitsUpdatedProfileContent() throws Exception {
final Account account = configureBareMockAccount();
createAndObserveInteractor();
verify(profileObserver).onData(refEq(new UserProfileViewModel(UserProfileViewModel.LimitedProfileMessage.NONE, null, null, new UserProfileBioModel(UserProfileBioModel.ContentType.NO_ABOUT_ME, null))));
when(account.getBio()).thenReturn(ProfileValues.ABOUT_ME);
eventBus.post(new AccountDataLoadedEvent(account));
verify(profileObserver).onData(refEq(new UserProfileViewModel(UserProfileViewModel.LimitedProfileMessage.NONE, null, null, new UserProfileBioModel(UserProfileBioModel.ContentType.ABOUT_ME, ProfileValues.ABOUT_ME))));
}
use of org.edx.mobile.user.Account in project edx-app-android by edx.
the class UserProfileInteractorTest method whenProfileObserved_withParentalConsentRequired_asAnonymousUser_showsNoAboutMe.
@Test
public void whenProfileObserved_withParentalConsentRequired_asAnonymousUser_showsNoAboutMe() {
final Account account = configureBareMockAccount();
when(account.requiresParentalConsent()).thenReturn(true);
createAndObserveInteractor();
verify(profileObserver).onData(refEq(new UserProfileViewModel(UserProfileViewModel.LimitedProfileMessage.OTHER_USERS_PROFILE, null, null, new UserProfileBioModel(UserProfileBioModel.ContentType.NO_ABOUT_ME, null))));
}
use of org.edx.mobile.user.Account in project edx-app-android by edx.
the class UserProfileInteractorTest method configureBareMockAccount.
@NonNull
private Account configureBareMockAccount() {
final Account account = mock(Account.class);
when(account.getUsername()).thenReturn(ProfileValues.USERNAME);
when(account.getProfileImage()).thenReturn(mock(ProfileImage.class));
when(userService.getAccount(ProfileValues.USERNAME)).thenReturn(Calls.response(account));
return account;
}
Aggregations