@@ -32,7 +32,7 @@ describe('setTopLevelCallers', () => {
32
32
expect ( typeof nreum . wrapLogger ) . toEqual ( 'function' )
33
33
} )
34
34
35
- test ( 'should forward calls to initialized and exposed agents ' , ( ) => {
35
+ test ( 'should forward calls to the first initialized and exposed agent that is not a micro-agent ' , ( ) => {
36
36
setTopLevelCallers ( )
37
37
38
38
const nreum = gosCDN ( )
@@ -41,18 +41,27 @@ describe('setTopLevelCallers', () => {
41
41
exposed : true ,
42
42
api : {
43
43
setErrorHandler : jest . fn ( )
44
+ } ,
45
+ runtime : {
46
+ loaderType : 'micro-agent'
44
47
}
45
48
} ,
46
49
[ faker . string . uuid ( ) ] : {
47
50
exposed : true ,
48
51
api : {
49
52
setErrorHandler : jest . fn ( )
53
+ } ,
54
+ runtime : {
55
+ loaderType : 'browser-agent'
50
56
}
51
57
} ,
52
58
[ faker . string . uuid ( ) ] : {
53
59
exposed : false ,
54
60
api : {
55
61
setErrorHandler : jest . fn ( )
62
+ } ,
63
+ runtime : {
64
+ loaderType : 'browser-agent'
56
65
}
57
66
}
58
67
}
@@ -61,7 +70,7 @@ describe('setTopLevelCallers', () => {
61
70
nreum . setErrorHandler ( errorHandler )
62
71
63
72
Object . values ( nreum . initializedAgents ) . forEach ( agent => {
64
- if ( agent . exposed ) {
73
+ if ( agent . exposed && agent . runtime . loaderType === 'browser-agent' ) {
65
74
expect ( agent . api . setErrorHandler ) . toHaveBeenCalledTimes ( 1 )
66
75
expect ( agent . api . setErrorHandler ) . toHaveBeenCalledWith ( errorHandler )
67
76
} else {
@@ -70,31 +79,7 @@ describe('setTopLevelCallers', () => {
70
79
} )
71
80
} )
72
81
73
- test ( 'should return a single value when only one exposed agent returns a value' , ( ) => {
74
- setTopLevelCallers ( )
75
-
76
- const nreum = gosCDN ( )
77
- const expected = faker . string . uuid ( )
78
- nreum . initializedAgents = {
79
- [ faker . string . uuid ( ) ] : {
80
- exposed : true ,
81
- api : {
82
- interaction : jest . fn ( ) . mockReturnValue ( expected )
83
- }
84
- } ,
85
- [ faker . string . uuid ( ) ] : {
86
- exposed : false ,
87
- api : {
88
- interaction : jest . fn ( ) . mockReturnValue ( expected )
89
- }
90
- }
91
- }
92
-
93
- const result = nreum . interaction ( )
94
- expect ( result ) . toEqual ( expected )
95
- } )
96
-
97
- test ( 'should return an array of values for each exposed agent that returns a value' , ( ) => {
82
+ test ( 'should return a single value for the first exposed browser-agent in the nreum initialized agents array' , ( ) => {
98
83
setTopLevelCallers ( )
99
84
100
85
const nreum = gosCDN ( )
@@ -104,23 +89,32 @@ describe('setTopLevelCallers', () => {
104
89
exposed : true ,
105
90
api : {
106
91
interaction : jest . fn ( ) . mockReturnValue ( expected )
92
+ } ,
93
+ runtime : {
94
+ loaderType : 'browser-agent'
107
95
}
108
96
} ,
109
97
[ faker . string . uuid ( ) ] : {
110
98
exposed : true ,
111
99
api : {
112
100
interaction : jest . fn ( ) . mockReturnValue ( expected )
101
+ } ,
102
+ runtime : {
103
+ loaderType : 'browser-agent'
113
104
}
114
105
} ,
115
106
[ faker . string . uuid ( ) ] : {
116
107
exposed : false ,
117
108
api : {
118
109
interaction : jest . fn ( ) . mockReturnValue ( expected )
110
+ } ,
111
+ runtime : {
112
+ loaderType : 'browser-agent'
119
113
}
120
114
}
121
115
}
122
116
123
117
const result = nreum . interaction ( )
124
- expect ( result ) . toEqual ( [ expected , expected ] )
118
+ expect ( result ) . toEqual ( expected )
125
119
} )
126
120
} )
0 commit comments