@@ -2,17 +2,25 @@ import { Configuration } from '../configuration/Configuration';
22import { IEvent } from '../models/IEvent' ;
33
44describe ( 'DefaultEventQueue' , ( ) => {
5- it ( 'should enqueue event' , ( ) => {
6- var config = new Configuration ( { apiKey :'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw' , serverUrl :'http://localhost:50000' } ) ;
5+ function getConfiguration ( ) : Configuration {
6+ var config :Configuration = new Configuration ( {
7+ apiKey :'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw' ,
8+ serverUrl :'http://localhost:50000'
9+ } ) ;
10+
711 expect ( config . storage . getList ( ) . length ) . toBe ( 0 ) ;
12+ return config ;
13+ }
14+
15+ it ( 'should enqueue event' , ( ) => {
16+ var config :Configuration = getConfiguration ( ) ;
817 var event :IEvent = { type : 'log' , reference_id : '123454321' } ;
918 config . queue . enqueue ( event ) ;
1019 expect ( config . storage . getList ( ) . length ) . toBe ( 1 ) ;
1120 } ) ;
1221
1322 it ( 'should process queue' , ( ) => {
14- var config = new Configuration ( { apiKey :'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw' , serverUrl :'http://localhost:50000' } ) ;
15- expect ( config . storage . getList ( ) . length ) . toBe ( 0 ) ;
23+ var config :Configuration = getConfiguration ( ) ;
1624 var event :IEvent = { type : 'log' , reference_id : '123454321' } ;
1725 config . queue . enqueue ( event ) ;
1826 expect ( config . storage . getList ( ) . length ) . toBe ( 1 ) ;
@@ -26,8 +34,7 @@ describe('DefaultEventQueue', () => {
2634 } ) ;
2735
2836 it ( 'should discard event submission' , ( ) => {
29- var config = new Configuration ( { apiKey :'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw' , serverUrl :'http://localhost:50000' } ) ;
30- expect ( config . storage . getList ( ) . length ) . toBe ( 0 ) ;
37+ var config :Configuration = getConfiguration ( ) ;
3138 config . queue . suspendProcessing ( 1 , true ) ;
3239
3340 var event :IEvent = { type : 'log' , reference_id : '123454321' } ;
@@ -36,8 +43,7 @@ describe('DefaultEventQueue', () => {
3643 } ) ;
3744
3845 it ( 'should suspend processing' , ( done ) => {
39- var config = new Configuration ( { apiKey :'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw' , serverUrl :'http://localhost:50000' } ) ;
40- expect ( config . storage . getList ( ) . length ) . toBe ( 0 ) ;
46+ var config :Configuration = getConfiguration ( ) ;
4147 config . queue . suspendProcessing ( .0001 ) ;
4248
4349 var event :IEvent = { type : 'log' , reference_id : '123454321' } ;
0 commit comments