2019-06-11 14:42:31 -04:00
|
|
|
/**
|
|
|
|
* Tests RateEventHandler
|
|
|
|
*
|
2019-08-30 09:41:33 -04:00
|
|
|
* Copyright (C) 2010-2019 R-T Specialty, LLC.
|
2019-06-11 14:42:31 -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';
|
|
|
|
|
|
|
|
const { expect } = require( 'chai' );
|
|
|
|
const Sut = require( '../../..' ).client.event.RateEventHandler;
|
|
|
|
|
|
|
|
describe( 'RateEventHandler', () =>
|
|
|
|
{
|
2019-06-12 17:51:31 -04:00
|
|
|
describe( "Handle Rating Event with all conditions met for clean rating", () =>
|
2019-06-11 14:42:31 -04:00
|
|
|
{
|
|
|
|
it( "calls #handle to do the rating", done =>
|
|
|
|
{
|
2019-06-12 17:51:31 -04:00
|
|
|
let test_init_date = false;
|
|
|
|
let test_last_prem_date = false;
|
|
|
|
let test_lock_quote = false;
|
|
|
|
|
|
|
|
const stepId = 1;
|
|
|
|
const lockStep = 0;
|
2019-06-11 14:42:31 -04:00
|
|
|
const indv = "somerater";
|
2019-06-12 17:51:31 -04:00
|
|
|
const initial_rated_date = 111;
|
|
|
|
const last_premium_date = 222;
|
2019-06-11 14:42:31 -04:00
|
|
|
|
|
|
|
const quote = {
|
|
|
|
getExplicitLockStep: () => lockStep,
|
2019-06-12 17:51:31 -04:00
|
|
|
setLastPremiumDate: given =>
|
|
|
|
{
|
|
|
|
expect( given ).to.equal( last_premium_date );
|
|
|
|
test_init_date = true;
|
|
|
|
},
|
|
|
|
setInitialRatedDate: given =>
|
|
|
|
{
|
|
|
|
expect( given ).to.equal( initial_rated_date );
|
|
|
|
test_last_prem_date = true;
|
|
|
|
},
|
2019-06-11 14:42:31 -04:00
|
|
|
getCurrentStepId: () => stepId,
|
|
|
|
refreshData: () => {},
|
2019-06-12 17:51:31 -04:00
|
|
|
isLocked: given =>
|
|
|
|
{
|
|
|
|
test_lock_quote = true;
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
getId: () => "111111"
|
2019-06-11 14:42:31 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
const step = {
|
|
|
|
invalidate: () => {}
|
|
|
|
};
|
|
|
|
|
|
|
|
const ui = {
|
|
|
|
getStep: ( dest ) => step
|
|
|
|
};
|
|
|
|
|
|
|
|
const client = {
|
2019-06-12 17:51:31 -04:00
|
|
|
showRatingInProgressDialog: () => "Some Dialog",
|
2019-06-11 14:42:31 -04:00
|
|
|
getQuote: () => quote,
|
|
|
|
isSaving: () => false,
|
|
|
|
once: ( event, callback ) => {},
|
|
|
|
getUi: () => ui
|
|
|
|
};
|
|
|
|
|
|
|
|
const response = {
|
|
|
|
content: {
|
2019-06-12 17:51:31 -04:00
|
|
|
data: "Some Data",
|
|
|
|
initialRatedDate: initial_rated_date,
|
|
|
|
lastRatedDate: last_premium_date
|
2019-06-11 14:42:31 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-06-12 17:51:31 -04:00
|
|
|
const error = null;
|
2019-06-11 14:42:31 -04:00
|
|
|
|
|
|
|
const proxy = {
|
|
|
|
get: ( url, callback ) => callback( response, error )
|
|
|
|
};
|
|
|
|
|
|
|
|
const sut = Sut( client, proxy );
|
|
|
|
|
2019-06-12 17:51:31 -04:00
|
|
|
sut.handle(
|
|
|
|
"",
|
|
|
|
( err, result ) =>
|
|
|
|
{
|
|
|
|
expect( err ).to.equal( error );
|
|
|
|
expect( result ).to.equal( response.content.data );
|
|
|
|
expect( test_init_date ).to.equal( true );
|
|
|
|
expect( test_last_prem_date ).to.equal( true );
|
|
|
|
expect( test_lock_quote ).to.equal( true );
|
|
|
|
done();
|
|
|
|
},
|
|
|
|
{
|
|
|
|
indv: indv,
|
|
|
|
stepId: stepId
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
} )
|
|
|
|
} );
|
|
|
|
|
|
|
|
describe( "Handle Rating Event with locked quote", () =>
|
|
|
|
{
|
|
|
|
it( "calls #handle to do the rating with a locked quote", done =>
|
|
|
|
{
|
|
|
|
|
|
|
|
let test_lock_quote = false;
|
|
|
|
|
|
|
|
const stepId = 1;
|
|
|
|
const lockStep = 0;
|
|
|
|
const indv = "somerater";
|
|
|
|
const error = null;
|
|
|
|
const proxy = {
|
|
|
|
get: ( url, callback ) => callback( response, error )
|
|
|
|
};
|
|
|
|
|
|
|
|
const quote = {
|
|
|
|
getExplicitLockStep: () => lockStep,
|
|
|
|
getCurrentStepId: () => stepId,
|
|
|
|
isLocked: given =>
|
|
|
|
{
|
|
|
|
test_lock_quote = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const client = {
|
|
|
|
getQuote: () => quote,
|
|
|
|
isSaving: () => false,
|
|
|
|
getUi: () => ui
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const sut = Sut( client, proxy );
|
|
|
|
|
|
|
|
sut.handle(
|
|
|
|
"",
|
|
|
|
( err, result ) =>
|
|
|
|
{
|
|
|
|
expect( test_lock_quote ).to.equal( true );
|
|
|
|
done();
|
|
|
|
},
|
|
|
|
{
|
|
|
|
indv: indv,
|
|
|
|
stepId: stepId
|
|
|
|
}
|
|
|
|
)
|
|
|
|
} )
|
|
|
|
} );
|
|
|
|
|
|
|
|
describe( "Handle Rating Event during a save event", () =>
|
|
|
|
{
|
|
|
|
it( "calls #handle to do the rating with a saving quote", done =>
|
|
|
|
{
|
|
|
|
let test_init_date = false;
|
|
|
|
let test_last_prem_date = false;
|
|
|
|
let test_save_quote = false;
|
|
|
|
|
|
|
|
const stepId = 1;
|
|
|
|
const lockStep = 0;
|
|
|
|
const indv = "somerater";
|
|
|
|
const initial_rated_date = 111;
|
|
|
|
const last_premium_date = 222;
|
|
|
|
|
|
|
|
const quote = {
|
|
|
|
getExplicitLockStep: () => lockStep,
|
|
|
|
setLastPremiumDate: given =>
|
|
|
|
{
|
|
|
|
expect( given ).to.equal( last_premium_date );
|
|
|
|
test_init_date = true;
|
|
|
|
},
|
|
|
|
setInitialRatedDate: given =>
|
|
|
|
{
|
|
|
|
expect( given ).to.equal( initial_rated_date );
|
|
|
|
test_last_prem_date = true;
|
|
|
|
},
|
|
|
|
getCurrentStepId: () => stepId,
|
|
|
|
refreshData: () => {},
|
|
|
|
isLocked: () => false,
|
|
|
|
getId: () => "111111"
|
|
|
|
};
|
|
|
|
|
|
|
|
const step = {
|
|
|
|
invalidate: () => {}
|
|
|
|
};
|
|
|
|
|
|
|
|
const ui = {
|
|
|
|
getStep: ( dest ) => step
|
|
|
|
};
|
|
|
|
|
|
|
|
const client = {
|
|
|
|
showRatingInProgressDialog: () => "Some Dialog",
|
|
|
|
getQuote: () => quote,
|
|
|
|
isSaving: given =>
|
|
|
|
{
|
|
|
|
test_save_quote = true;
|
|
|
|
return true;
|
|
|
|
},
|
|
|
|
once: ( event, callback ) => callback(),
|
|
|
|
getUi: () => ui
|
|
|
|
};
|
|
|
|
|
|
|
|
const response = {
|
|
|
|
content: {
|
|
|
|
data: "Some Data",
|
|
|
|
initialRatedDate: initial_rated_date,
|
|
|
|
lastRatedDate: last_premium_date
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const error = null;
|
|
|
|
|
|
|
|
const proxy = {
|
|
|
|
get: ( url, callback ) => callback( response, error )
|
|
|
|
};
|
|
|
|
|
|
|
|
const sut = Sut( client, proxy );
|
|
|
|
|
|
|
|
sut.handle(
|
|
|
|
"",
|
|
|
|
( err, result ) =>
|
|
|
|
{
|
|
|
|
expect( err ).to.equal( error );
|
|
|
|
expect( result ).to.equal( response.content.data );
|
|
|
|
expect( test_init_date ).to.equal( true );
|
|
|
|
expect( test_last_prem_date ).to.equal( true );
|
|
|
|
expect( test_save_quote ).to.equal( true );
|
|
|
|
done();
|
|
|
|
},
|
|
|
|
{
|
|
|
|
indv: indv,
|
|
|
|
stepId: stepId
|
|
|
|
}
|
|
|
|
)
|
2019-06-11 14:42:31 -04:00
|
|
|
} )
|
2019-06-12 17:51:31 -04:00
|
|
|
} );
|
2019-06-11 14:42:31 -04:00
|
|
|
} )
|