Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorAustin Schaffer <austin.schaffer@ryansg.com>2019-11-07 14:19:35 -0500
committerSchaffer, Austin <austin.schaffer@ryansg.com>2019-11-07 16:25:33 -0500
commit26c4367ead4fc7d064bcb73c8d081f8cca407ba4 (patch)
tree217a5ea61ea14f71eaa42a684fb3ac3042b61cbd /test
parent48aa315c2ac2b096b0ad0f23b9bfee12d7aa16b1 (diff)
downloadliza-26c4367ead4fc7d064bcb73c8d081f8cca407ba4.tar.gz
liza-26c4367ead4fc7d064bcb73c8d081f8cca407ba4.tar.bz2
liza-26c4367ead4fc7d064bcb73c8d081f8cca407ba4.zip
[DEV-6353] Accept push data in MongoDao
Diffstat (limited to 'test')
-rw-r--r--test/server/db/MongoServerDaoTest.js69
-rw-r--r--test/server/service/RatingServiceTest.ts14
2 files changed, 75 insertions, 8 deletions
diff --git a/test/server/db/MongoServerDaoTest.js b/test/server/db/MongoServerDaoTest.js
index 0f42f2b..0fa5d30 100644
--- a/test/server/db/MongoServerDaoTest.js
+++ b/test/server/db/MongoServerDaoTest.js
@@ -30,7 +30,7 @@ describe( 'MongoServerDao', () =>
{
describe( '#saveQuote', () =>
{
- describe( "with no save data", () =>
+ describe( "with no save data or push data", () =>
{
it( "saves entire metabucket record individually", done =>
{
@@ -51,6 +51,9 @@ describe( 'MongoServerDao', () =>
expect( data.$set[ 'meta.bar' ] )
.to.deep.equal( metadata.bar );
+
+ expect( data.$push ).to.equal( undefined );
+
done();
}
) );
@@ -60,6 +63,70 @@ describe( 'MongoServerDao', () =>
);
} );
} );
+
+ describe( "with push data", () =>
+ {
+ it( "adds push data to the collection", done =>
+ {
+ const push_data = {
+ foo: [ 'bar', 'baz' ],
+ bar: [ { quux: 'quuux' } ],
+ };
+
+ const quote = createStubQuote( {} );
+
+ const sut = Sut( createMockDb(
+ // update
+ ( selector, data ) =>
+ {
+ expect( data.$push[ 'foo' ] )
+ .to.deep.equal( push_data.foo );
+
+ expect( data.$push[ 'bar' ] )
+ .to.deep.equal( push_data.bar );
+
+ done();
+ }
+ ) );
+
+ sut.init( () =>
+ sut.saveQuote(
+ quote,
+ () => {},
+ () => {},
+ undefined,
+ push_data
+ )
+ );
+ } );
+
+ it( "skips push data when it is an empty object", done =>
+ {
+ const push_data = {};
+
+ const quote = createStubQuote( {} );
+
+ const sut = Sut( createMockDb(
+ // update
+ ( selector, data ) =>
+ {
+ expect( data.$push ).to.equal( undefined );
+
+ done();
+ }
+ ) );
+
+ sut.init( () =>
+ sut.saveQuote(
+ quote,
+ () => {},
+ () => {},
+ undefined,
+ push_data
+ )
+ );
+ } );
+ } );
} );
} );
diff --git a/test/server/service/RatingServiceTest.ts b/test/server/service/RatingServiceTest.ts
index 3bc72c0..5dd821f 100644
--- a/test/server/service/RatingServiceTest.ts
+++ b/test/server/service/RatingServiceTest.ts
@@ -157,15 +157,14 @@ describe( 'RatingService', () =>
let saved_rates = false;
dao.saveQuote = (
- quote: ServerSideQuote,
- success: ServerDaoCallback,
- _failure: ServerDaoCallback,
- save_data: Record<string, any>,
+ quote: ServerSideQuote,
+ success: ServerDaoCallback,
+ _failure: ServerDaoCallback,
+ save_data: Record<string, any>,
+ _push_data: Record<string, any>,
) =>
{
- expect( save_data ).to.deep.equal( {
- ratedata: stub_rate_data,
- } );
+ expect( save_data.ratedata ).to.deep.equal( stub_rate_data );
saved_rates = true;
success( quote );
@@ -453,6 +452,7 @@ function getStubs()
success: ServerDaoCallback,
_failure: ServerDaoCallback,
_save_data: Record<string, any>,
+ _push_data: Record<string, any>,
): this
{
success( quote );