"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * Tests UserSession
 *
 *  Copyright (C) 2010-2020 R-T Specialty, LLC.
 *
 *  This file is part of the Liza Data Collection Framework.
 *
 *  liza is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as
 *  published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
var chai_1 = require("chai");
var UserSession_1 = require("../../../src/server/request/UserSession");
describe('UserSession', function () {
    it('session data is unserialized', function () {
        var session_id = '1234234';
        var session_data = 'agentID|s:6:"900000";retail_agency_num|s:8:"AGT12345";user_name|s:11:"foo@bar.com";agentNAME|s:3:"Foo";';
        var expected_username = 'foo@bar.com';
        var expected_agent_name = 'Foo';
        var expected_agent_id = 900000;
        var expected_agency_num = 'AGT12345';
        var expected_data = {
            agentID: '900000',
            agentNAME: 'Foo',
            retail_agency_num: 'AGT12345',
            user_name: 'foo@bar.com',
        };
        var memcache = {
            get: function (id, callback) {
                chai_1.expect(id).to.be.equal(session_id);
                callback(undefined, session_data);
            },
        };
        var sut = new UserSession_1.UserSession(session_id, memcache);
        chai_1.expect(sut.getData()).to.deep.equal(expected_data);
        chai_1.expect(sut.userName()).to.equal(expected_username);
        chai_1.expect(sut.agentName()).to.equal(expected_agent_name);
        chai_1.expect(sut.agentId()).to.equal(expected_agent_id);
        chai_1.expect(sut.agencyNumber()).to.equal(expected_agency_num);
    });
    describe('UserSession#isInternal', function () {
        [
            {
                label: 'Session is internal',
                agentId: 900000,
                expected: true,
            },
            {
                label: 'Session is not internal',
                agentId: 900001,
                expected: false,
            },
        ].forEach(function (_a) {
            var label = _a.label, agentId = _a.agentId, expected = _a.expected;
            it(label, function () {
                var memcache = {
                    get: function (_, __) { },
                };
                var sut = new UserSession_1.UserSession('', memcache);
                sut.setAgentId(agentId);
                chai_1.expect(sut.agentId()).to.equal(agentId);
                chai_1.expect(sut.isInternal()).to.equal(expected);
            });
        });
    });
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiVXNlclNlc3Npb25UZXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiVXNlclNlc3Npb25UZXN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUE7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7R0FtQkc7QUFDSCw2QkFBNEI7QUFDNUIsdUVBQTJFO0FBRTNFLFFBQVEsQ0FBQyxhQUFhLEVBQUU7SUFDdEIsRUFBRSxDQUFDLDhCQUE4QixFQUFFO1FBQ2pDLElBQU0sVUFBVSxHQUFHLFNBQVMsQ0FBQztRQUM3QixJQUFNLFlBQVksR0FDaEIseUdBQXlHLENBQUM7UUFFNUcsSUFBTSxpQkFBaUIsR0FBRyxhQUFhLENBQUM7UUFDeEMsSUFBTSxtQkFBbUIsR0FBRyxLQUFLLENBQUM7UUFDbEMsSUFBTSxpQkFBaUIsR0FBRyxNQUFNLENBQUM7UUFDakMsSUFBTSxtQkFBbUIsR0FBRyxVQUFVLENBQUM7UUFDdkMsSUFBTSxhQUFhLEdBQUc7WUFDcEIsT0FBTyxFQUFFLFFBQVE7WUFDakIsU0FBUyxFQUFFLEtBQUs7WUFDaEIsaUJBQWlCLEVBQUUsVUFBVTtZQUM3QixTQUFTLEVBQUUsYUFBYTtTQUN6QixDQUFDO1FBRUYsSUFBTSxRQUFRLEdBQUc7WUFDZixHQUFHLEVBQUUsVUFBQyxFQUFPLEVBQUUsUUFBd0M7Z0JBQ3JELGFBQU0sQ0FBQyxFQUFFLENBQUMsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLEtBQUssQ0FBQyxVQUFV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