-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathenhanceParametersTest.ts
47 lines (44 loc) · 1.74 KB
/
enhanceParametersTest.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* eslint-disable @typescript-eslint/naming-convention */
import Onyx from 'react-native-onyx';
import CONFIG from '../../src/CONFIG';
import enhanceParameters from '../../src/libs/Network/enhanceParameters';
import ONYXKEYS from '../../src/ONYXKEYS';
import waitForBatchedUpdates from '../utils/waitForBatchedUpdates';
beforeEach(() => Onyx.clear());
test('Enhance parameters adds correct parameters for Log command with no authToken', () => {
const command = 'Log';
const parameters = {testParameter: 'test'};
const email = 'test-user@test.com';
const authToken = 'test-token';
Onyx.merge(ONYXKEYS.SESSION, {email, authToken});
return waitForBatchedUpdates().then(() => {
const finalParameters = enhanceParameters(command, parameters);
expect(finalParameters).toEqual({
testParameter: 'test',
api_setCookie: false,
email,
isFromDevEnv: true,
platform: 'ios',
referer: CONFIG.EXPENSIFY.EXPENSIFY_CASH_REFERER,
});
});
});
test('Enhance parameters adds correct parameters for a command that requires authToken', () => {
const command = 'Report_AddComment';
const parameters = {testParameter: 'test'};
const email = 'test-user@test.com';
const authToken = 'test-token';
Onyx.merge(ONYXKEYS.SESSION, {email, authToken});
return waitForBatchedUpdates().then(() => {
const finalParameters = enhanceParameters(command, parameters);
expect(finalParameters).toEqual({
testParameter: 'test',
api_setCookie: false,
email,
isFromDevEnv: true,
platform: 'ios',
authToken,
referer: CONFIG.EXPENSIFY.EXPENSIFY_CASH_REFERER,
});
});
});