{"size": 1704, "ext": "js", "max_stars_repo_path": "tests/unit/enhanceParametersTest.js", "max_stars_repo_name": "Amarpsp10/App", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "tests/unit/enhanceParametersTest.js", "max_issues_repo_name": "Amarpsp10/App", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/unit/enhanceParametersTest.js", "max_forks_repo_name": "Amarpsp10/App", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 37.8666666667, "max_line_length": 96, "alphanum_fraction": 0.6197183099}
import Onyx from 'react-native-onyx';
import ONYXKEYS from '../../src/ONYXKEYS';
import enhanceParameters from '../../src/libs/Network/enhanceParameters';
import waitForPromisesToResolve from '../utils/waitForPromisesToResolve';
import CONFIG from '../../src/CONFIG';

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 waitForPromisesToResolve()
        .then(() => {
            const finalParameters = enhanceParameters(command, parameters);
            expect(finalParameters).toEqual({
                testParameter: 'test',
                api_setCookie: false,
                email,
                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 waitForPromisesToResolve()
        .then(() => {
            const finalParameters = enhanceParameters(command, parameters);
            expect(finalParameters).toEqual({
                testParameter: 'test',
                api_setCookie: false,
                email,
                authToken,
                referer: CONFIG.EXPENSIFY.EXPENSIFY_CASH_REFERER,
            });
        });
});
