-
Notifications
You must be signed in to change notification settings - Fork 900
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the linkWithCredential API to call the signUp endpoint
- Loading branch information
Showing
4 changed files
with
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ import * as mockFetch from '../../../test/helpers/mock_fetch'; | |
import { ServerError } from '../errors'; | ||
import { | ||
applyActionCode, | ||
linkEmailPassword, | ||
resetPassword, | ||
updateEmailPassword | ||
} from './email_and_password'; | ||
|
@@ -91,6 +92,65 @@ describe('api/account_management/resetPassword', () => { | |
}); | ||
}); | ||
|
||
describe('api/account_management/linkEmailPassword', () => { | ||
const request = { | ||
idToken: 'id-token', | ||
returnSecureToken: true, | ||
email: '[email protected]', | ||
password: 'new-password' | ||
}; | ||
|
||
let auth: TestAuth; | ||
|
||
beforeEach(async () => { | ||
auth = await testAuth(); | ||
mockFetch.setUp(); | ||
}); | ||
|
||
afterEach(mockFetch.tearDown); | ||
|
||
it('should POST to the correct endpoint', async () => { | ||
const mock = mockEndpoint(Endpoint.SIGN_UP, { | ||
idToken: 'id-token' | ||
}); | ||
|
||
const response = await linkEmailPassword(auth, request); | ||
expect(response.idToken).to.eq('id-token'); | ||
expect(mock.calls[0].request).to.eql(request); | ||
expect(mock.calls[0].method).to.eq('POST'); | ||
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq( | ||
'application/json' | ||
); | ||
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq( | ||
'testSDK/0.0.0' | ||
); | ||
}); | ||
|
||
it('should handle errors', async () => { | ||
const mock = mockEndpoint( | ||
Endpoint.SIGN_UP, | ||
{ | ||
error: { | ||
code: 400, | ||
message: ServerError.INVALID_EMAIL, | ||
errors: [ | ||
{ | ||
message: ServerError.INVALID_EMAIL | ||
} | ||
] | ||
} | ||
}, | ||
400 | ||
); | ||
|
||
await expect(linkEmailPassword(auth, request)).to.be.rejectedWith( | ||
FirebaseError, | ||
'Firebase: The email address is badly formatted. (auth/invalid-email).' | ||
); | ||
expect(mock.calls[0].request).to.eql(request); | ||
}); | ||
}); | ||
|
||
describe('api/account_management/updateEmailPassword', () => { | ||
const request = { | ||
idToken: 'id-token', | ||
|
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
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