Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAustin Schaffer <austin.schaffer@ryansg.com>2019-11-07 13:33:14 -0500
committerSchaffer, Austin <austin.schaffer@ryansg.com>2019-11-07 16:25:33 -0500
commit4f39c754a2d9b2fc2e2caa611c6c38d80f4e509a (patch)
treeb59d981e6fb0e387770f8cc70fafa9ed9b400944 /test
parent6fcf72f1b6923bbd3ce374e5db967e37ec3805b9 (diff)
downloadliza-4f39c754a2d9b2fc2e2caa611c6c38d80f4e509a.tar.gz
liza-4f39c754a2d9b2fc2e2caa611c6c38d80f4e509a.tar.bz2
liza-4f39c754a2d9b2fc2e2caa611c6c38d80f4e509a.zip
[DEV-6353] Add bucket definitions
Diffstat (limited to 'test')
-rw-r--r--test/server/quote/ServerSideQuoteTest.js117
-rw-r--r--test/server/request/DataProcessorTest.ts3
-rw-r--r--test/server/service/RatingServiceTest.ts7
3 files changed, 92 insertions, 35 deletions
diff --git a/test/server/quote/ServerSideQuoteTest.js b/test/server/quote/ServerSideQuoteTest.js
index aea8cc8..8e92a67 100644
--- a/test/server/quote/ServerSideQuoteTest.js
+++ b/test/server/quote/ServerSideQuoteTest.js
@@ -21,8 +21,14 @@
'use strict';
-const { expect } = require( 'chai' );
-const Sut = require( '../../..' ).server.quote.ServerSideQuote;
+const root = require( '../../..' );
+const Sut = require( '../../..' ).server.quote.ServerSideQuote;
+const expect = require( 'chai' ).expect;
+const sinon = require( 'sinon' );
+
+const {
+ QuoteDataBucket,
+} = root.bucket;
describe( 'ServerSideQuote', () =>
{
@@ -31,80 +37,85 @@ describe( 'ServerSideQuote', () =>
[
{
property: 'startDate',
- default: 0,
- value: 946684800
+ default: 0,
+ value: 946684800
},
{
property: 'initialRatedDate',
- default: 0,
- value: 946684800
+ default: 0,
+ value: 946684800
},
{
property: 'agentId',
- default: 0,
- value: 12345678
+ default: 0,
+ value: 12345678
},
{
property: 'agentEntityId',
- default: 0,
- value: 12345678
+ default: 0,
+ value: 12345678
},
{
property: 'agentName',
- default: '',
- value: 'name'
+ default: '',
+ value: 'name'
},
{
property: 'imported',
- default: false,
- value: true,
+ default: false,
+ value: true,
accessor: 'is'
},
{
property: 'bound',
- default: false,
- value: true,
+ default: false,
+ value: true,
accessor: 'is'
},
{
property: 'currentStepId',
- default: 1,
- value: 2
+ default: 1,
+ value: 2
},
{
property: 'topVisitedStepId',
- default: 1,
- value: 2
+ default: 1,
+ value: 2
},
{
property: 'topSavedStepId',
- value: 1
+ value: 1
},
{
property: 'error',
- default: '',
- value: 'ERROR'
+ default: '',
+ value: 'ERROR'
},
{
property: 'programVersion',
- default: '',
- value: '1.0.0'
+ default: '',
+ value: '1.0.0'
},
{
property: 'creditScoreRef',
- default: 0,
- value: 800
+ default: 0,
+ value: 800
},
{
property: 'lastPremiumDate',
- default: 0,
- value: 946684800
+ default: 0,
+ value: 946684800
},
{
property: 'ratedDate',
- default: 0,
- value: 946684800
- }
+ default: 0,
+ value: 946684800
+ },
+ {
+ property: 'rateBucket',
+ default: null,
+ value: QuoteDataBucket()
+ },
].forEach( testCase =>
{
@@ -122,4 +133,44 @@ describe( 'ServerSideQuote', () =>
} );
} );
} );
-} ); \ No newline at end of file
+
+ 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 );
+ } );
+ } );
+} );
diff --git a/test/server/request/DataProcessorTest.ts b/test/server/request/DataProcessorTest.ts
index faf69bf..361d99a 100644
--- a/test/server/request/DataProcessorTest.ts
+++ b/test/server/request/DataProcessorTest.ts
@@ -25,6 +25,7 @@ import { DocumentId } from "../../../src/document/Document";
import { PositiveInteger } from "../../../src/numeric";
import { UserRequest } from "../../../src/server/request/UserRequest";
import { ServerSideQuote } from "../../../src/server/quote/ServerSideQuote";
+import { QuoteDataBucket } from "../../../src/bucket/QuoteDataBucket";
chai_use( require( 'chai-as-promised' ) );
@@ -711,7 +712,7 @@ function createStubQuote()
getBucket()
{
- return;
+ return new QuoteDataBucket();
}
};
}
diff --git a/test/server/service/RatingServiceTest.ts b/test/server/service/RatingServiceTest.ts
index 1b7f7d7..3bc72c0 100644
--- a/test/server/service/RatingServiceTest.ts
+++ b/test/server/service/RatingServiceTest.ts
@@ -35,6 +35,7 @@ import { ServerSideQuote } from "../../../src/server/quote/ServerSideQuote";
import { UserRequest } from "../../../src/server/request/UserRequest";
import { UserResponse } from "../../../src/server/request/UserResponse";
import { UserSession } from "../../../src/server/request/UserSession";
+import { QuoteDataBucket } from "../../../src/bucket/QuoteDataBucket";
import {
ServerDao,
@@ -140,7 +141,7 @@ describe( 'RatingService', () =>
.then( () => expect( sent ).to.be.true );
} );
- it( "saves rate data to own field", () =>
+ it( "saves rate data to it's own field", () =>
{
const {
logger,
@@ -510,6 +511,10 @@ function getStubs()
getLastPremiumDate: () => <UnixTimestamp>0,
getCurrentStepId: () => 0,
setExplicitLock: () => quote,
+ setRateBucket: () => quote,
+ setRatingData: () => quote,
+ getRatingData: () => stub_rate_data,
+ getBucket: () => new QuoteDataBucket(),
};
return {