Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAustin Schaffer <austin.schaffer@ryansg.com>2019-06-12 17:51:31 -0400
committerChase Gregory <chase.gregory@ryansg.com>2019-06-17 08:28:19 -0400
commit9637fc22e1cbf4d0bf5ff1ea0479b76abf796d49 (patch)
tree543bc53b2625fbaaa4df40753c1d423fff75478e /test
parent23889cbfca570b21d38b2c72aa97aec16acc4ddf (diff)
downloadliza-9637fc22e1cbf4d0bf5ff1ea0479b76abf796d49.tar.gz
liza-9637fc22e1cbf4d0bf5ff1ea0479b76abf796d49.tar.bz2
liza-9637fc22e1cbf4d0bf5ff1ea0479b76abf796d49.zip
[DEV-5333] Pass last rated date from the server quote back to the client quote
Correct and add more elaborate tests for RateEventHandler
Diffstat (limited to 'test')
-rw-r--r--test/client/event/RateEventHandlerTest.js197
-rw-r--r--test/client/quote/ClientQuoteTest.js17
-rw-r--r--test/server/service/RatingServiceSubmitNotifyTest.js2
-rw-r--r--test/server/service/RatingServiceTest.js40
4 files changed, 237 insertions, 19 deletions
diff --git a/test/client/event/RateEventHandlerTest.js b/test/client/event/RateEventHandlerTest.js
index 7cbc3a6..39d8f12 100644
--- a/test/client/event/RateEventHandlerTest.js
+++ b/test/client/event/RateEventHandlerTest.js
@@ -26,20 +26,40 @@ const Sut = require( '../../..' ).client.event.RateEventHandler;
describe( 'RateEventHandler', () =>
{
- describe( "Handle Rating Event", () =>
+ describe( "Handle Rating Event with all conditions met for clean rating", () =>
{
it( "calls #handle to do the rating", done =>
{
- const stepId = 0;
- const lockStep = 1;
+ let test_init_date = false;
+ let test_last_prem_date = false;
+ let test_lock_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,
- setInitialRatedDate: ( value ) => {},
+ 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
+ isLocked: given =>
+ {
+ test_lock_quote = true;
+ return false;
+ },
+ getId: () => "111111"
};
const step = {
@@ -51,6 +71,7 @@ describe( 'RateEventHandler', () =>
};
const client = {
+ showRatingInProgressDialog: () => "Some Dialog",
getQuote: () => quote,
isSaving: () => false,
once: ( event, callback ) => {},
@@ -59,11 +80,13 @@ describe( 'RateEventHandler', () =>
const response = {
content: {
- data: "Some Data"
+ data: "Some Data",
+ initialRatedDate: initial_rated_date,
+ lastRatedDate: last_premium_date
}
};
- const error = "ERROR";
+ const error = null;
const proxy = {
get: ( url, callback ) => callback( response, error )
@@ -71,11 +94,159 @@ describe( 'RateEventHandler', () =>
const sut = Sut( client, proxy );
- sut.handle( "", function() {}, {
- indv: indv,
- stepId: stepId
- } );
- done();
+ 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
+ }
+ )
} )
- } )
+ } );
} )
diff --git a/test/client/quote/ClientQuoteTest.js b/test/client/quote/ClientQuoteTest.js
index 3ad9260..0a249aa 100644
--- a/test/client/quote/ClientQuoteTest.js
+++ b/test/client/quote/ClientQuoteTest.js
@@ -35,16 +35,18 @@ describe( 'ClientQuote', () =>
const agent_name = 'John Doe';
const agent_entity_id = 12434300;
const initial_rated_date = 1531507748;
+ const last_rated_date = 1531508748;
const quote = ClientQuote(
base_quote,
{
- startDate: start_date,
- agentId: agent_id,
- agentName: agent_name,
- agentEntityId: agent_entity_id,
+ startDate: start_date,
+ agentId: agent_id,
+ agentName: agent_name,
+ agentEntityId: agent_entity_id,
initialRatedDate: initial_rated_date,
+ lastRatedDate: last_rated_date,
},
- bucket => bucket
+ bucket => bucket
);
it( 'getStartDate returns base quote startDate', () =>
@@ -71,4 +73,9 @@ describe( 'ClientQuote', () =>
{
expect( quote.getInitialRatedDate() ).to.equal( initial_rated_date );
} );
+
+ it( 'getLastPremiumDate returns base quote lastRatedDate', () =>
+ {
+ expect( quote.getLastPremiumDate() ).to.equal( last_rated_date );
+ } );
} );
diff --git a/test/server/service/RatingServiceSubmitNotifyTest.js b/test/server/service/RatingServiceSubmitNotifyTest.js
index 80e0bc3..d053755 100644
--- a/test/server/service/RatingServiceSubmitNotifyTest.js
+++ b/test/server/service/RatingServiceSubmitNotifyTest.js
@@ -179,8 +179,8 @@ describe( 'RatingServiceSubmitNotify', () =>
// only save notification status if we're notifying
expect( notify_saved ).to.equal( expected.save );
+ done();
} );
- done();
} )
);
} );
diff --git a/test/server/service/RatingServiceTest.js b/test/server/service/RatingServiceTest.js
index 948af9a..2586945 100644
--- a/test/server/service/RatingServiceTest.js
+++ b/test/server/service/RatingServiceTest.js
@@ -61,5 +61,45 @@ describe( 'RatingService', () =>
sut.request( request, response, quote, 'something', () => {} );
} );
+
+ it( "calls getLastPremiumDate during #_performRating", done =>
+ {
+ let getLastPremiumDateCallCount = 0;
+
+ const last_date = 1234;
+ const initial_date = 2345;
+
+ const {
+ logger,
+ server,
+ raters,
+ dao,
+ request,
+ response,
+ quote,
+ } = RatingServiceStub.getStubs();
+
+ quote.getLastPremiumDate = () =>
+ {
+ getLastPremiumDateCallCount++;
+ return last_date
+ };
+
+ quote.getRatedDate = () => initial_date;
+
+ const sut = Sut( logger, dao, server, raters );
+
+ server.sendResponse = ( request, quote, resp, actions ) =>
+ {
+ expect( getLastPremiumDateCallCount ).to.equal( 2 );
+ expect( resp.initialRatedDate ).to.equal( initial_date );
+ expect( resp.lastRatedDate ).to.equal( last_date );
+
+ done();
+ };
+
+ sut.request( request, response, quote, null, () => {} );
+ } );
+
} );
} );