@newrelic/browser-agent 1.235.0 → 1.236.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (332) hide show
  1. package/README.md +41 -1
  2. package/dist/cjs/common/config/state/init.js +3 -0
  3. package/dist/cjs/common/config/state/runtime.js +4 -4
  4. package/dist/cjs/common/constants/env.cdn.js +2 -2
  5. package/dist/cjs/common/constants/env.npm.js +1 -1
  6. package/dist/cjs/common/constants/runtime.js +52 -0
  7. package/dist/cjs/common/event-listener/event-listener-opts.js +3 -3
  8. package/dist/cjs/common/harvest/harvest-scheduler.js +22 -19
  9. package/dist/cjs/common/harvest/harvest.js +163 -144
  10. package/dist/cjs/common/harvest/types.js +54 -0
  11. package/dist/cjs/common/ids/id.js +2 -2
  12. package/dist/cjs/common/ids/unique-id.js +3 -3
  13. package/dist/cjs/common/session/session-entity.js +2 -2
  14. package/dist/cjs/common/timer/interaction-timer.js +2 -2
  15. package/dist/cjs/common/unload/eol.js +10 -11
  16. package/dist/cjs/common/url/canonicalize-url.js +2 -2
  17. package/dist/cjs/common/url/parse-url.js +3 -3
  18. package/dist/cjs/common/url/protocol.js +2 -2
  19. package/dist/cjs/common/util/submit-data.js +58 -76
  20. package/dist/cjs/common/window/nreum.js +14 -14
  21. package/dist/cjs/common/wrap/wrap-events.js +3 -3
  22. package/dist/cjs/common/wrap/wrap-fetch.js +5 -5
  23. package/dist/cjs/common/wrap/wrap-history.js +2 -2
  24. package/dist/cjs/common/wrap/wrap-jsonp.js +2 -2
  25. package/dist/cjs/common/wrap/wrap-mutation.js +2 -2
  26. package/dist/cjs/common/wrap/wrap-promise.js +2 -2
  27. package/dist/cjs/common/wrap/wrap-raf.js +2 -2
  28. package/dist/cjs/common/wrap/wrap-timer.js +4 -4
  29. package/dist/cjs/common/wrap/wrap-xhr.js +3 -3
  30. package/dist/cjs/features/ajax/aggregate/index.js +1 -1
  31. package/dist/cjs/features/ajax/instrument/distributed-tracing.js +2 -2
  32. package/dist/cjs/features/ajax/instrument/index.js +6 -7
  33. package/dist/cjs/features/jserrors/aggregate/index.js +7 -4
  34. package/dist/cjs/features/jserrors/instrument/index.js +4 -4
  35. package/dist/cjs/features/metrics/aggregate/framework-detection.js +2 -2
  36. package/dist/cjs/features/metrics/aggregate/index.js +3 -3
  37. package/dist/cjs/features/page_action/aggregate/index.js +3 -3
  38. package/dist/cjs/features/page_view_event/aggregate/index.js +10 -11
  39. package/dist/cjs/features/page_view_event/instrument/index.js +2 -2
  40. package/dist/cjs/features/page_view_timing/aggregate/index.js +3 -5
  41. package/dist/cjs/features/page_view_timing/instrument/index.js +2 -2
  42. package/dist/cjs/features/session_replay/replay-mode.js +2 -2
  43. package/dist/cjs/features/session_trace/instrument/index.js +2 -2
  44. package/dist/cjs/features/spa/aggregate/index.js +1 -1
  45. package/dist/cjs/features/spa/instrument/index.js +2 -2
  46. package/dist/cjs/features/utils/instrument-base.js +6 -7
  47. package/dist/cjs/index.js +7 -0
  48. package/dist/cjs/loaders/agent.js +7 -0
  49. package/dist/cjs/loaders/api/api.js +2 -2
  50. package/dist/cjs/loaders/api/apiAsync.js +6 -4
  51. package/dist/cjs/loaders/configure/configure.js +2 -2
  52. package/dist/cjs/loaders/micro-agent.js +29 -38
  53. package/dist/esm/common/config/state/init.js +3 -0
  54. package/dist/esm/common/config/state/runtime.js +1 -1
  55. package/dist/esm/common/constants/env.cdn.js +2 -2
  56. package/dist/esm/common/constants/env.npm.js +1 -1
  57. package/dist/esm/common/constants/runtime.js +38 -0
  58. package/dist/esm/common/event-listener/event-listener-opts.js +1 -1
  59. package/dist/esm/common/harvest/harvest-scheduler.js +21 -20
  60. package/dist/esm/common/harvest/harvest.js +160 -142
  61. package/dist/esm/common/harvest/types.js +47 -0
  62. package/dist/esm/common/ids/id.js +1 -1
  63. package/dist/esm/common/ids/unique-id.js +1 -1
  64. package/dist/esm/common/session/session-entity.js +1 -1
  65. package/dist/esm/common/timer/interaction-timer.js +1 -1
  66. package/dist/esm/common/unload/eol.js +1 -2
  67. package/dist/esm/common/url/canonicalize-url.js +1 -1
  68. package/dist/esm/common/url/parse-url.js +1 -1
  69. package/dist/esm/common/url/protocol.js +1 -1
  70. package/dist/esm/common/util/submit-data.js +55 -73
  71. package/dist/esm/common/window/nreum.js +1 -1
  72. package/dist/esm/common/wrap/wrap-events.js +1 -1
  73. package/dist/esm/common/wrap/wrap-fetch.js +1 -1
  74. package/dist/esm/common/wrap/wrap-history.js +1 -1
  75. package/dist/esm/common/wrap/wrap-jsonp.js +1 -1
  76. package/dist/esm/common/wrap/wrap-mutation.js +1 -1
  77. package/dist/esm/common/wrap/wrap-promise.js +1 -1
  78. package/dist/esm/common/wrap/wrap-raf.js +1 -1
  79. package/dist/esm/common/wrap/wrap-timer.js +1 -1
  80. package/dist/esm/common/wrap/wrap-xhr.js +1 -1
  81. package/dist/esm/features/ajax/aggregate/index.js +1 -1
  82. package/dist/esm/features/ajax/instrument/distributed-tracing.js +1 -1
  83. package/dist/esm/features/ajax/instrument/index.js +1 -2
  84. package/dist/esm/features/jserrors/aggregate/index.js +6 -3
  85. package/dist/esm/features/jserrors/instrument/index.js +1 -1
  86. package/dist/esm/features/metrics/aggregate/framework-detection.js +1 -1
  87. package/dist/esm/features/metrics/aggregate/index.js +1 -1
  88. package/dist/esm/features/page_action/aggregate/index.js +1 -1
  89. package/dist/esm/features/page_view_event/aggregate/index.js +1 -2
  90. package/dist/esm/features/page_view_event/instrument/index.js +1 -1
  91. package/dist/esm/features/page_view_timing/aggregate/index.js +2 -4
  92. package/dist/esm/features/page_view_timing/instrument/index.js +1 -1
  93. package/dist/esm/features/session_replay/replay-mode.js +2 -2
  94. package/dist/esm/features/session_trace/instrument/index.js +1 -1
  95. package/dist/esm/features/spa/aggregate/index.js +1 -1
  96. package/dist/esm/features/spa/instrument/index.js +1 -1
  97. package/dist/esm/features/utils/instrument-base.js +4 -5
  98. package/dist/esm/index.js +1 -4
  99. package/dist/esm/loaders/agent.js +7 -0
  100. package/dist/esm/loaders/api/api.js +1 -1
  101. package/dist/esm/loaders/api/apiAsync.js +3 -3
  102. package/dist/esm/loaders/configure/configure.js +1 -1
  103. package/dist/esm/loaders/micro-agent.js +29 -38
  104. package/dist/types/common/config/state/init.d.ts.map +1 -1
  105. package/dist/types/common/constants/runtime.d.ts +29 -0
  106. package/dist/types/common/constants/runtime.d.ts.map +1 -0
  107. package/dist/types/common/harvest/harvest-scheduler.d.ts +1 -1
  108. package/dist/types/common/harvest/harvest-scheduler.d.ts.map +1 -1
  109. package/dist/types/common/harvest/harvest.d.ts +49 -38
  110. package/dist/types/common/harvest/harvest.d.ts.map +1 -1
  111. package/dist/types/common/harvest/types.d.ts +100 -0
  112. package/dist/types/common/harvest/types.d.ts.map +1 -0
  113. package/dist/types/common/unload/eol.d.ts.map +1 -1
  114. package/dist/types/common/util/submit-data.d.ts +62 -64
  115. package/dist/types/common/util/submit-data.d.ts.map +1 -1
  116. package/dist/types/features/ajax/instrument/index.d.ts.map +1 -1
  117. package/dist/types/features/jserrors/aggregate/index.d.ts +1 -1
  118. package/dist/types/features/jserrors/aggregate/index.d.ts.map +1 -1
  119. package/dist/types/features/jserrors/instrument/index.d.ts +1 -1
  120. package/dist/types/features/jserrors/instrument/index.d.ts.map +1 -1
  121. package/dist/types/features/page_view_event/aggregate/index.d.ts.map +1 -1
  122. package/dist/types/features/page_view_timing/aggregate/index.d.ts.map +1 -1
  123. package/dist/types/index.d.ts +1 -0
  124. package/dist/types/loaders/agent.d.ts +4 -4
  125. package/dist/types/loaders/agent.d.ts.map +1 -1
  126. package/dist/types/loaders/micro-agent.d.ts +3 -4
  127. package/dist/types/loaders/micro-agent.d.ts.map +1 -1
  128. package/package.json +6 -1
  129. package/src/common/config/__mocks__/config.js +11 -0
  130. package/src/common/config/state/init.js +1 -0
  131. package/src/common/config/state/runtime.js +1 -1
  132. package/src/common/constants/__mocks__/env.js +3 -0
  133. package/src/common/constants/__mocks__/runtime.js +8 -0
  134. package/src/common/constants/env.cdn.test.js +7 -0
  135. package/src/common/constants/env.npm.test.js +7 -0
  136. package/src/common/constants/env.test.js +7 -0
  137. package/src/common/constants/runtime.js +71 -0
  138. package/src/common/constants/runtime.test.js +168 -0
  139. package/src/common/context/__mocks__/shared-context.js +8 -0
  140. package/src/common/event-listener/__mocks__/event-listener-opts.js +7 -0
  141. package/src/common/event-listener/event-listener-opts.js +1 -1
  142. package/src/common/harvest/__mocks__/harvest.js +13 -0
  143. package/src/common/harvest/harvest-scheduler.js +21 -20
  144. package/src/common/harvest/harvest-scheduler.test.js +496 -0
  145. package/src/common/harvest/harvest.js +147 -130
  146. package/src/common/harvest/harvest.test.js +818 -0
  147. package/src/common/harvest/types.js +47 -0
  148. package/src/common/ids/id.js +1 -1
  149. package/src/common/ids/unique-id.js +1 -1
  150. package/src/common/session/__mocks__/session-entity.js +25 -0
  151. package/src/common/session/session-entity.component-test.js +1 -1
  152. package/src/common/session/session-entity.js +1 -1
  153. package/src/common/timer/interaction-timer.js +1 -1
  154. package/src/common/timing/__mocks__/now.js +1 -0
  155. package/src/common/unload/__mocks__/eol.js +1 -0
  156. package/src/common/unload/eol.js +1 -2
  157. package/src/common/url/__mocks__/clean-url.js +1 -0
  158. package/src/common/url/__mocks__/encode.js +7 -0
  159. package/src/common/url/__mocks__/location.js +1 -0
  160. package/src/common/url/canonicalize-url.js +1 -1
  161. package/src/common/url/canonicalize-url.test.js +2 -2
  162. package/src/common/url/parse-url.js +1 -1
  163. package/src/common/url/parse-url.test.js +3 -3
  164. package/src/common/url/protocol.js +1 -1
  165. package/src/common/util/__mocks__/obfuscate.js +10 -0
  166. package/src/common/util/__mocks__/stringify.js +1 -0
  167. package/src/common/util/__mocks__/submit-data.js +6 -0
  168. package/src/common/util/__mocks__/traverse.js +1 -0
  169. package/src/common/util/submit-data.js +39 -53
  170. package/src/common/util/submit-data.test.js +81 -68
  171. package/src/common/window/nreum.js +1 -1
  172. package/src/common/wrap/wrap-events.js +1 -1
  173. package/src/common/wrap/wrap-fetch.js +1 -1
  174. package/src/common/wrap/wrap-history.js +1 -1
  175. package/src/common/wrap/wrap-jsonp.js +1 -1
  176. package/src/common/wrap/wrap-mutation.js +1 -1
  177. package/src/common/wrap/wrap-promise.js +1 -1
  178. package/src/common/wrap/wrap-promise.test.js +2 -2
  179. package/src/common/wrap/wrap-raf.js +1 -1
  180. package/src/common/wrap/wrap-timer.js +1 -1
  181. package/src/common/wrap/wrap-xhr.js +1 -1
  182. package/src/features/ajax/aggregate/index.js +1 -1
  183. package/src/features/ajax/instrument/distributed-tracing.js +1 -1
  184. package/src/features/ajax/instrument/index.js +1 -2
  185. package/src/features/jserrors/aggregate/compute-stack-trace.test.js +1 -1
  186. package/src/features/jserrors/aggregate/index.js +7 -3
  187. package/src/features/jserrors/instrument/index.js +1 -1
  188. package/src/features/metrics/aggregate/framework-detection.js +1 -1
  189. package/src/features/metrics/aggregate/framework-detection.test.js +2 -2
  190. package/src/features/metrics/aggregate/index.js +1 -1
  191. package/src/features/page_action/aggregate/index.js +1 -1
  192. package/src/features/page_view_event/aggregate/index.js +1 -2
  193. package/src/features/page_view_event/instrument/index.js +1 -1
  194. package/src/features/page_view_timing/aggregate/index.js +2 -4
  195. package/src/features/page_view_timing/instrument/index.js +1 -1
  196. package/src/features/session_replay/replay-mode.js +2 -2
  197. package/src/features/session_trace/instrument/index.js +1 -1
  198. package/src/features/spa/aggregate/index.js +1 -1
  199. package/src/features/spa/instrument/index.js +1 -1
  200. package/src/features/utils/agent-session.test.js +2 -2
  201. package/src/features/utils/instrument-base.js +5 -5
  202. package/src/features/utils/instrument-base.test.js +22 -3
  203. package/src/index.js +1 -3
  204. package/src/loaders/agent.js +8 -0
  205. package/src/loaders/api/api.js +1 -1
  206. package/src/loaders/api/apiAsync.js +3 -3
  207. package/src/loaders/configure/configure.js +1 -1
  208. package/src/loaders/micro-agent.js +26 -30
  209. package/dist/cjs/common/browser-version/firefox-version.js +0 -17
  210. package/dist/cjs/common/browser-version/ios-version.js +0 -19
  211. package/dist/cjs/common/event-emitter/contextual-ee.test.js +0 -282
  212. package/dist/cjs/common/event-emitter/handle.test.js +0 -58
  213. package/dist/cjs/common/event-emitter/register-handler.test.js +0 -55
  214. package/dist/cjs/common/harvest/harvest-scheduler.component-test.js +0 -39
  215. package/dist/cjs/common/harvest/harvest.component-test.js +0 -224
  216. package/dist/cjs/common/ids/id.test.js +0 -85
  217. package/dist/cjs/common/ids/unique-id.test.js +0 -49
  218. package/dist/cjs/common/session/session-entity.component-test.js +0 -497
  219. package/dist/cjs/common/storage/local-storage.test.js +0 -14
  220. package/dist/cjs/common/timer/interaction-timer.component-test.js +0 -216
  221. package/dist/cjs/common/timer/timer.test.js +0 -105
  222. package/dist/cjs/common/timing/nav-timing.test.js +0 -192
  223. package/dist/cjs/common/url/canonicalize-url.test.js +0 -38
  224. package/dist/cjs/common/url/clean-url.test.js +0 -9
  225. package/dist/cjs/common/url/encode.component-test.js +0 -74
  226. package/dist/cjs/common/url/location.test.js +0 -13
  227. package/dist/cjs/common/url/parse-url.test.js +0 -111
  228. package/dist/cjs/common/url/protocol.component-test.js +0 -15
  229. package/dist/cjs/common/util/console.test.js +0 -30
  230. package/dist/cjs/common/util/data-size.test.js +0 -64
  231. package/dist/cjs/common/util/feature-flags.test.js +0 -84
  232. package/dist/cjs/common/util/get-or-set.test.js +0 -47
  233. package/dist/cjs/common/util/global-scope.js +0 -27
  234. package/dist/cjs/common/util/global-scope.test.js +0 -72
  235. package/dist/cjs/common/util/invoke.test.js +0 -49
  236. package/dist/cjs/common/util/map-own.test.js +0 -49
  237. package/dist/cjs/common/util/obfuscate.component-test.js +0 -129
  238. package/dist/cjs/common/util/stringify.test.js +0 -48
  239. package/dist/cjs/common/util/submit-data.test.js +0 -245
  240. package/dist/cjs/common/util/traverse.test.js +0 -44
  241. package/dist/cjs/common/wrap/wrap-promise.test.js +0 -119
  242. package/dist/cjs/features/jserrors/aggregate/canonical-function-name.test.js +0 -31
  243. package/dist/cjs/features/jserrors/aggregate/compute-stack-trace.test.js +0 -383
  244. package/dist/cjs/features/jserrors/aggregate/format-stack-trace.test.js +0 -40
  245. package/dist/cjs/features/jserrors/aggregate/string-hash-code.test.js +0 -27
  246. package/dist/cjs/features/metrics/aggregate/framework-detection.test.js +0 -137
  247. package/dist/cjs/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -17
  248. package/dist/cjs/features/metrics/aggregate/polyfill-detection.test.js +0 -165
  249. package/dist/cjs/features/session_replay/aggregate/index.component-test.js +0 -457
  250. package/dist/cjs/features/spa/aggregate/interaction-node.test.js +0 -16
  251. package/dist/cjs/features/utils/agent-session.test.js +0 -211
  252. package/dist/cjs/features/utils/aggregate-base.test.js +0 -110
  253. package/dist/cjs/features/utils/feature-base.test.js +0 -42
  254. package/dist/cjs/features/utils/handler-cache.test.js +0 -53
  255. package/dist/cjs/features/utils/instrument-base.test.js +0 -179
  256. package/dist/cjs/features/utils/lazy-feature-loader.test.js +0 -30
  257. package/dist/esm/common/browser-version/firefox-version.js +0 -10
  258. package/dist/esm/common/browser-version/ios-version.js +0 -11
  259. package/dist/esm/common/event-emitter/contextual-ee.test.js +0 -278
  260. package/dist/esm/common/event-emitter/handle.test.js +0 -54
  261. package/dist/esm/common/event-emitter/register-handler.test.js +0 -51
  262. package/dist/esm/common/harvest/harvest-scheduler.component-test.js +0 -37
  263. package/dist/esm/common/harvest/harvest.component-test.js +0 -222
  264. package/dist/esm/common/ids/id.test.js +0 -81
  265. package/dist/esm/common/ids/unique-id.test.js +0 -44
  266. package/dist/esm/common/session/session-entity.component-test.js +0 -495
  267. package/dist/esm/common/storage/local-storage.test.js +0 -12
  268. package/dist/esm/common/timer/interaction-timer.component-test.js +0 -214
  269. package/dist/esm/common/timer/timer.test.js +0 -103
  270. package/dist/esm/common/timing/nav-timing.test.js +0 -190
  271. package/dist/esm/common/url/canonicalize-url.test.js +0 -34
  272. package/dist/esm/common/url/clean-url.test.js +0 -7
  273. package/dist/esm/common/url/encode.component-test.js +0 -70
  274. package/dist/esm/common/url/location.test.js +0 -11
  275. package/dist/esm/common/url/parse-url.test.js +0 -107
  276. package/dist/esm/common/url/protocol.component-test.js +0 -13
  277. package/dist/esm/common/util/console.test.js +0 -28
  278. package/dist/esm/common/util/data-size.test.js +0 -60
  279. package/dist/esm/common/util/feature-flags.test.js +0 -80
  280. package/dist/esm/common/util/get-or-set.test.js +0 -45
  281. package/dist/esm/common/util/global-scope.js +0 -17
  282. package/dist/esm/common/util/global-scope.test.js +0 -70
  283. package/dist/esm/common/util/invoke.test.js +0 -47
  284. package/dist/esm/common/util/map-own.test.js +0 -47
  285. package/dist/esm/common/util/obfuscate.component-test.js +0 -125
  286. package/dist/esm/common/util/stringify.test.js +0 -46
  287. package/dist/esm/common/util/submit-data.test.js +0 -241
  288. package/dist/esm/common/util/traverse.test.js +0 -42
  289. package/dist/esm/common/wrap/wrap-promise.test.js +0 -115
  290. package/dist/esm/features/jserrors/aggregate/canonical-function-name.test.js +0 -29
  291. package/dist/esm/features/jserrors/aggregate/compute-stack-trace.test.js +0 -379
  292. package/dist/esm/features/jserrors/aggregate/format-stack-trace.test.js +0 -38
  293. package/dist/esm/features/jserrors/aggregate/string-hash-code.test.js +0 -25
  294. package/dist/esm/features/metrics/aggregate/framework-detection.test.js +0 -133
  295. package/dist/esm/features/metrics/aggregate/polyfill-detection.es5.test.js +0 -15
  296. package/dist/esm/features/metrics/aggregate/polyfill-detection.test.js +0 -163
  297. package/dist/esm/features/session_replay/aggregate/index.component-test.js +0 -453
  298. package/dist/esm/features/spa/aggregate/interaction-node.test.js +0 -14
  299. package/dist/esm/features/utils/agent-session.test.js +0 -207
  300. package/dist/esm/features/utils/aggregate-base.test.js +0 -108
  301. package/dist/esm/features/utils/feature-base.test.js +0 -40
  302. package/dist/esm/features/utils/handler-cache.test.js +0 -51
  303. package/dist/esm/features/utils/instrument-base.test.js +0 -175
  304. package/dist/esm/features/utils/lazy-feature-loader.test.js +0 -29
  305. package/dist/types/common/browser-version/firefox-version.d.ts +0 -2
  306. package/dist/types/common/browser-version/firefox-version.d.ts.map +0 -1
  307. package/dist/types/common/browser-version/ios-version.d.ts +0 -3
  308. package/dist/types/common/browser-version/ios-version.d.ts.map +0 -1
  309. package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts +0 -2
  310. package/dist/types/common/harvest/harvest-scheduler.component-test.d.ts.map +0 -1
  311. package/dist/types/common/harvest/harvest.component-test.d.ts +0 -2
  312. package/dist/types/common/harvest/harvest.component-test.d.ts.map +0 -1
  313. package/dist/types/common/session/session-entity.component-test.d.ts +0 -2
  314. package/dist/types/common/session/session-entity.component-test.d.ts.map +0 -1
  315. package/dist/types/common/timer/interaction-timer.component-test.d.ts +0 -2
  316. package/dist/types/common/timer/interaction-timer.component-test.d.ts.map +0 -1
  317. package/dist/types/common/url/encode.component-test.d.ts +0 -2
  318. package/dist/types/common/url/encode.component-test.d.ts.map +0 -1
  319. package/dist/types/common/url/protocol.component-test.d.ts +0 -2
  320. package/dist/types/common/url/protocol.component-test.d.ts.map +0 -1
  321. package/dist/types/common/util/global-scope.d.ts +0 -5
  322. package/dist/types/common/util/global-scope.d.ts.map +0 -1
  323. package/dist/types/common/util/obfuscate.component-test.d.ts +0 -2
  324. package/dist/types/common/util/obfuscate.component-test.d.ts.map +0 -1
  325. package/dist/types/features/session_replay/aggregate/index.component-test.d.ts +0 -2
  326. package/dist/types/features/session_replay/aggregate/index.component-test.d.ts.map +0 -1
  327. package/src/common/browser-version/firefox-version.js +0 -10
  328. package/src/common/browser-version/ios-version.js +0 -11
  329. package/src/common/harvest/harvest-scheduler.component-test.js +0 -25
  330. package/src/common/harvest/harvest.component-test.js +0 -169
  331. package/src/common/util/global-scope.js +0 -23
  332. package/src/common/util/global-scope.test.js +0 -87
@@ -1,214 +0,0 @@
1
- import { InteractionTimer } from './interaction-timer';
2
- jest.useFakeTimers();
3
- let now;
4
- beforeEach(() => {
5
- now = Date.now();
6
- jest.setSystemTime(now);
7
- });
8
- afterEach(() => {
9
- jest.clearAllMocks();
10
- });
11
- describe('constructor', () => {
12
- test('appropriate properties are set with valid values -- no refresh', () => {
13
- const timer = new InteractionTimer({
14
- onEnd: jest.fn()
15
- }, 100);
16
- const requiredKeys = ['onEnd', 'initialMs', 'startTimestamp', 'timer'];
17
- expect(requiredKeys.every(rk => !!timer[rk])).toBeTruthy();
18
- });
19
- test('appropriate properties are set with valid values -- with refresh', () => {
20
- const timer = new InteractionTimer({
21
- onEnd: jest.fn()
22
- }, 100);
23
- const requiredKeys = ['onEnd', 'refresh', 'initialMs', 'startTimestamp', 'timer'];
24
- expect(requiredKeys.every(rk => !!timer[rk])).toBeTruthy();
25
- });
26
- test('required keys are enforced', () => {
27
- try {
28
- new InteractionTimer({}, 100);
29
- } catch (e) {
30
- expect(e).toEqual(new Error('onEnd handler is required'));
31
- }
32
- try {
33
- new InteractionTimer({
34
- onEnd: jest.fn()
35
- });
36
- } catch (e) {
37
- expect(e).toEqual(new Error('ms duration is required'));
38
- }
39
- });
40
- test('refresh type timers set event listeners', () => {
41
- // eslint-disable-next-line
42
- let ee = {
43
- on: jest.fn().mockImplementation((evt, cb) => {
44
- cb([{
45
- type: 'click'
46
- }]);
47
- })
48
- };
49
- let it = new InteractionTimer({
50
- onEnd: jest.fn(),
51
- onRefresh: jest.fn(),
52
- ee
53
- }, 100);
54
- // scroll, keypress, click
55
- expect(ee.on).toHaveBeenCalledTimes(1);
56
- expect(it.onRefresh).toHaveBeenCalledTimes(1);
57
-
58
- // eslint-disable-next-line
59
- ee = {
60
- on: jest.fn().mockImplementation((evt, cb) => {
61
- cb([{
62
- type: 'scroll'
63
- }]);
64
- })
65
- };
66
- it = new InteractionTimer({
67
- onEnd: jest.fn(),
68
- onRefresh: jest.fn(),
69
- ee
70
- }, 100);
71
- // scroll, keypress, click
72
- expect(ee.on).toHaveBeenCalledTimes(1);
73
- expect(it.onRefresh).toHaveBeenCalledTimes(1);
74
-
75
- // eslint-disable-next-line
76
- ee = {
77
- on: jest.fn().mockImplementation((evt, cb) => {
78
- cb([{
79
- type: 'keydown'
80
- }]);
81
- })
82
- };
83
- it = new InteractionTimer({
84
- onEnd: jest.fn(),
85
- onRefresh: jest.fn(),
86
- ee
87
- }, 100);
88
- // scroll, keypress, click
89
- expect(ee.on).toHaveBeenCalledTimes(1);
90
- expect(it.onRefresh).toHaveBeenCalledTimes(1);
91
- const aelSpy = jest.spyOn(document, 'addEventListener');
92
- // eslint-disable-next-line
93
- ee = {
94
- on: jest.fn().mockImplementation((evt, cb) => {
95
- cb([{
96
- type: 'keydown'
97
- }]);
98
- })
99
- };
100
- it = new InteractionTimer({
101
- onEnd: jest.fn(),
102
- onRefresh: jest.fn(),
103
- ee
104
- }, 100);
105
- // visibility change
106
- expect(aelSpy).toHaveBeenCalledTimes(1);
107
- });
108
- });
109
- describe('create()', () => {
110
- test('Create sets a timeout that can execute a cb', () => {
111
- const timer = new InteractionTimer({
112
- onEnd: jest.fn()
113
- }, 100);
114
- expect(timer.timer).toBeTruthy();
115
- expect(timer.onEnd).toHaveBeenCalledTimes(0);
116
- jest.runOnlyPendingTimers();
117
- expect(timer.onEnd).toHaveBeenCalledTimes(1);
118
- });
119
- test('Create can fallback to use defaults', () => {
120
- let called = 0;
121
- const timer1 = new InteractionTimer({
122
- onEnd: jest.fn()
123
- }, 100);
124
- timer1.create();
125
- const timer2 = new InteractionTimer({
126
- onEnd: jest.fn()
127
- }, 100);
128
- timer2.create(timer2.onEnd);
129
- const timer3 = new InteractionTimer({
130
- onEnd: jest.fn()
131
- }, 100);
132
- timer3.create(undefined, 100);
133
- jest.runAllTimers(200);
134
- expect(timer1.onEnd).toHaveBeenCalledTimes(1);
135
- expect(timer2.onEnd).toHaveBeenCalledTimes(1);
136
- expect(timer3.onEnd).toHaveBeenCalledTimes(1);
137
- });
138
- });
139
- describe('refresh()', () => {
140
- test('refresh prevents the callback from firing', () => {
141
- const timer = new InteractionTimer({
142
- onEnd: jest.fn(),
143
- onRefresh: jest.fn()
144
- }, 100);
145
- expect(timer.onEnd).toHaveBeenCalledTimes(0);
146
- jest.advanceTimersByTime(75);
147
- expect(timer.onEnd).toHaveBeenCalledTimes(0);
148
- timer.refresh();
149
- jest.advanceTimersByTime(75);
150
- expect(timer.onEnd).toHaveBeenCalledTimes(0);
151
- jest.advanceTimersByTime(100);
152
- expect(timer.onEnd).toHaveBeenCalledTimes(1);
153
- });
154
- test('refresh executes a callback for consumers', () => {
155
- const timer = new InteractionTimer({
156
- onEnd: jest.fn(),
157
- onRefresh: jest.fn()
158
- }, 100);
159
- timer.refresh();
160
- expect(timer.onRefresh).toHaveBeenCalledTimes(1);
161
- });
162
- });
163
- describe('pause()', () => {
164
- test('pause prevents the callback from firing', () => {
165
- const timer = new InteractionTimer({
166
- onEnd: jest.fn()
167
- }, 100);
168
- expect(timer.onEnd).toHaveBeenCalledTimes(0);
169
- timer.pause();
170
- jest.advanceTimersByTime(150);
171
- expect(timer.onEnd).toHaveBeenCalledTimes(0);
172
- });
173
- test('pause sets remainingMs timestamp', () => {
174
- const timer = new InteractionTimer({
175
- onEnd: jest.fn()
176
- }, 100);
177
- expect(timer.remainingMs).toEqual(undefined);
178
- timer.pause();
179
- expect(timer.remainingMs).toEqual(timer.initialMs - (now - timer.startTimestamp));
180
- });
181
- });
182
- describe('clear()', () => {
183
- test('clear prevents the callback from firing and deletes the pointer', () => {
184
- const timer = new InteractionTimer({
185
- onEnd: jest.fn()
186
- }, 100);
187
- expect(timer.onEnd).toHaveBeenCalledTimes(0);
188
- timer.clear();
189
- jest.advanceTimersByTime(150);
190
- expect(timer.onEnd).toHaveBeenCalledTimes(0);
191
- expect(timer.timer).toEqual(null);
192
- });
193
- });
194
- describe('end()', () => {
195
- test('end clears the callback and calls the onEnd callback', () => {
196
- const timer = new InteractionTimer({
197
- onEnd: jest.fn()
198
- }, 100);
199
- expect(timer.onEnd).toHaveBeenCalledTimes(0);
200
- timer.end();
201
- expect(timer.onEnd).toHaveBeenCalledTimes(1);
202
- expect(timer.timer).toEqual(null);
203
- });
204
- });
205
- describe('isValid', () => {
206
- test('isValid validates timeStamps', () => {
207
- const timer = new InteractionTimer({
208
- onEnd: jest.fn()
209
- }, 100);
210
- expect(timer.isValid()).toEqual(true);
211
- timer.startTimestamp -= 100;
212
- expect(timer.isValid()).toEqual(false);
213
- });
214
- });
@@ -1,103 +0,0 @@
1
- import { Timer } from './timer';
2
- jest.useFakeTimers();
3
- let now;
4
- beforeEach(() => {
5
- now = Date.now();
6
- jest.setSystemTime(now);
7
- });
8
- afterEach(() => {
9
- jest.clearAllMocks();
10
- });
11
- describe('constructor', () => {
12
- test('appropriate properties are set with valid values -- no refresh', () => {
13
- const timer = new Timer({
14
- onEnd: jest.fn()
15
- }, 100);
16
- const requiredKeys = ['onEnd', 'initialMs', 'startTimestamp', 'timer'];
17
- expect(requiredKeys.every(rk => !!timer[rk])).toBeTruthy();
18
- });
19
- test('appropriate properties are set with valid values -- with refresh', () => {
20
- const timer = new Timer({
21
- onEnd: jest.fn()
22
- }, 100);
23
- const requiredKeys = ['onEnd', 'initialMs', 'startTimestamp', 'timer'];
24
- expect(requiredKeys.every(rk => !!timer[rk])).toBeTruthy();
25
- });
26
- test('required keys are enforced', () => {
27
- try {
28
- new Timer({}, 100);
29
- } catch (e) {
30
- expect(e).toEqual(new Error('onEnd handler is required'));
31
- }
32
- try {
33
- new Timer({
34
- onEnd: jest.fn()
35
- });
36
- } catch (e) {
37
- expect(e).toEqual(new Error('ms duration is required'));
38
- }
39
- });
40
- });
41
- describe('create()', () => {
42
- test('Create sets a timeout that can execute a cb', () => {
43
- const timer = new Timer({
44
- onEnd: jest.fn()
45
- }, 100);
46
- expect(timer.timer).toBeTruthy();
47
- expect(timer.onEnd).toHaveBeenCalledTimes(0);
48
- jest.runOnlyPendingTimers();
49
- expect(timer.onEnd).toHaveBeenCalledTimes(1);
50
- });
51
- test('Create can fallback to use defaults', () => {
52
- let called = 0;
53
- const timer1 = new Timer({
54
- onEnd: jest.fn()
55
- }, 100);
56
- timer1.create();
57
- const timer2 = new Timer({
58
- onEnd: jest.fn()
59
- }, 100);
60
- timer2.create(timer2.onEnd);
61
- const timer3 = new Timer({
62
- onEnd: jest.fn()
63
- }, 100);
64
- timer3.create(undefined, 100);
65
- jest.runAllTimers(200);
66
- expect(timer1.onEnd).toHaveBeenCalledTimes(1);
67
- expect(timer2.onEnd).toHaveBeenCalledTimes(1);
68
- expect(timer3.onEnd).toHaveBeenCalledTimes(1);
69
- });
70
- });
71
- describe('clear()', () => {
72
- test('clear prevents the callback from firing and deletes the pointer', () => {
73
- const timer = new Timer({
74
- onEnd: jest.fn()
75
- }, 100);
76
- expect(timer.onEnd).toHaveBeenCalledTimes(0);
77
- timer.clear();
78
- jest.advanceTimersByTime(150);
79
- expect(timer.onEnd).toHaveBeenCalledTimes(0);
80
- expect(timer.timer).toEqual(null);
81
- });
82
- });
83
- describe('end()', () => {
84
- test('end clears the callback and calls the onEnd callback', () => {
85
- const timer = new Timer({
86
- onEnd: jest.fn()
87
- }, 100);
88
- expect(timer.onEnd).toHaveBeenCalledTimes(0);
89
- timer.end();
90
- expect(timer.onEnd).toHaveBeenCalledTimes(1);
91
- expect(timer.timer).toEqual(null);
92
- });
93
- });
94
- describe('isValid', () => {
95
- test('isValid validates timeStamps', () => {
96
- const timer = new Timer({
97
- onEnd: jest.fn()
98
- }, 100);
99
- expect(timer.isValid()).toEqual(true);
100
- timer.startTimestamp -= 100;
101
- expect(timer.isValid()).toEqual(false);
102
- });
103
- });
@@ -1,190 +0,0 @@
1
- import { addPT, addPN, navTimingValues } from './nav-timing';
2
- const offset = 123;
3
- const testValues = {
4
- unloadEventStart: 1,
5
- redirectStart: 2,
6
- unloadEventEnd: 3,
7
- redirectEnd: 4,
8
- fetchStart: 5,
9
- domainLookupStart: 6,
10
- domainLookupEnd: 7,
11
- connectStart: 8,
12
- secureConnectionStart: 9,
13
- connectEnd: 10,
14
- requestStart: 11,
15
- responseStart: 12,
16
- responseEnd: 13,
17
- domLoading: 14,
18
- domInteractive: 15,
19
- domContentLoadedEventStart: 16,
20
- domContentLoadedEventEnd: 17,
21
- domComplete: 18,
22
- loadEventStart: 19,
23
- loadEventEnd: 20,
24
- type: 'reload',
25
- redirectCount: 22
26
- };
27
- const legacyTestValues = {
28
- unloadEventStart: offset + 1,
29
- redirectStart: offset + 2,
30
- unloadEventEnd: offset + 3,
31
- redirectEnd: offset + 4,
32
- fetchStart: offset + 5,
33
- domainLookupStart: offset + 6,
34
- domainLookupEnd: offset + 7,
35
- connectStart: offset + 8,
36
- secureConnectionStart: offset + 9,
37
- connectEnd: offset + 10,
38
- requestStart: offset + 11,
39
- responseStart: offset + 12,
40
- responseEnd: offset + 13,
41
- domLoading: offset + 14,
42
- domInteractive: offset + 15,
43
- domContentLoadedEventStart: offset + 16,
44
- domContentLoadedEventEnd: offset + 17,
45
- domComplete: offset + 18,
46
- loadEventStart: offset + 19,
47
- loadEventEnd: offset + 20,
48
- type: 'reload',
49
- redirectCount: offset + 22
50
- };
51
- const expectedPT = {
52
- of: offset,
53
- n: 0,
54
- u: 1,
55
- r: 2,
56
- ue: 3,
57
- re: 4,
58
- f: 5,
59
- dn: 6,
60
- dne: 7,
61
- c: 8,
62
- s: 9,
63
- ce: 10,
64
- rq: 11,
65
- rp: 12,
66
- rpe: 13,
67
- dl: 14,
68
- di: 15,
69
- ds: 16,
70
- de: 17,
71
- dc: 18,
72
- l: 19,
73
- le: 20
74
- };
75
- const expectedPN = {
76
- ty: 1,
77
- rc: 22
78
- };
79
- describe('addPT()', () => {
80
- test('an output object is populated with valid values', () => {
81
- const output = addPT(offset, testValues, {});
82
- expect(output).toEqual(expectedPT);
83
- });
84
- test('an object with invalid values is handled', () => {
85
- const output = addPT(offset, {
86
- ...testValues,
87
- invalidValue: 'test'
88
- }, {});
89
- expect(output).toEqual(expectedPT);
90
- const output2 = addPT(offset, {
91
- ...testValues,
92
- loadEventEnd: -1
93
- }, {});
94
- let expected = {
95
- ...expectedPT
96
- };
97
- delete expected.le;
98
- expect(output2).toEqual(expected);
99
- const output3 = addPT(offset, {
100
- ...testValues,
101
- loadEventEnd: 'test'
102
- }, {});
103
- expected = {
104
- ...expectedPT
105
- };
106
- delete expected.le;
107
- expect(output3).toEqual(expected);
108
- const output4 = addPT(offset, {
109
- ...testValues,
110
- loadEventEnd: null
111
- }, {});
112
- expected = {
113
- ...expectedPT
114
- };
115
- delete expected.le;
116
- expect(output4).toEqual(expected);
117
- const legacyoutput = addPT(offset, {
118
- ...legacyTestValues,
119
- invalidValue: 'test'
120
- }, {}, true);
121
- expect(legacyoutput).toEqual(expectedPT);
122
- const legacyoutput2 = addPT(offset, {
123
- ...legacyTestValues,
124
- loadEventEnd: -1
125
- }, {}, true);
126
- let legacyexpected = {
127
- ...expectedPT
128
- };
129
- delete legacyexpected.le;
130
- expect(legacyoutput2).toEqual(expected);
131
- const legacyoutput3 = addPT(offset, {
132
- ...legacyTestValues,
133
- loadEventEnd: 'test'
134
- }, {}, true);
135
- legacyexpected = {
136
- ...expectedPT
137
- };
138
- delete legacyexpected.le;
139
- expect(legacyoutput3).toEqual(legacyexpected);
140
- const legacyoutput4 = addPT(offset, {
141
- ...legacyTestValues,
142
- loadEventEnd: null
143
- }, {}, true);
144
- legacyexpected = {
145
- ...expectedPT
146
- };
147
- delete legacyexpected.le;
148
- expect(legacyoutput4).toEqual(legacyexpected);
149
- });
150
- test('rounds values to integers', () => {
151
- const output = addPT(offset, {
152
- unloadEventStart: 3.14159
153
- }, {});
154
- expect(output.u).toEqual(3);
155
- const legacyoutput = addPT(0, {
156
- unloadEventStart: 3.14159
157
- }, {}, true);
158
- expect(legacyoutput.u).toEqual(3);
159
- });
160
- test('adds entries to navTimingValues', () => {
161
- const beforeLength = navTimingValues.length;
162
- addPT(offset, {
163
- testValues
164
- }, {});
165
- const afterLength = navTimingValues.length;
166
- expect(afterLength - beforeLength).toEqual(21); // 20 + value of n
167
-
168
- const legacybeforeLength = navTimingValues.length;
169
- addPT(offset, {
170
- legacyTestValues
171
- }, {}, true);
172
- const legacyafterLength = navTimingValues.length;
173
- expect(legacyafterLength - legacybeforeLength).toEqual(21); // 20 + value of n
174
- });
175
- });
176
-
177
- describe('addPN()', () => {
178
- test('an output object is populated with valid values', () => {
179
- const output = addPN(testValues, {});
180
- expect(output).toEqual(expectedPN);
181
- });
182
- test('adds entries to navTimingValues', () => {
183
- const beforeLength = navTimingValues.length;
184
- addPN(offset, {
185
- testValues
186
- }, {});
187
- const afterLength = navTimingValues.length;
188
- expect(afterLength - beforeLength).toEqual(2);
189
- });
190
- });
@@ -1,34 +0,0 @@
1
- import { faker } from '@faker-js/faker';
2
- import * as globalScopeModule from '../util/global-scope';
3
- import * as cleanUrlModule from './clean-url';
4
- import { canonicalizeUrl } from './canonicalize-url';
5
- jest.mock('../util/global-scope');
6
- jest.mock('./clean-url');
7
- beforeEach(() => {
8
- jest.spyOn(cleanUrlModule, 'cleanURL').mockImplementation(input => input);
9
- jest.replaceProperty(globalScopeModule, 'initialLocation', faker.internet.url());
10
- });
11
- afterEach(() => {
12
- jest.resetAllMocks();
13
- });
14
- test.each([null, undefined, 34])('returns empty string when url argument is %s', async url => {
15
- expect(canonicalizeUrl(url)).toEqual('');
16
- });
17
- test('uses cleanURL to clean the input and initial location URLs', () => {
18
- const url = faker.internet.url();
19
- canonicalizeUrl(url);
20
- expect(cleanUrlModule.cleanURL).toHaveBeenCalledWith(globalScopeModule.initialLocation);
21
- expect(cleanUrlModule.cleanURL).toHaveBeenCalledWith(url);
22
- expect(cleanUrlModule.cleanURL).toHaveBeenCalledTimes(2);
23
- });
24
- test('returns <inline> when input and initial page urls are the same', async () => {
25
- expect(canonicalizeUrl(globalScopeModule.initialLocation)).toEqual('<inline>');
26
- });
27
- test('returns input url when it does not match initial page url', async () => {
28
- const url = faker.internet.url();
29
- expect(canonicalizeUrl(url)).toEqual(url);
30
- });
31
- test('does not identify sub-paths of the loader origin as <inline>', async () => {
32
- const url = globalScopeModule.initialLocation + '/path/to/script.js';
33
- expect(canonicalizeUrl(url)).not.toEqual('<inline>');
34
- });
@@ -1,7 +0,0 @@
1
- import { cleanURL } from './clean-url';
2
- test.each([['http://domain.com/path?query=5', 'http://domain.com/path'], ['http://domain.com/path#fragment', 'http://domain.com/path'], ['http://domain.com/path?query=5#fragment', 'http://domain.com/path'], ['http://domain.com/path?query=5?dumb#fragment', 'http://domain.com/path'], ['http://domain.com/path?query=5#fragment#dumb', 'http://domain.com/path'], ['http://domain.com/path?query=5#fragment#dumb?additional_query', 'http://domain.com/path'], ['http://domain.com/path?query=5#fragment/silly/dumber#dumbest?additional_query=silly#what_is_this_even', 'http://domain.com/path']])('cleanURL should remove hash', (input, expected) => {
3
- expect(cleanURL(input)).toEqual(expected);
4
- });
5
- test.each([['http://domain.com/path?query=5', 'http://domain.com/path'], ['http://domain.com/path#fragment', 'http://domain.com/path#fragment'], ['http://domain.com/path?query=5#fragment', 'http://domain.com/path#fragment'], ['http://domain.com/path?query=5?dumb#fragment', 'http://domain.com/path#fragment'], ['http://domain.com/path?query=5#fragment#dumb', 'http://domain.com/path#fragment#dumb'], ['http://domain.com/path?query=5#fragment#dumb?additional_query', 'http://domain.com/path#fragment#dumb'], ['http://domain.com/path?query=5#fragment/silly/dumber#dumbest?additional_query=silly#what_is_this_even', 'http://domain.com/path#fragment/silly/dumber#dumbest']])('cleanURL should retain hash if second argument is true', (input, expected) => {
6
- expect(cleanURL(input, true)).toEqual(expected);
7
- });
@@ -1,70 +0,0 @@
1
- import * as encode from './encode';
2
- describe('query string encoding', () => {
3
- test('escapes string components except safe characters', () => {
4
- const input = 'Asdf:, :, /@$;';
5
- const expected = 'Asdf:,%20:,%20/@$;';
6
- expect(encode.qs(input)).toEqual(expected);
7
- });
8
- test('null and undefined value returns \'null\'', () => {
9
- expect(encode.qs(null)).toEqual('null');
10
- expect(encode.qs(undefined)).toEqual('null');
11
- });
12
- });
13
- describe('fromArray encoding', () => {
14
- test('cuts cleanly at end of byte', () => {
15
- const input = ['a', 'b', 'c'];
16
- const expected = 'ab';
17
- expect(encode.fromArray(input, 2)).toEqual(expected);
18
- });
19
- test('fall back to largest whole chunk', () => {
20
- const input = ['aa', 'bb', 'cc'];
21
- const expected = 'aabb';
22
- expect(encode.fromArray(input, 5)).toEqual(expected);
23
- });
24
- });
25
- describe('object encoding', () => {
26
- test('cuts cleanly at end of byte', () => {
27
- const input = {
28
- foo: [1, 2, 3]
29
- };
30
- const expected = '&foo=%5B1,2%5D';
31
- expect(encode.obj(input, 12)).toEqual(expected);
32
- });
33
- test('fall back to largest whole chunk', () => {
34
- const input = {
35
- bar: ['a', 'b', 'c']
36
- };
37
- const expected = '&bar=%5B%22a%22,%22b%22%5D';
38
- expect(encode.obj(input, 30)).toEqual(expected);
39
- });
40
- test('handles circular objects', () => {
41
- const circular = {};
42
- circular.circular = circular;
43
- const input = {
44
- bar: ['a', circular, 'c']
45
- };
46
- const expected = '&bar=%5B%22a%22,%7B%7D,%22c%22%5D';
47
- expect(encode.obj(input, 1000)).toEqual(expected);
48
- });
49
- test('handles circular arrays', () => {
50
- const circular = [];
51
- circular.push(circular);
52
- const input = {
53
- bar: ['a', circular, 'c']
54
- };
55
- const expected = '&bar=%5B%22a%22,%5Bnull%5D,%22c%22%5D';
56
- expect(encode.obj(input, 1000)).toEqual(expected);
57
- });
58
- });
59
- describe('encode key value pairs as query params', () => {
60
- test('ignores input when value is null or undefined', () => {
61
- expect(encode.param('foo', null)).toEqual('');
62
- expect(encode.param('foo', undefined)).toEqual('');
63
- });
64
- test('encodes key value pair correctly', () => {
65
- expect(encode.param('foo', 'bar')).toEqual('&foo=bar');
66
- });
67
- test('ignores input when value is not a string', () => {
68
- expect(encode.param('foo', {})).toEqual('');
69
- });
70
- });
@@ -1,11 +0,0 @@
1
- import { faker } from '@faker-js/faker';
2
- import { getLocation } from './location';
3
- test('should always return a string', () => {
4
- jest.spyOn(window, 'location', 'get').mockReturnValue({});
5
- expect(typeof getLocation()).toEqual('string');
6
- });
7
- test('should return window location', () => {
8
- const expected = faker.internet.url();
9
- jest.spyOn(window, 'location', 'get').mockReturnValue(expected);
10
- expect(getLocation()).toEqual(expected);
11
- });