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

177 lines
5.0 KiB
JavaScript
Raw Normal View History

/**
* Tests ServerSideQuote
*
* Copyright (C) 2010-2019 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';
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;
describe( 'ServerSideQuote', () =>
{
describe( 'accessors & mutators', () =>
{
[
{
property: 'startDate',
2019-11-07 13:33:14 -05:00
default: 0,
value: 946684800
},
{
property: 'initialRatedDate',
2019-11-07 13:33:14 -05:00
default: 0,
value: 946684800
},
{
property: 'agentId',
2019-11-07 13:33:14 -05:00
default: 0,
value: 12345678
},
{
property: 'agentEntityId',
2019-11-07 13:33:14 -05:00
default: 0,
value: 12345678
},
{
property: 'agentName',
2019-11-07 13:33:14 -05:00
default: '',
value: 'name'
},
{
property: 'imported',
2019-11-07 13:33:14 -05:00
default: false,
value: true,
accessor: 'is'
},
{
property: 'bound',
2019-11-07 13:33:14 -05:00
default: false,
value: true,
accessor: 'is'
},
{
property: 'currentStepId',
2019-11-07 13:33:14 -05:00
default: 1,
value: 2
},
{
property: 'topVisitedStepId',
2019-11-07 13:33:14 -05:00
default: 1,
value: 2
},
{
property: 'topSavedStepId',
2019-11-07 13:33:14 -05:00
value: 1
},
{
property: 'error',
2019-11-07 13:33:14 -05:00
default: '',
value: 'ERROR'
},
{
property: 'programVersion',
2019-11-07 13:33:14 -05:00
default: '',
value: '1.0.0'
},
{
property: 'creditScoreRef',
2019-11-07 13:33:14 -05:00
default: 0,
value: 800
},
{
property: 'lastPremiumDate',
2019-11-07 13:33:14 -05:00
default: 0,
value: 946684800
},
{
property: 'ratedDate',
2019-11-07 13:33:14 -05:00
default: 0,
value: 946684800
},
{
property: 'rateBucket',
default: null,
value: QuoteDataBucket()
},
].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 );
} );
} );
} );