<commit_before>import { expect } from 'chai';
import { switchAccount } from '../switch_account.js';
import Client from '_common/base/client_base';

global.sessionStorage = window.sessionStorage;
global.localStorage = window.localStorage;

describe('switchAccount', () => {
    const loginid_real = 'MLT79287';
    const loginid_invalid = 'ZZ123456789';

    localStorage.setItem('active_loginid', loginid_real);

    const accounts = {
        MLT79287: {
            'token': "<KEY>",
        },
        MF6097: {
            'token': "<KEY>7IwnTM06M4z",
        }
    };

    localStorage.setItem('client.accounts', JSON.stringify(accounts));

    it('Return nothing when no argument passed or the login id is invalid', () => {
        expect(switchAccount()).to.be.undefined;
        expect(switchAccount(loginid_invalid)).to.be.undefined;
    })

    it('expects item set on the session storage', () => {
        switchAccount(loginid_real);
        expect(sessionStorage.getItem('active_tab')).to.equal('1');
    });

    it('expects the login id change after switching the acount', () => {
        switchAccount(loginid_real);

        expect(Client.get('loginid', loginid_real)).to.eql(loginid_real);
    });

    it('expects item unset on the localstorage', () => {
        switchAccount(loginid_real);

        expect(Client.get('cashier_confirmed', loginid_real)).to.be.undefined;
        expect(Client.get('accepted_bch', loginid_real)).to.be.undefined;
    })
});<commit_msg>added gtm test switch account<commit_after>import { expect } from 'chai';
import { switchAccount } from '../switch_account.js';
import Client from '_common/base/client_base';

global.sessionStorage = window.sessionStorage;
global.localStorage = window.localStorage;

describe('switchAccount', () => {
    const loginid_real = 'MLT79287';
    const loginid_invalid = 'ZZ123456789';

    localStorage.setItem('active_loginid', loginid_real);

    const accounts = {
        MLT79287: {
            'token': "<KEY>",
        },
        MF6097: {
            'token': "<KEY>",
        }
    };

    localStorage.setItem('client.accounts', JSON.stringify(accounts));

    it('Return nothing when no argument passed or the login id is invalid', () => {
        expect(switchAccount()).to.be.undefined;
        expect(switchAccount(loginid_invalid)).to.be.undefined;
    })

    it('expects GTM event set on local storage', () => {
        switchAccount(loginid_real);
        expect(localStorage.getItem('GTM_login')).to.eq('account_switch');
    })

    it('expects item set on the session storage', () => {
        switchAccount(loginid_real);
        expect(sessionStorage.getItem('active_tab')).to.equal('1');
    });

    it('expects the login id change after switching the acount', () => {
        switchAccount(loginid_real);
        expect(Client.get('loginid', loginid_real)).to.eql(loginid_real);
    });

    it('expects item unset on the localstorage', () => {
        switchAccount(loginid_real);
        expect(Client.get('cashier_confirmed', loginid_real)).to.be.undefined;
        expect(Client.get('accepted_bch', loginid_real)).to.be.undefined;
    })
});
{'fraction_non_alphanumeric': 0.14648065948002537, 'fraction_numerical': 0.016487000634115408, 'mean_word_length': 3.310109289617486, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 18, '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': '7320965', 'n_tokens_mistral': 979, 'n_tokens_neox': 930, 'n_words': 175}