<commit_before>const Client             = require('../client');
const { expect, setURL } = require('../../../_common/__tests__/tests_common');
const State              = require('../../../_common/storage').State;
const Url                = require('../../../_common/url');
global.$                 = require('jquery');

describe('Client', () => {
    const loginid_invalid   = 'ZZ123456789';
    const loginid_virtual   = 'VRTC123456789';
    const loginid_real      = 'CR123456789';
    const loginid_gaming    = 'MLT123';
    const loginid_financial = 'MF123';

    const landing_company = { landing_company: { financial_company: { name: 'Binary Investments (Europe) Ltd', shortcode: 'maltainvest' }, gaming_company: { name: 'Binary (Europe) Ltd', shortcode: 'malta' } }, msg_type: 'landing_company' };
    const authorize       = { authorize: { upgradeable_landing_companies: [] }};

    describe('.validateLoginid()', () => {
        it('can detect a valid loginid', () => {
            [loginid_virtual, loginid_real].forEach((id) => {
                Client.set('loginid', id, id);
                Client.set('token', 'test', id);
                expect(Client.isValidLoginid()).to.eq(true);
            });
        });
        it('can detect an invalid loginid', () => {
            Client.set('loginid', loginid_invalid, loginid_invalid);
            Client.set('token', 'test', loginid_invalid);
            expect(Client.isValidLoginid()).to.eq(false);
        });
        after(() => {
            Client.clearAllAccounts();
        });
    });

    describe('.(set|get)()', () => {
        it('sets and gets for expected client', () => {
            Client.set('currency', 'USD', loginid_virtual);
            Client.set('currency', 'EUR', loginid_real);
            expect(Client.get('currency', loginid_virtual)).to.eq('USD');
            expect(Client.get('currency', loginid_real)).to.eq('EUR');
        });
    });

    describe('.getAllLoginids()', () => {<commit_msg>add type checking to client.(set|get)<commit_after>const Client             = require('../client');
const { expect, setURL } = require('../../../_common/__tests__/tests_common');
const State              = require('../../../_common/storage').State;
const Url                = require('../../../_common/url');
global.$                 = require('jquery');

describe('Client', () => {
    const loginid_invalid   = 'ZZ123456789';
    const loginid_virtual   = 'VRTC123456789';
    const loginid_real      = 'CR123456789';
    const loginid_gaming    = 'MLT123';
    const loginid_financial = 'MF123';

    const landing_company = { landing_company: { financial_company: { name: 'Binary Investments (Europe) Ltd', shortcode: 'maltainvest' }, gaming_company: { name: 'Binary (Europe) Ltd', shortcode: 'malta' } }, msg_type: 'landing_company' };
    const authorize       = { authorize: { upgradeable_landing_companies: [] }};

    describe('.validateLoginid()', () => {
        it('can detect a valid loginid', () => {
            [loginid_virtual, loginid_real].forEach((id) => {
                Client.set('loginid', id, id);
                Client.set('token', 'test', id);
                expect(Client.isValidLoginid()).to.eq(true);
            });
        });
        it('can detect an invalid loginid', () => {
            Client.set('loginid', loginid_invalid, loginid_invalid);
            Client.set('token', 'test', loginid_invalid);
            expect(Client.isValidLoginid()).to.eq(false);
        });
        after(() => {
            Client.clearAllAccounts();
        });
    });

    describe('.(set|get)()', () => {
        it('sets and gets for expected client', () => {
            Client.set('currency', 'USD', loginid_virtual);
            Client.set('currency', 'EUR', loginid_real);
            expect(Client.get('currency', loginid_virtual)).to.eq('USD');
            expect(Client.get('currency', loginid_real)).to.eq('EUR');
        });
        it('returns expected data types', () => {
            Client.set('number', 1, loginid_real);
            expect(Client.get('number', loginid_real)).to.be.a('Number').and.to.eq(1);
            Client.set('float', 1.12345, loginid_real);
            expect(Client.get('float', loginid_real)).to.be.a('Number').and.to.eq(1.12345);
            const obj_nested = { a: { b: 'test' } };
            Client.set('object', obj_nested, loginid_real);
            expect(Client.get('object', loginid_real)).to.be.an('Object').and.to.deep.eq(obj_nested);
            Client.set('bool', true, loginid_real);
            expect(Client.get('bool', loginid_real)).to.be.a('boolean').and.to.eq(true);
            Client.set('undef', undefined, loginid_real);
            expect(Client.get('undef', loginid_real)).to.eq(undefined);
        });
    });

    describe('.getAllLoginids()', () => {
{'fraction_non_alphanumeric': 0.18385093167701863, 'fraction_numerical': 0.016563146997929608, 'mean_word_length': 2.4755395683453236, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5926336', 'n_tokens_mistral': 1485, 'n_tokens_neox': 1397, 'n_words': 242}