@@ -7,11 +7,15 @@ jest.mock('../src/osgi');
7
7
8
8
describe ( 'actions.js' , ( ) => {
9
9
describe ( 'ScriptExecution' , ( ) => {
10
+ const defaultIdentifier = 'script-1' ;
11
+
10
12
beforeAll ( ( ) => {
11
13
jest . spyOn ( JavaScriptExecution , 'callScript' ) ;
12
14
jest . spyOn ( JavaScriptExecution , 'createTimer' ) ;
13
15
16
+ console . loggerName = defaultIdentifier ;
14
17
ThreadsafeTimers = {
18
+ setIdentifier : jest . fn ( ) ,
15
19
createTimer : jest . fn ( )
16
20
} ;
17
21
} ) ;
@@ -31,16 +35,29 @@ describe('actions.js', () => {
31
35
32
36
ScriptExecution . createTimer ( identifier , zdt , functionRef , 'prop1' ) ;
33
37
38
+ expect ( ThreadsafeTimers . setIdentifier ) . toHaveBeenCalledWith ( defaultIdentifier ) ;
34
39
expect ( ThreadsafeTimers . createTimer ) . toHaveBeenCalled ( ) ;
35
40
expect ( JavaScriptExecution . callScript ) . not . toHaveBeenCalled ( ) ;
36
41
37
- jest . clearAllMocks ( ) ;
38
-
39
42
ScriptExecution . createTimer ( zdt , functionRef , 'prop1' ) ;
40
43
44
+ expect ( ThreadsafeTimers . setIdentifier ) . toHaveBeenCalledWith ( defaultIdentifier ) ;
41
45
expect ( ThreadsafeTimers . createTimer ) . toHaveBeenCalled ( ) ;
42
46
expect ( JavaScriptExecution . callScript ) . not . toHaveBeenCalled ( ) ;
43
47
} ) ;
48
+
49
+ it ( 'sets default identifier for ThreadsafeTimers.' , ( ) => {
50
+ const zdt = { } ;
51
+ const functionRef = ( foo ) => foo ;
52
+
53
+ ScriptExecution . createTimer ( zdt , functionRef , 'prop1' ) ;
54
+
55
+ expect ( ThreadsafeTimers . setIdentifier ) . toHaveBeenCalledWith ( defaultIdentifier ) ;
56
+
57
+ ScriptExecution . createTimer ( zdt , functionRef , 'prop1' ) ;
58
+
59
+ expect ( ThreadsafeTimers . setIdentifier ) . toHaveBeenCalledWith ( defaultIdentifier ) ;
60
+ } ) ;
44
61
} ) ;
45
62
46
63
describe ( 'Transformation' , ( ) => {
0 commit comments