Skip to content

Commit ff81c1e

Browse files
committed
Add useDeviceLanguage to auth-next (#3273)
1 parent c0b95b7 commit ff81c1e

20 files changed

+264
-151
lines changed

packages-exp/auth-exp/src/api/account_management/account.test.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import * as chaiAsPromised from 'chai-as-promised';
2121
import { ProviderId } from '@firebase/auth-types-exp';
2222
import { FirebaseError } from '@firebase/util';
2323

24-
import { Endpoint } from '../';
24+
import { Endpoint, HttpHeader } from '../';
2525
import { mockEndpoint } from '../../../test/api/helper';
2626
import { testAuth } from '../../../test/mock_auth';
2727
import * as mockFetch from '../../../test/mock_fetch';
@@ -51,10 +51,12 @@ describe('api/account_management/deleteAccount', () => {
5151
await deleteAccount(auth, request);
5252
expect(mock.calls[0].request).to.eql(request);
5353
expect(mock.calls[0].method).to.eq('POST');
54-
expect(mock.calls[0].headers).to.eql({
55-
'Content-Type': 'application/json',
56-
'X-Client-Version': 'testSDK/0.0.0'
57-
});
54+
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
55+
'application/json'
56+
);
57+
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq(
58+
'testSDK/0.0.0'
59+
);
5860
});
5961

6062
it('should handle errors', async () => {
@@ -112,10 +114,12 @@ describe('api/account_management/deleteLinkedAccounts', () => {
112114
expect(response.providerUserInfo[0].email).to.eq('[email protected]');
113115
expect(mock.calls[0].request).to.eql(request);
114116
expect(mock.calls[0].method).to.eq('POST');
115-
expect(mock.calls[0].headers).to.eql({
116-
'Content-Type': 'application/json',
117-
'X-Client-Version': 'testSDK/0.0.0'
118-
});
117+
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
118+
'application/json'
119+
);
120+
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq(
121+
'testSDK/0.0.0'
122+
);
119123
});
120124

121125
it('should handle errors', async () => {
@@ -172,10 +176,12 @@ describe('api/account_management/getAccountInfo', () => {
172176
expect(response.users[0].email).to.eq('[email protected]');
173177
expect(mock.calls[0].request).to.eql(request);
174178
expect(mock.calls[0].method).to.eq('POST');
175-
expect(mock.calls[0].headers).to.eql({
176-
'Content-Type': 'application/json',
177-
'X-Client-Version': 'testSDK/0.0.0'
178-
});
179+
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
180+
'application/json'
181+
);
182+
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq(
183+
'testSDK/0.0.0'
184+
);
179185
});
180186

181187
it('should handle errors', async () => {

packages-exp/auth-exp/src/api/account_management/email_and_password.test.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import * as chaiAsPromised from 'chai-as-promised';
2020

2121
import { FirebaseError } from '@firebase/util';
2222

23-
import { Endpoint } from '../';
23+
import { Endpoint, HttpHeader } from '../';
2424
import { mockEndpoint } from '../../../test/api/helper';
2525
import { testAuth } from '../../../test/mock_auth';
2626
import * as mockFetch from '../../../test/mock_fetch';
@@ -58,10 +58,12 @@ describe('api/account_management/resetPassword', () => {
5858
expect(response.email).to.eq('[email protected]');
5959
expect(mock.calls[0].request).to.eql(request);
6060
expect(mock.calls[0].method).to.eq('POST');
61-
expect(mock.calls[0].headers).to.eql({
62-
'Content-Type': 'application/json',
63-
'X-Client-Version': 'testSDK/0.0.0'
64-
});
61+
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
62+
'application/json'
63+
);
64+
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq(
65+
'testSDK/0.0.0'
66+
);
6567
});
6668

6769
it('should handle errors', async () => {
@@ -115,10 +117,12 @@ describe('api/account_management/updateEmailPassword', () => {
115117
expect(response.idToken).to.eq('id-token');
116118
expect(mock.calls[0].request).to.eql(request);
117119
expect(mock.calls[0].method).to.eq('POST');
118-
expect(mock.calls[0].headers).to.eql({
119-
'Content-Type': 'application/json',
120-
'X-Client-Version': 'testSDK/0.0.0'
121-
});
120+
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
121+
'application/json'
122+
);
123+
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq(
124+
'testSDK/0.0.0'
125+
);
122126
});
123127

124128
it('should handle errors', async () => {
@@ -167,10 +171,12 @@ describe('api/account_management/applyActionCode', () => {
167171
expect(response).to.be.empty;
168172
expect(mock.calls[0].request).to.eql(request);
169173
expect(mock.calls[0].method).to.eq('POST');
170-
expect(mock.calls[0].headers).to.eql({
171-
'Content-Type': 'application/json',
172-
'X-Client-Version': 'testSDK/0.0.0'
173-
});
174+
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
175+
'application/json'
176+
);
177+
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq(
178+
'testSDK/0.0.0'
179+
);
174180
});
175181

176182
it('should handle errors', async () => {

packages-exp/auth-exp/src/api/account_management/mfa.test.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import * as chaiAsPromised from 'chai-as-promised';
2020

2121
import { FirebaseError } from '@firebase/util';
2222

23-
import { Endpoint } from '../';
23+
import { Endpoint, HttpHeader } from '../';
2424
import { mockEndpoint } from '../../../test/api/helper';
2525
import { testAuth } from '../../../test/mock_auth';
2626
import * as mockFetch from '../../../test/mock_fetch';
@@ -59,10 +59,12 @@ describe('api/account_management/startEnrollPhoneMfa', () => {
5959
expect(response.phoneSessionInfo.sessionInfo).to.eq('session-info');
6060
expect(mock.calls[0].request).to.eql(request);
6161
expect(mock.calls[0].method).to.eq('POST');
62-
expect(mock.calls[0].headers).to.eql({
63-
'Content-Type': 'application/json',
64-
'X-Client-Version': 'testSDK/0.0.0'
65-
});
62+
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
63+
'application/json'
64+
);
65+
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq(
66+
'testSDK/0.0.0'
67+
);
6668
});
6769

6870
it('should handle errors', async () => {
@@ -120,10 +122,12 @@ describe('api/account_management/enrollPhoneMfa', () => {
120122
expect(response.idToken).to.eq('id-token');
121123
expect(mock.calls[0].request).to.eql(request);
122124
expect(mock.calls[0].method).to.eq('POST');
123-
expect(mock.calls[0].headers).to.eql({
124-
'Content-Type': 'application/json',
125-
'X-Client-Version': 'testSDK/0.0.0'
126-
});
125+
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
126+
'application/json'
127+
);
128+
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq(
129+
'testSDK/0.0.0'
130+
);
127131
});
128132

129133
it('should handle errors', async () => {
@@ -177,10 +181,12 @@ describe('api/account_management/withdrawMfa', () => {
177181
expect(response.idToken).to.eq('id-token');
178182
expect(mock.calls[0].request).to.eql(request);
179183
expect(mock.calls[0].method).to.eq('POST');
180-
expect(mock.calls[0].headers).to.eql({
181-
'Content-Type': 'application/json',
182-
'X-Client-Version': 'testSDK/0.0.0'
183-
});
184+
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
185+
'application/json'
186+
);
187+
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq(
188+
'testSDK/0.0.0'
189+
);
184190
});
185191

186192
it('should handle errors', async () => {

packages-exp/auth-exp/src/api/account_management/profile.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import * as chaiAsPromised from 'chai-as-promised';
2020

2121
import { FirebaseError } from '@firebase/util';
2222

23-
import { Endpoint } from '../';
23+
import { Endpoint, HttpHeader } from '../';
2424
import { mockEndpoint } from '../../../test/api/helper';
2525
import { testAuth } from '../../../test/mock_auth';
2626
import * as mockFetch from '../../../test/mock_fetch';
@@ -56,10 +56,12 @@ describe('api/account_management/updateProfile', () => {
5656
expect(response.displayName).to.eq('my-name');
5757
expect(mock.calls[0].request).to.eql(request);
5858
expect(mock.calls[0].method).to.eq('POST');
59-
expect(mock.calls[0].headers).to.eql({
60-
'Content-Type': 'application/json',
61-
'X-Client-Version': 'testSDK/0.0.0'
62-
});
59+
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
60+
'application/json'
61+
);
62+
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq(
63+
'testSDK/0.0.0'
64+
);
6365
});
6466

6567
it('should handle errors', async () => {

packages-exp/auth-exp/src/api/authentication/create_auth_uri.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import * as chaiAsPromised from 'chai-as-promised';
2020

2121
import { FirebaseError } from '@firebase/util';
2222

23-
import { Endpoint } from '../';
23+
import { Endpoint, HttpHeader } from '../';
2424
import { mockEndpoint } from '../../../test/api/helper';
2525
import { testAuth } from '../../../test/mock_auth';
2626
import * as mockFetch from '../../../test/mock_fetch';
@@ -54,10 +54,12 @@ describe('api/authentication/createAuthUri', () => {
5454
expect(response.signinMethods).to.include('email');
5555
expect(mock.calls[0].request).to.eql(request);
5656
expect(mock.calls[0].method).to.eq('POST');
57-
expect(mock.calls[0].headers).to.eql({
58-
'Content-Type': 'application/json',
59-
'X-Client-Version': 'testSDK/0.0.0'
60-
});
57+
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
58+
'application/json'
59+
);
60+
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq(
61+
'testSDK/0.0.0'
62+
);
6163
});
6264

6365
it('should handle errors', async () => {

packages-exp/auth-exp/src/api/authentication/custom_token.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import * as chaiAsPromised from 'chai-as-promised';
2121
import { ProviderId } from '@firebase/auth-types-exp';
2222
import { FirebaseError } from '@firebase/util';
2323

24-
import { Endpoint } from '../';
24+
import { Endpoint, HttpHeader } from '../';
2525
import { mockEndpoint } from '../../../test/api/helper';
2626
import { testAuth } from '../../../test/mock_auth';
2727
import * as mockFetch from '../../../test/mock_fetch';
@@ -60,10 +60,12 @@ describe('api/authentication/signInWithCustomToken', () => {
6060
expect(response.localId).to.eq('1234');
6161
expect(mock.calls[0].request).to.eql(request);
6262
expect(mock.calls[0].method).to.eq('POST');
63-
expect(mock.calls[0].headers).to.eql({
64-
'Content-Type': 'application/json',
65-
'X-Client-Version': 'testSDK/0.0.0'
66-
});
63+
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
64+
'application/json'
65+
);
66+
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq(
67+
'testSDK/0.0.0'
68+
);
6769
});
6870

6971
it('should handle errors', async () => {

packages-exp/auth-exp/src/api/authentication/email_and_password.test.ts

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import * as chaiAsPromised from 'chai-as-promised';
2020

2121
import { FirebaseError } from '@firebase/util';
2222

23-
import { Endpoint } from '../';
23+
import { Endpoint, HttpHeader } from '../';
2424
import { mockEndpoint } from '../../../test/api/helper';
2525
import { testAuth } from '../../../test/mock_auth';
2626
import * as mockFetch from '../../../test/mock_fetch';
@@ -66,10 +66,12 @@ describe('api/authentication/signInWithPassword', () => {
6666
expect(response.email).to.eq('[email protected]');
6767
expect(mock.calls[0].request).to.eql(request);
6868
expect(mock.calls[0].method).to.eq('POST');
69-
expect(mock.calls[0].headers).to.eql({
70-
'Content-Type': 'application/json',
71-
'X-Client-Version': 'testSDK/0.0.0'
72-
});
69+
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
70+
'application/json'
71+
);
72+
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq(
73+
'testSDK/0.0.0'
74+
);
7375
});
7476

7577
it('should handle errors', async () => {
@@ -121,10 +123,12 @@ describe('api/authentication/sendEmailVerification', () => {
121123
expect(response.email).to.eq('[email protected]');
122124
expect(mock.calls[0].request).to.eql(request);
123125
expect(mock.calls[0].method).to.eq('POST');
124-
expect(mock.calls[0].headers).to.eql({
125-
'Content-Type': 'application/json',
126-
'X-Client-Version': 'testSDK/0.0.0'
127-
});
126+
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
127+
'application/json'
128+
);
129+
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq(
130+
'testSDK/0.0.0'
131+
);
128132
});
129133

130134
it('should handle errors', async () => {
@@ -176,10 +180,12 @@ describe('api/authentication/sendPasswordResetEmail', () => {
176180
expect(response.email).to.eq('[email protected]');
177181
expect(mock.calls[0].request).to.eql(request);
178182
expect(mock.calls[0].method).to.eq('POST');
179-
expect(mock.calls[0].headers).to.eql({
180-
'Content-Type': 'application/json',
181-
'X-Client-Version': 'testSDK/0.0.0'
182-
});
183+
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
184+
'application/json'
185+
);
186+
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq(
187+
'testSDK/0.0.0'
188+
);
183189
});
184190

185191
it('should handle errors', async () => {
@@ -231,10 +237,12 @@ describe('api/authentication/sendSignInLinkToEmail', () => {
231237
expect(response.email).to.eq('[email protected]');
232238
expect(mock.calls[0].request).to.eql(request);
233239
expect(mock.calls[0].method).to.eq('POST');
234-
expect(mock.calls[0].headers).to.eql({
235-
'Content-Type': 'application/json',
236-
'X-Client-Version': 'testSDK/0.0.0'
237-
});
240+
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
241+
'application/json'
242+
);
243+
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq(
244+
'testSDK/0.0.0'
245+
);
238246
});
239247

240248
it('should handle errors', async () => {

packages-exp/auth-exp/src/api/authentication/email_link.test.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import * as chaiAsPromised from 'chai-as-promised';
2020

2121
import { FirebaseError } from '@firebase/util';
2222

23-
import { Endpoint } from '../';
23+
import { Endpoint, HttpHeader } from '../';
2424
import { mockEndpoint } from '../../../test/api/helper';
2525
import { testAuth } from '../../../test/mock_auth';
2626
import * as mockFetch from '../../../test/mock_fetch';
@@ -60,10 +60,12 @@ describe('api/authentication/email_link', () => {
6060
expect(response.email).to.eq('[email protected]');
6161
expect(mock.calls[0].request).to.eql(request);
6262
expect(mock.calls[0].method).to.eq('POST');
63-
expect(mock.calls[0].headers).to.eql({
64-
'Content-Type': 'application/json',
65-
'X-Client-Version': 'testSDK/0.0.0'
66-
});
63+
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
64+
'application/json'
65+
);
66+
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq(
67+
'testSDK/0.0.0'
68+
);
6769
});
6870

6971
it('should handle errors', async () => {
@@ -109,10 +111,12 @@ describe('api/authentication/email_link', () => {
109111
expect(response.email).to.eq('[email protected]');
110112
expect(mock.calls[0].request).to.eql(request);
111113
expect(mock.calls[0].method).to.eq('POST');
112-
expect(mock.calls[0].headers).to.eql({
113-
'Content-Type': 'application/json',
114-
'X-Client-Version': 'testSDK/0.0.0'
115-
});
114+
expect(mock.calls[0].headers!.get(HttpHeader.CONTENT_TYPE)).to.eq(
115+
'application/json'
116+
);
117+
expect(mock.calls[0].headers!.get(HttpHeader.X_CLIENT_VERSION)).to.eq(
118+
'testSDK/0.0.0'
119+
);
116120
});
117121

118122
it('should handle errors', async () => {

0 commit comments

Comments
 (0)