@@ -3,25 +3,36 @@ import { IEvent } from '../models/IEvent';
3
3
import { expect } from 'chai' ;
4
4
5
5
describe ( '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
+
6
19
function getConfiguration ( ) : Configuration {
7
- let config : Configuration = new Configuration ( {
20
+ let result : Configuration = new Configuration ( {
8
21
apiKey : 'LhhP1C9gijpSKCslHHCvwdSIz298twx271n1l6xw' ,
9
22
serverUrl : 'http://localhost:50000'
10
23
} ) ;
11
24
12
- expect ( config . storage . getList ( ) . length ) . to . equal ( 0 ) ;
13
- return config ;
25
+ expect ( result . storage . getList ( ) . length ) . to . equal ( 0 ) ;
26
+ return result ;
14
27
}
15
28
16
29
it ( 'should enqueue event' , ( ) => {
17
- let config : Configuration = getConfiguration ( ) ;
18
30
let event : IEvent = { type : 'log' , reference_id : '123454321' } ;
19
31
config . queue . enqueue ( event ) ;
20
32
expect ( config . storage . getList ( ) . length ) . to . equal ( 1 ) ;
21
33
} ) ;
22
34
23
35
it ( 'should process queue' , ( ) => {
24
- let config : Configuration = getConfiguration ( ) ;
25
36
let event : IEvent = { type : 'log' , reference_id : '123454321' } ;
26
37
config . queue . enqueue ( event ) ;
27
38
expect ( config . storage . getList ( ) . length ) . to . equal ( 1 ) ;
@@ -35,7 +46,6 @@ describe('DefaultEventQueue', () => {
35
46
} ) ;
36
47
37
48
it ( 'should discard event submission' , ( ) => {
38
- let config : Configuration = getConfiguration ( ) ;
39
49
config . queue . suspendProcessing ( 1 , true ) ;
40
50
41
51
let event : IEvent = { type : 'log' , reference_id : '123454321' } ;
@@ -44,7 +54,6 @@ describe('DefaultEventQueue', () => {
44
54
} ) ;
45
55
46
56
it ( 'should suspend processing' , ( done ) => {
47
- let config : Configuration = getConfiguration ( ) ;
48
57
config . queue . suspendProcessing ( .0001 ) ;
49
58
50
59
let event : IEvent = { type : 'log' , reference_id : '123454321' } ;
0 commit comments