@@ -3,25 +3,36 @@ import { IEvent } from '../models/IEvent';
33import { expect } from 'chai' ;
44
55describe ( 'DefaultEventQueue' , ( ) => {
6+
7+ let config : Configuration ;
8+
9+ beforeEach ( ( ) => {
10+ config = getConfiguration ( ) ;
11+ } ) ;
12+
13+ afterEach ( ( ) => {
14+ let queue = < any > config . queue ;
15+ clearInterval ( queue . _queueTimer ) ;
16+ config = null ;
17+ } ) ;
18+
619 function getConfiguration ( ) : Configuration {
7- let config : Configuration = new Configuration ( {
20+ let result : Configuration = new Configuration ( {
821 apiKey : 'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw' ,
922 serverUrl : 'http://localhost:50000'
1023 } ) ;
1124
12- expect ( config . storage . getList ( ) . length ) . to . equal ( 0 ) ;
13- return config ;
25+ expect ( result . storage . getList ( ) . length ) . to . equal ( 0 ) ;
26+ return result ;
1427 }
1528
1629 it ( 'should enqueue event' , ( ) => {
17- let config : Configuration = getConfiguration ( ) ;
1830 let event : IEvent = { type : 'log' , reference_id : '123454321' } ;
1931 config . queue . enqueue ( event ) ;
2032 expect ( config . storage . getList ( ) . length ) . to . equal ( 1 ) ;
2133 } ) ;
2234
2335 it ( 'should process queue' , ( ) => {
24- let config : Configuration = getConfiguration ( ) ;
2536 let event : IEvent = { type : 'log' , reference_id : '123454321' } ;
2637 config . queue . enqueue ( event ) ;
2738 expect ( config . storage . getList ( ) . length ) . to . equal ( 1 ) ;
@@ -35,7 +46,6 @@ describe('DefaultEventQueue', () => {
3546 } ) ;
3647
3748 it ( 'should discard event submission' , ( ) => {
38- let config : Configuration = getConfiguration ( ) ;
3949 config . queue . suspendProcessing ( 1 , true ) ;
4050
4151 let event : IEvent = { type : 'log' , reference_id : '123454321' } ;
@@ -44,7 +54,6 @@ describe('DefaultEventQueue', () => {
4454 } ) ;
4555
4656 it ( 'should suspend processing' , ( done ) => {
47- let config : Configuration = getConfiguration ( ) ;
4857 config . queue . suspendProcessing ( .0001 ) ;
4958
5059 let event : IEvent = { type : 'log' , reference_id : '123454321' } ;
0 commit comments