-
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.
Merge pull request #302 from PermanentOrg/PER-9361-email-and-phone-verif
PER-9361-Email and phone verification are broken;
- Loading branch information
Showing
3 changed files
with
77 additions
and
4 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
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 |
---|---|---|
|
@@ -41,6 +41,32 @@ describe('AccountService', () => { | |
}, | ||
get: (account: AccountVO) => Promise.reject({}), | ||
}, | ||
auth: { | ||
verify: (account, token, type) => { | ||
return new Observable((observer) => { | ||
observer.next( | ||
new AuthResponse({ | ||
isSuccessful: true, | ||
Results: [ | ||
{ | ||
data: [ | ||
{ | ||
AccountVO: { | ||
primaryEmail: '[email protected]', | ||
fullName: 'Test User', | ||
emailStatus: 'status.auth.verified', | ||
phoneStatus: 'status.auth.verified', | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}) | ||
); | ||
observer.complete(); | ||
}); | ||
}, | ||
}, | ||
}) | ||
.mock(Router, { | ||
navigate: (route: string[]) => Promise.resolve(true), | ||
|
@@ -99,4 +125,38 @@ describe('AccountService', () => { | |
expect(error).toEqual(expectedError); | ||
} | ||
}); | ||
|
||
it('should handle successful email verification', async () => { | ||
const { instance } = shallow.createService(); | ||
|
||
const account = new AccountVO({ | ||
primaryEmail: '[email protected]', | ||
fullName: 'Test User', | ||
keepLoggedIn: true, | ||
emailStatus: 'status.auth.unverified', | ||
}); | ||
|
||
instance.setAccount(account); | ||
|
||
await instance.verifyEmail('sampleToken'); | ||
expect(instance.getAccount().emailStatus).toBe('status.auth.verified'); | ||
expect(instance.getAccount().keepLoggedIn).toBeTrue(); | ||
}); | ||
|
||
it('should handle successful phone verification', async () => { | ||
const { instance } = shallow.createService(); | ||
|
||
const account = new AccountVO({ | ||
primaryEmail: '[email protected]', | ||
fullName: 'Test User', | ||
keepLoggedIn: true, | ||
phoneStatus: 'status.auth.unverified', | ||
}); | ||
|
||
instance.setAccount(account); | ||
|
||
await instance.verifyEmail('sampleToken'); | ||
expect(instance.getAccount().phoneStatus).toBe('status.auth.verified'); | ||
expect(instance.getAccount().keepLoggedIn).toBeTrue(); | ||
}); | ||
}); |
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