diff options
author | Mike Gerwitz <mike.gerwitz@ryansg.com> | 2019-12-09 15:45:01 -0500 |
---|---|---|
committer | Austin Schaffer <austin.schaffer@ryansg.com> | 2019-12-12 10:27:09 -0500 |
commit | 819701eca3c290e4847ffe87eaff7a09b8d653f6 (patch) | |
tree | 81acf3148decc2f2434481d48a28a8d3a84b7489 /test | |
parent | d0a3ba573f32760e72f356e468f2a2c32eb1306c (diff) | |
download | liza-819701eca3c290e4847ffe87eaff7a09b8d653f6.tar.gz liza-819701eca3c290e4847ffe87eaff7a09b8d653f6.tar.bz2 liza-819701eca3c290e4847ffe87eaff7a09b8d653f6.zip |
DeltaProcessor: Encapsulate getDeltas and remove redundant tests
getDeltas should be encapsulated. It looks like it was public for the sake
of the tests, and its behavior can be inferred by looking at the result of
processing.
Diffstat (limited to 'test')
-rw-r--r-- | test/system/DeltaProcessorTest.ts | 158 |
1 files changed, 35 insertions, 123 deletions
diff --git a/test/system/DeltaProcessorTest.ts b/test/system/DeltaProcessorTest.ts index 07e288c..0b7c35d 100644 --- a/test/system/DeltaProcessorTest.ts +++ b/test/system/DeltaProcessorTest.ts @@ -22,7 +22,7 @@ import { DeltaProcessor as Sut } from '../../src/system/DeltaProcessor'; import { AmqpPublisher } from '../../src/system/AmqpPublisher'; import { DeltaDao } from '../../src/system/db/DeltaDao'; -import { DeltaType, DeltaDocument } from "../../src/bucket/delta"; +import { DeltaDocument } from "../../src/bucket/delta"; import { DocumentId } from '../../src/document/Document'; import { EventEmitter } from 'events'; @@ -32,128 +32,6 @@ chai_use( require( 'chai-as-promised' ) ); describe( 'system.DeltaProcessor', () => { - describe( '#getDeltas', () => - { - ( <{ - label: string, - type: DeltaType, - given: any, - expected: any - }[]>[ - { - label: 'return empty array if no deltas are present', - type: 'data', - given: { - rdelta: {}, - }, - expected: [], - }, - { - label: 'return full list if no lastPublished index is found', - type: 'data', - given: { - rdelta: { - data: [ - { - data: { foo: [ 'first_bar' ] }, - timestamp: 123, - }, - { - data: { foo: [ 'second_bar' ] }, - timestamp: 234, - }, - ], - }, - }, - expected: [ - { - data: { foo: [ 'first_bar' ] }, - timestamp: 123, - type: 'data', - }, - { - data: { foo: [ 'second_bar' ] }, - timestamp: 234, - type: 'data', - }, - ], - }, - { - label: 'marks deltas with their type', - type: 'data', - given: { - rdelta: { - data: [ - { - data: { foo: [ 'first_bar' ] }, - timestamp: 123, - }, - { - data: { foo: [ 'second_bar' ] }, - timestamp: 234, - }, - ], - }, - totalPublishDelta: { - data: 0, - }, - }, - expected: [ - { - data: { foo: [ 'first_bar' ] }, - timestamp: 123, - type: 'data', - }, - { - data: { foo: [ 'second_bar' ] }, - timestamp: 234, - type: 'data', - }, - ], - }, - { - label: 'trims delta array based on index', - type: 'data', - given: { - rdelta: { - data: [ - { - data: { foo: [ 'first_bar' ] }, - timestamp: 123, - }, - { - data: { foo: [ 'second_bar' ] }, - timestamp: 234, - }, - ], - }, - totalPublishDelta: { - data: 1, - }, - }, - expected: [ - { - data: { foo: [ 'second_bar' ] }, - timestamp: 234, - type: 'data', - }, - ], - }, - ] ).forEach( ( { type, given, expected, label } ) => it( label, () => - { - const sut = new Sut( - createMockDeltaDao(), - createMockDeltaPublisher(), - new EventEmitter(), - ); - - const actual = sut.getDeltas( given, type ); - - expect( actual ).to.deep.equal( expected ); - } ) ); - } ); - - describe( '#process', () => { ( <{ @@ -320,6 +198,40 @@ describe( 'system.DeltaProcessor', () => }, ], }, + { + label: 'trims delta array based on index', + given: [ + { + id: 111, + lastUpdate: 123123123, + data: { foo: [ 'bar' ] }, + ratedata: {}, + rdelta: { + data: [ + { + data: { foo: [ 'first_bar' ] }, + timestamp: 123, + }, + { + data: { foo: [ 'second_bar' ] }, + timestamp: 234, + }, + ], + }, + totalPublishDelta: { + data: 1, + }, + }, + ], + expected: [ + { + doc_id: 111, + delta: { foo: [ 'second_bar' ] }, + bucket: { foo: [ 'second_bar' ] }, + ratedata: {} + }, + ], + }, ] ).forEach( ( { label, given, expected } ) => it( label, () => { let published: any = []; |