2019-05-21 14:29:49 -04:00
|
|
|
/**
|
|
|
|
* Tests ServerSideQuote
|
|
|
|
*
|
2019-08-30 09:41:33 -04:00
|
|
|
* Copyright (C) 2010-2019 R-T Specialty, LLC.
|
2019-05-21 14:29:49 -04:00
|
|
|
*
|
|
|
|
* 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';
|
|
|
|
|
2019-11-07 13:33:14 -05:00
|
|
|
const root = require( '../../..' );
|
|
|
|
const Sut = require( '../../..' ).server.quote.ServerSideQuote;
|
|
|
|
const expect = require( 'chai' ).expect;
|
|
|
|
const sinon = require( 'sinon' );
|
|
|
|
|
|
|
|
const {
|
|
|
|
QuoteDataBucket,
|
|
|
|
} = root.bucket;
|
2019-05-21 14:29:49 -04:00
|
|
|
|
|
|
|
describe( 'ServerSideQuote', () =>
|
|
|
|
{
|
|
|
|
describe( 'accessors & mutators', () =>
|
|
|
|
{
|
|
|
|
[
|
|
|
|
{
|
|
|
|
property: 'startDate',
|
2019-11-07 13:33:14 -05:00
|
|
|
default: 0,
|
|
|
|
value: 946684800
|
2019-05-21 14:29:49 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: 'initialRatedDate',
|
2019-11-07 13:33:14 -05:00
|
|
|
default: 0,
|
|
|
|
value: 946684800
|
2019-05-21 14:29:49 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: 'agentId',
|
2019-11-07 13:33:14 -05:00
|
|
|
default: 0,
|
|
|
|
value: 12345678
|
2019-05-21 14:29:49 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: 'agentEntityId',
|
2019-11-07 13:33:14 -05:00
|
|
|
default: 0,
|
|
|
|
value: 12345678
|
2019-05-21 14:29:49 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: 'agentName',
|
2019-11-07 13:33:14 -05:00
|
|
|
default: '',
|
|
|
|
value: 'name'
|
2019-05-21 14:29:49 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: 'imported',
|
2019-11-07 13:33:14 -05:00
|
|
|
default: false,
|
|
|
|
value: true,
|
2019-05-21 14:29:49 -04:00
|
|
|
accessor: 'is'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
property: 'bound',
|
2019-11-07 13:33:14 -05:00
|
|
|
default: false,
|
|
|
|
value: true,
|
2019-05-21 14:29:49 -04:00
|
|
|
accessor: 'is'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
property: 'currentStepId',
|
2019-11-07 13:33:14 -05:00
|
|
|
default: 1,
|
|
|
|
value: 2
|
2019-05-21 14:29:49 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: 'topVisitedStepId',
|
2019-11-07 13:33:14 -05:00
|
|
|
default: 1,
|
|
|
|
value: 2
|
2019-05-21 14:29:49 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: 'topSavedStepId',
|
2019-11-07 13:33:14 -05:00
|
|
|
value: 1
|
2019-05-21 14:29:49 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: 'error',
|
2019-11-07 13:33:14 -05:00
|
|
|
default: '',
|
|
|
|
value: 'ERROR'
|
2019-05-21 14:29:49 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: 'programVersion',
|
2019-11-07 13:33:14 -05:00
|
|
|
default: '',
|
|
|
|
value: '1.0.0'
|
2019-05-21 14:29:49 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: 'creditScoreRef',
|
2019-11-07 13:33:14 -05:00
|
|
|
default: 0,
|
|
|
|
value: 800
|
2019-05-21 14:29:49 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: 'lastPremiumDate',
|
2019-11-07 13:33:14 -05:00
|
|
|
default: 0,
|
|
|
|
value: 946684800
|
2019-05-21 14:29:49 -04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
property: 'ratedDate',
|
2019-11-07 13:33:14 -05:00
|
|
|
default: 0,
|
|
|
|
value: 946684800
|
|
|
|
},
|
|
|
|
{
|
|
|
|
property: 'rateBucket',
|
|
|
|
default: null,
|
|
|
|
value: QuoteDataBucket()
|
|
|
|
},
|
2019-05-21 14:29:49 -04:00
|
|
|
|
|
|
|
].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 );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
} );
|
2019-11-07 13:33:14 -05:00
|
|
|
|
|
|
|
describe( 'rating data', () =>
|
|
|
|
{
|
|
|
|
it( `#setRatingData throws an error if no bucket is set`, () =>
|
|
|
|
{
|
|
|
|
const data = { foo: 'bar' };
|
|
|
|
const sut = Sut();
|
|
|
|
|
|
|
|
expect( function() { sut.setRatingData( data ); } )
|
|
|
|
.to.throw( Error );
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( `Bucket values setters/getters work correctly`, () =>
|
|
|
|
{
|
|
|
|
const data = { foo: 'bar' };
|
|
|
|
let bucket_data = null;
|
|
|
|
const sut = Sut();
|
|
|
|
var called = false;
|
|
|
|
|
|
|
|
const bucket = {
|
|
|
|
setValues( gdata )
|
|
|
|
{
|
|
|
|
expect( gdata ).to.deep.equal( data );
|
|
|
|
|
|
|
|
bucket_data = gdata;
|
|
|
|
called = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
getData()
|
|
|
|
{
|
|
|
|
return bucket_data;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
sut.setRateBucket( bucket );
|
|
|
|
sut.setRatingData( data );
|
|
|
|
|
|
|
|
expect( called ).to.equal( true );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
} );
|