1
0
Fork 0
liza/test/server/quote/ServerSideQuoteTest.js

125 lines
3.6 KiB
JavaScript

/**
* Tests ServerSideQuote
*
* Copyright (C) 2017, 2018 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 Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
'use strict';
const { expect } = require( 'chai' );
const Sut = require( '../../..' ).server.quote.ServerSideQuote;
describe( 'ServerSideQuote', () =>
{
describe( 'accessors & mutators', () =>
{
[
{
property: 'startDate',
default: 0,
value: 946684800
},
{
property: 'initialRatedDate',
default: 0,
value: 946684800
},
{
property: 'agentId',
default: 0,
value: 12345678
},
{
property: 'agentEntityId',
default: 0,
value: 12345678
},
{
property: 'agentName',
default: '',
value: 'name'
},
{
property: 'imported',
default: false,
value: true,
accessor: 'is'
},
{
property: 'bound',
default: false,
value: true,
accessor: 'is'
},
{
property: 'currentStepId',
default: 1,
value: 2
},
{
property: 'topVisitedStepId',
default: 1,
value: 2
},
{
property: 'topSavedStepId',
value: 1
},
{
property: 'error',
default: '',
value: 'ERROR'
},
{
property: 'programVersion',
default: '',
value: '1.0.0'
},
{
property: 'creditScoreRef',
default: 0,
value: 800
},
{
property: 'lastPremiumDate',
default: 0,
value: 946684800
},
{
property: 'ratedDate',
default: 0,
value: 946684800
}
].forEach( testCase =>
{
const quote = Sut( 123, {} );
const property = testCase.property;
const title_cased = property.charAt( 0 ).toUpperCase() + property.slice( 1 );
const setter = ( testCase.mutator || 'set' ) + title_cased;
const getter = ( testCase.accessor || 'get' ) + title_cased;
it( property + ' can be mutated and accessed', () =>
{
expect( quote[getter].call( quote ) ).to.equal( testCase.default );
quote[setter].call( quote, testCase.value );
expect( quote[getter].call( quote ) ).to.equal( testCase.value );
} );
} );
} );
} );