[DEV-5333] Expose initialRatedDate to the client from the bucket
[DEV-5333] WIP Add RateEventHandlerTest and fix RatingServiceSubmitNotifyTest WIP: Add RateEventHandlerTest Add stubs for RateEventHandlerTest Finish RateEventHandlerTest Move done to fix test bugmaster
parent
2f0fea8f49
commit
723a7f7ff7
|
@ -141,7 +141,7 @@ module.exports = Class( 'RateEventHandler' )
|
|||
this._dataProxy.get( this._genRateUrl( quote, indv ),
|
||||
function( response, err )
|
||||
{
|
||||
var data = ( response.content.data || {} );
|
||||
const { initialRatedDate: initial_rated = 0, data = {} } = response.content || {};
|
||||
|
||||
if ( err )
|
||||
{
|
||||
|
@ -154,6 +154,8 @@ module.exports = Class( 'RateEventHandler' )
|
|||
// save only; no transport is specified)
|
||||
quote.refreshData( data );
|
||||
|
||||
quote.setInitialRatedDate( initial_rated );
|
||||
|
||||
// let subtypes handle additional processing
|
||||
_self.postRate( err, data, _self._client, quote );
|
||||
|
||||
|
|
|
@ -565,6 +565,24 @@ module.exports = Class( 'ClientQuote' )
|
|||
'public proxy getInitialRatedDate': '_quote',
|
||||
|
||||
|
||||
/**
|
||||
* Sets the quote's initial rated date
|
||||
*
|
||||
* @param {number} time initial rated date as a Unix timestamp
|
||||
*
|
||||
* @return {Quote} self
|
||||
*/
|
||||
'public proxy setInitialRatedDate': '_quote',
|
||||
|
||||
|
||||
/**
|
||||
* Returns the quote's expiration date
|
||||
*
|
||||
* @return {number} quote's initial rated date
|
||||
*/
|
||||
'public proxy getExpirationDate': '_quote',
|
||||
|
||||
|
||||
/**
|
||||
* Returns the id of the agent that owns the quote
|
||||
*
|
||||
|
|
|
@ -178,7 +178,8 @@ module.exports = Class( 'RatingService',
|
|||
|
||||
// no need to wait for the save; send the response
|
||||
_self._server.sendResponse( request, quote, {
|
||||
data: cleaned
|
||||
data: cleaned,
|
||||
initialRatedDate: quote.getInitialRatedDate()
|
||||
}, actions );
|
||||
},
|
||||
function( message )
|
||||
|
@ -216,6 +217,7 @@ module.exports = Class( 'RatingService',
|
|||
|
||||
quote.setLastPremiumDate( cur_date );
|
||||
quote.setRatedDate( cur_date );
|
||||
quote.setInitialRatedDate( cur_date );
|
||||
|
||||
function done()
|
||||
{
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
/**
|
||||
* Tests RateEventHandler
|
||||
*
|
||||
* Copyright (C) 2019, 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';
|
||||
|
||||
const { expect } = require( 'chai' );
|
||||
const Sut = require( '../../..' ).client.event.RateEventHandler;
|
||||
|
||||
describe( 'RateEventHandler', () =>
|
||||
{
|
||||
describe( "Handle Rating Event", () =>
|
||||
{
|
||||
it( "calls #handle to do the rating", done =>
|
||||
{
|
||||
const stepId = 0;
|
||||
const lockStep = 1;
|
||||
const indv = "somerater";
|
||||
|
||||
const quote = {
|
||||
getExplicitLockStep: () => lockStep,
|
||||
setInitialRatedDate: ( value ) => {},
|
||||
getCurrentStepId: () => stepId,
|
||||
refreshData: () => {},
|
||||
isLocked: () => false
|
||||
};
|
||||
|
||||
const step = {
|
||||
invalidate: () => {}
|
||||
};
|
||||
|
||||
const ui = {
|
||||
getStep: ( dest ) => step
|
||||
};
|
||||
|
||||
const client = {
|
||||
getQuote: () => quote,
|
||||
isSaving: () => false,
|
||||
once: ( event, callback ) => {},
|
||||
getUi: () => ui
|
||||
};
|
||||
|
||||
const response = {
|
||||
content: {
|
||||
data: "Some Data"
|
||||
}
|
||||
};
|
||||
|
||||
const error = "ERROR";
|
||||
|
||||
const proxy = {
|
||||
get: ( url, callback ) => callback( response, error )
|
||||
};
|
||||
|
||||
const sut = Sut( client, proxy );
|
||||
|
||||
sut.handle( "", function() {}, {
|
||||
indv: indv,
|
||||
stepId: stepId
|
||||
} );
|
||||
done();
|
||||
} )
|
||||
} )
|
||||
} )
|
|
@ -179,8 +179,8 @@ describe( 'RatingServiceSubmitNotify', () =>
|
|||
// only save notification status if we're notifying
|
||||
expect( notify_saved ).to.equal( expected.save );
|
||||
|
||||
done();
|
||||
} );
|
||||
done();
|
||||
} )
|
||||
);
|
||||
} );
|
||||
|
|
Loading…
Reference in New Issue