@angular/core 13.0.0-next.9 → 13.0.0-rc.3

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 (558) hide show
  1. package/core.d.ts +791 -1180
  2. package/esm2020/core.mjs +5 -0
  3. package/esm2020/index.mjs +14 -0
  4. package/{esm2015/public_api.js → esm2020/public_api.mjs} +0 -0
  5. package/esm2020/src/application_init.mjs +140 -0
  6. package/esm2020/src/application_module.mjs +130 -0
  7. package/esm2020/src/application_ref.mjs +738 -0
  8. package/{esm2015/src/application_tokens.js → esm2020/src/application_tokens.mjs} +0 -0
  9. package/esm2020/src/change_detection/change_detection.mjs +31 -0
  10. package/esm2020/src/change_detection/change_detection_util.mjs +64 -0
  11. package/esm2020/src/change_detection/change_detector_ref.mjs +89 -0
  12. package/{esm2015/src/change_detection/constants.js → esm2020/src/change_detection/constants.mjs} +0 -0
  13. package/esm2020/src/change_detection/differs/default_iterable_differ.mjs +666 -0
  14. package/{esm2015/src/change_detection/differs/default_keyvalue_differ.js → esm2020/src/change_detection/differs/default_keyvalue_differ.mjs} +0 -0
  15. package/{esm2015/src/change_detection/differs/iterable_differs.js → esm2020/src/change_detection/differs/iterable_differs.mjs} +0 -0
  16. package/{esm2015/src/change_detection/differs/keyvalue_differs.js → esm2020/src/change_detection/differs/keyvalue_differs.mjs} +0 -0
  17. package/{esm2015/src/change_detection/pipe_transform.js → esm2020/src/change_detection/pipe_transform.mjs} +0 -0
  18. package/esm2020/src/change_detection.mjs +14 -0
  19. package/esm2020/src/codegen_private_exports.mjs +11 -0
  20. package/{esm2015/src/compiler/compiler_facade.js → esm2020/src/compiler/compiler_facade.mjs} +0 -0
  21. package/{esm2015/src/compiler/compiler_facade_interface.js → esm2020/src/compiler/compiler_facade_interface.mjs} +1 -1
  22. package/esm2020/src/console.mjs +26 -0
  23. package/esm2020/src/core.mjs +52 -0
  24. package/esm2020/src/core_private_export.mjs +34 -0
  25. package/esm2020/src/core_render3_private_export.mjs +47 -0
  26. package/esm2020/src/debug/debug_node.mjs +625 -0
  27. package/{esm2015/src/debug/proxy.js → esm2020/src/debug/proxy.mjs} +0 -0
  28. package/{esm2015/src/di/forward_ref.js → esm2020/src/di/forward_ref.mjs} +0 -0
  29. package/{esm2015/src/di/index.js → esm2020/src/di/index.mjs} +0 -0
  30. package/{esm2015/src/di/inject_switch.js → esm2020/src/di/inject_switch.mjs} +0 -0
  31. package/esm2020/src/di/injectable.mjs +27 -0
  32. package/esm2020/src/di/injection_token.mjs +82 -0
  33. package/esm2020/src/di/injector.mjs +323 -0
  34. package/esm2020/src/di/injector_compatibility.mjs +185 -0
  35. package/{esm2015/src/di/injector_marker.js → esm2020/src/di/injector_marker.mjs} +0 -0
  36. package/{esm2015/src/di/injector_token.js → esm2020/src/di/injector_token.mjs} +0 -0
  37. package/{esm2015/src/di/interface/defs.js → esm2020/src/di/interface/defs.mjs} +0 -0
  38. package/{esm2015/src/di/interface/injector.js → esm2020/src/di/interface/injector.mjs} +0 -0
  39. package/{esm2015/src/di/interface/provider.js → esm2020/src/di/interface/provider.mjs} +0 -0
  40. package/{esm2015/src/di/jit/environment.js → esm2020/src/di/jit/environment.mjs} +0 -0
  41. package/esm2020/src/di/jit/injectable.mjs +94 -0
  42. package/{esm2015/src/di/jit/util.js → esm2020/src/di/jit/util.mjs} +0 -0
  43. package/esm2020/src/di/metadata.mjs +60 -0
  44. package/esm2020/src/di/metadata_attr.mjs +24 -0
  45. package/{esm2015/src/di/null_injector.js → esm2020/src/di/null_injector.mjs} +0 -0
  46. package/{esm2015/src/di/provider_token.js → esm2020/src/di/provider_token.mjs} +0 -0
  47. package/{esm2015/src/di/r3_injector.js → esm2020/src/di/r3_injector.mjs} +0 -0
  48. package/{esm2015/src/di/reflective_errors.js → esm2020/src/di/reflective_errors.mjs} +0 -0
  49. package/{esm2015/src/di/reflective_injector.js → esm2020/src/di/reflective_injector.mjs} +0 -0
  50. package/{esm2015/src/di/reflective_key.js → esm2020/src/di/reflective_key.mjs} +0 -0
  51. package/{esm2015/src/di/reflective_provider.js → esm2020/src/di/reflective_provider.mjs} +0 -0
  52. package/{esm2015/src/di/scope.js → esm2020/src/di/scope.mjs} +0 -0
  53. package/esm2020/src/di/util.mjs +51 -0
  54. package/{esm2015/src/di.js → esm2020/src/di.mjs} +0 -0
  55. package/{esm2015/src/error_handler.js → esm2020/src/error_handler.mjs} +0 -0
  56. package/{esm2015/src/errors.js → esm2020/src/errors.mjs} +0 -0
  57. package/esm2020/src/event_emitter.mjs +53 -0
  58. package/{esm2015/src/i18n/locale_data_api.js → esm2020/src/i18n/locale_data_api.mjs} +0 -0
  59. package/esm2020/src/i18n/locale_en.mjs +17 -0
  60. package/{esm2015/src/i18n/localization.js → esm2020/src/i18n/localization.mjs} +0 -0
  61. package/{esm2015/src/i18n/tokens.js → esm2020/src/i18n/tokens.mjs} +0 -0
  62. package/{esm2015/src/interface/lifecycle_hooks.js → esm2020/src/interface/lifecycle_hooks.mjs} +0 -0
  63. package/{esm2015/src/interface/simple_change.js → esm2020/src/interface/simple_change.mjs} +0 -0
  64. package/{esm2015/src/interface/type.js → esm2020/src/interface/type.mjs} +0 -0
  65. package/{esm2015/src/ivy_switch.js → esm2020/src/ivy_switch.mjs} +2 -2
  66. package/esm2020/src/linker/compiler.mjs +136 -0
  67. package/{esm2015/src/linker/component_factory.js → esm2020/src/linker/component_factory.mjs} +0 -0
  68. package/{esm2015/src/linker/component_factory_resolver.js → esm2020/src/linker/component_factory_resolver.mjs} +5 -5
  69. package/esm2020/src/linker/element_ref.mjs +59 -0
  70. package/esm2020/src/linker/ng_module_factory.mjs +29 -0
  71. package/esm2020/src/linker/ng_module_factory_loader.mjs +42 -0
  72. package/esm2020/src/linker/ng_module_factory_loader_impl.mjs +10 -0
  73. package/{esm2015/src/linker/ng_module_factory_registration.js → esm2020/src/linker/ng_module_factory_registration.mjs} +2 -2
  74. package/{esm2015/src/linker/query_list.js → esm2020/src/linker/query_list.mjs} +0 -0
  75. package/{esm2015/src/linker/template_ref.js → esm2020/src/linker/template_ref.mjs} +2 -2
  76. package/esm2020/src/linker/view_container_ref.mjs +283 -0
  77. package/{esm2015/src/linker/view_ref.js → esm2020/src/linker/view_ref.mjs} +0 -0
  78. package/esm2020/src/linker.mjs +19 -0
  79. package/esm2020/src/metadata/di.mjs +108 -0
  80. package/esm2020/src/metadata/directives.mjs +112 -0
  81. package/{esm2015/src/metadata/do_boostrap.js → esm2020/src/metadata/do_boostrap.mjs} +0 -0
  82. package/esm2020/src/metadata/ng_module.mjs +42 -0
  83. package/{esm2015/src/metadata/ng_module_def.js → esm2020/src/metadata/ng_module_def.mjs} +0 -0
  84. package/{esm2015/src/metadata/resource_loading.js → esm2020/src/metadata/resource_loading.mjs} +0 -0
  85. package/{esm2015/src/metadata/schema.js → esm2020/src/metadata/schema.mjs} +0 -0
  86. package/{esm2015/src/metadata/view.js → esm2020/src/metadata/view.mjs} +0 -0
  87. package/{esm2015/src/metadata.js → esm2020/src/metadata.mjs} +0 -0
  88. package/{esm2015/src/platform_core_providers.js → esm2020/src/platform_core_providers.mjs} +0 -0
  89. package/{esm2015/src/r3_symbols.js → esm2020/src/r3_symbols.mjs} +0 -0
  90. package/{esm2015/src/reflection/platform_reflection_capabilities.js → esm2020/src/reflection/platform_reflection_capabilities.mjs} +0 -0
  91. package/{esm2015/src/reflection/reflection.js → esm2020/src/reflection/reflection.mjs} +0 -0
  92. package/{esm2015/src/reflection/reflection_capabilities.js → esm2020/src/reflection/reflection_capabilities.mjs} +0 -0
  93. package/{esm2015/src/reflection/reflector.js → esm2020/src/reflection/reflector.mjs} +0 -0
  94. package/{esm2015/src/reflection/types.js → esm2020/src/reflection/types.mjs} +0 -0
  95. package/{esm2015/src/render/api.js → esm2020/src/render/api.mjs} +2 -2
  96. package/{esm2015/src/render/api_flags.js → esm2020/src/render/api_flags.mjs} +0 -0
  97. package/{esm2015/src/render.js → esm2020/src/render.mjs} +0 -0
  98. package/{esm2015/src/render3/assert.js → esm2020/src/render3/assert.mjs} +0 -0
  99. package/{esm2015/src/render3/bindings.js → esm2020/src/render3/bindings.mjs} +0 -0
  100. package/{esm2015/src/render3/collect_native_nodes.js → esm2020/src/render3/collect_native_nodes.mjs} +0 -0
  101. package/esm2020/src/render3/component.mjs +204 -0
  102. package/{esm2015/src/render3/component_ref.js → esm2020/src/render3/component_ref.mjs} +0 -0
  103. package/{esm2015/src/render3/context_discovery.js → esm2020/src/render3/context_discovery.mjs} +0 -0
  104. package/esm2020/src/render3/definition.mjs +296 -0
  105. package/{esm2015/src/render3/definition_factory.js → esm2020/src/render3/definition_factory.mjs} +0 -0
  106. package/{esm2015/src/render3/di.js → esm2020/src/render3/di.mjs} +3 -3
  107. package/{esm2015/src/render3/di_setup.js → esm2020/src/render3/di_setup.mjs} +0 -0
  108. package/esm2020/src/render3/error_code.mjs +42 -0
  109. package/esm2020/src/render3/error_details_base_url.mjs +16 -0
  110. package/{esm2015/src/render3/errors.js → esm2020/src/render3/errors.mjs} +0 -0
  111. package/{esm2015/src/render3/errors_di.js → esm2020/src/render3/errors_di.mjs} +0 -0
  112. package/{esm2015/src/render3/features/copy_definition_feature.js → esm2020/src/render3/features/copy_definition_feature.mjs} +0 -0
  113. package/{esm2015/src/render3/features/inherit_definition_feature.js → esm2020/src/render3/features/inherit_definition_feature.mjs} +0 -0
  114. package/esm2020/src/render3/features/ng_onchanges_feature.mjs +92 -0
  115. package/{esm2015/src/render3/features/providers_feature.js → esm2020/src/render3/features/providers_feature.mjs} +0 -0
  116. package/esm2020/src/render3/fields.mjs +21 -0
  117. package/{esm2015/src/render3/global_utils_api.js → esm2020/src/render3/global_utils_api.mjs} +0 -0
  118. package/{esm2015/src/render3/hooks.js → esm2020/src/render3/hooks.mjs} +0 -0
  119. package/{esm2015/src/render3/i18n/i18n_apply.js → esm2020/src/render3/i18n/i18n_apply.mjs} +0 -0
  120. package/{esm2015/src/render3/i18n/i18n_debug.js → esm2020/src/render3/i18n/i18n_debug.mjs} +0 -0
  121. package/{esm2015/src/render3/i18n/i18n_insert_before_index.js → esm2020/src/render3/i18n/i18n_insert_before_index.mjs} +0 -0
  122. package/{esm2015/src/render3/i18n/i18n_locale_id.js → esm2020/src/render3/i18n/i18n_locale_id.mjs} +0 -0
  123. package/{esm2015/src/render3/i18n/i18n_parse.js → esm2020/src/render3/i18n/i18n_parse.mjs} +0 -0
  124. package/{esm2015/src/render3/i18n/i18n_postprocess.js → esm2020/src/render3/i18n/i18n_postprocess.mjs} +0 -0
  125. package/{esm2015/src/render3/i18n/i18n_tree_shaking.js → esm2020/src/render3/i18n/i18n_tree_shaking.mjs} +0 -0
  126. package/{esm2015/src/render3/i18n/i18n_util.js → esm2020/src/render3/i18n/i18n_util.mjs} +0 -0
  127. package/{esm2015/src/render3/index.js → esm2020/src/render3/index.mjs} +0 -0
  128. package/{esm2015/src/render3/instructions/advance.js → esm2020/src/render3/instructions/advance.mjs} +0 -0
  129. package/{esm2015/src/render3/instructions/all.js → esm2020/src/render3/instructions/all.mjs} +0 -0
  130. package/{esm2015/src/render3/instructions/attribute.js → esm2020/src/render3/instructions/attribute.mjs} +0 -0
  131. package/{esm2015/src/render3/instructions/attribute_interpolation.js → esm2020/src/render3/instructions/attribute_interpolation.mjs} +0 -0
  132. package/{esm2015/src/render3/instructions/change_detection.js → esm2020/src/render3/instructions/change_detection.mjs} +0 -0
  133. package/{esm2015/src/render3/instructions/class_map_interpolation.js → esm2020/src/render3/instructions/class_map_interpolation.mjs} +0 -0
  134. package/{esm2015/src/render3/instructions/di.js → esm2020/src/render3/instructions/di.mjs} +0 -0
  135. package/{esm2015/src/render3/instructions/di_attr.js → esm2020/src/render3/instructions/di_attr.mjs} +0 -0
  136. package/{esm2015/src/render3/instructions/element.js → esm2020/src/render3/instructions/element.mjs} +0 -0
  137. package/{esm2015/src/render3/instructions/element_container.js → esm2020/src/render3/instructions/element_container.mjs} +0 -0
  138. package/{esm2015/src/render3/instructions/get_current_view.js → esm2020/src/render3/instructions/get_current_view.mjs} +0 -0
  139. package/{esm2015/src/render3/instructions/host_property.js → esm2020/src/render3/instructions/host_property.mjs} +0 -0
  140. package/{esm2015/src/render3/instructions/i18n.js → esm2020/src/render3/instructions/i18n.mjs} +0 -0
  141. package/{esm2015/src/render3/instructions/i18n_icu_container_visitor.js → esm2020/src/render3/instructions/i18n_icu_container_visitor.mjs} +0 -0
  142. package/{esm2015/src/render3/instructions/interpolation.js → esm2020/src/render3/instructions/interpolation.mjs} +0 -0
  143. package/{esm2015/src/render3/instructions/listener.js → esm2020/src/render3/instructions/listener.mjs} +0 -0
  144. package/{esm2015/src/render3/instructions/lview_debug.js → esm2020/src/render3/instructions/lview_debug.mjs} +0 -0
  145. package/{esm2015/src/render3/instructions/namespace.js → esm2020/src/render3/instructions/namespace.mjs} +0 -0
  146. package/{esm2015/src/render3/instructions/next_context.js → esm2020/src/render3/instructions/next_context.mjs} +0 -0
  147. package/{esm2015/src/render3/instructions/projection.js → esm2020/src/render3/instructions/projection.mjs} +0 -0
  148. package/{esm2015/src/render3/instructions/property.js → esm2020/src/render3/instructions/property.mjs} +0 -0
  149. package/{esm2015/src/render3/instructions/property_interpolation.js → esm2020/src/render3/instructions/property_interpolation.mjs} +0 -0
  150. package/esm2020/src/render3/instructions/shared.mjs +1811 -0
  151. package/{esm2015/src/render3/instructions/storage.js → esm2020/src/render3/instructions/storage.mjs} +0 -0
  152. package/{esm2015/src/render3/instructions/style_map_interpolation.js → esm2020/src/render3/instructions/style_map_interpolation.mjs} +0 -0
  153. package/{esm2015/src/render3/instructions/style_prop_interpolation.js → esm2020/src/render3/instructions/style_prop_interpolation.mjs} +0 -0
  154. package/{esm2015/src/render3/instructions/styling.js → esm2020/src/render3/instructions/styling.mjs} +0 -0
  155. package/{esm2015/src/render3/instructions/template.js → esm2020/src/render3/instructions/template.mjs} +0 -0
  156. package/{esm2015/src/render3/instructions/text.js → esm2020/src/render3/instructions/text.mjs} +0 -0
  157. package/{esm2015/src/render3/instructions/text_interpolation.js → esm2020/src/render3/instructions/text_interpolation.mjs} +0 -0
  158. package/{esm2015/src/render3/interfaces/container.js → esm2020/src/render3/interfaces/container.mjs} +0 -0
  159. package/{esm2015/src/render3/interfaces/context.js → esm2020/src/render3/interfaces/context.mjs} +0 -0
  160. package/{esm2015/src/render3/interfaces/definition.js → esm2020/src/render3/interfaces/definition.mjs} +0 -0
  161. package/{esm2015/src/render3/interfaces/document.js → esm2020/src/render3/interfaces/document.mjs} +0 -0
  162. package/{esm2015/src/render3/interfaces/i18n.js → esm2020/src/render3/interfaces/i18n.mjs} +0 -0
  163. package/{esm2015/src/render3/interfaces/injector.js → esm2020/src/render3/interfaces/injector.mjs} +0 -0
  164. package/{esm2015/src/render3/interfaces/node.js → esm2020/src/render3/interfaces/node.mjs} +0 -0
  165. package/{esm2015/src/render3/interfaces/player.js → esm2020/src/render3/interfaces/player.mjs} +0 -0
  166. package/{esm2015/src/render3/interfaces/projection.js → esm2020/src/render3/interfaces/projection.mjs} +0 -0
  167. package/{esm2015/src/render3/interfaces/public_definitions.js → esm2020/src/render3/interfaces/public_definitions.mjs} +0 -0
  168. package/{esm2015/src/render3/interfaces/query.js → esm2020/src/render3/interfaces/query.mjs} +0 -0
  169. package/esm2020/src/render3/interfaces/renderer.mjs +27 -0
  170. package/{esm2015/src/render3/interfaces/renderer_dom.js → esm2020/src/render3/interfaces/renderer_dom.mjs} +0 -0
  171. package/{esm2015/src/render3/interfaces/sanitization.js → esm2020/src/render3/interfaces/sanitization.mjs} +0 -0
  172. package/{esm2015/src/render3/interfaces/styling.js → esm2020/src/render3/interfaces/styling.mjs} +0 -0
  173. package/{esm2015/src/render3/interfaces/type_checks.js → esm2020/src/render3/interfaces/type_checks.mjs} +0 -0
  174. package/{esm2015/src/render3/interfaces/view.js → esm2020/src/render3/interfaces/view.mjs} +0 -0
  175. package/esm2020/src/render3/jit/directive.mjs +325 -0
  176. package/esm2020/src/render3/jit/environment.mjs +165 -0
  177. package/{esm2015/src/render3/jit/jit_options.js → esm2020/src/render3/jit/jit_options.mjs} +0 -0
  178. package/{esm2015/src/render3/jit/module.js → esm2020/src/render3/jit/module.mjs} +0 -0
  179. package/esm2020/src/render3/jit/partial.mjs +104 -0
  180. package/{esm2015/src/render3/jit/pipe.js → esm2020/src/render3/jit/pipe.mjs} +0 -0
  181. package/esm2020/src/render3/metadata.mjs +49 -0
  182. package/{esm2015/src/render3/namespaces.js → esm2020/src/render3/namespaces.mjs} +0 -0
  183. package/esm2020/src/render3/ng_module_ref.mjs +119 -0
  184. package/{esm2015/src/render3/node_assert.js → esm2020/src/render3/node_assert.mjs} +0 -0
  185. package/{esm2015/src/render3/node_manipulation.js → esm2020/src/render3/node_manipulation.mjs} +0 -0
  186. package/{esm2015/src/render3/node_manipulation_i18n.js → esm2020/src/render3/node_manipulation_i18n.mjs} +0 -0
  187. package/{esm2015/src/render3/node_selector_matcher.js → esm2020/src/render3/node_selector_matcher.mjs} +0 -0
  188. package/esm2020/src/render3/pipe.mjs +184 -0
  189. package/{esm2015/src/render3/profiler.js → esm2020/src/render3/profiler.mjs} +0 -0
  190. package/{esm2015/src/render3/pure_function.js → esm2020/src/render3/pure_function.mjs} +0 -0
  191. package/{esm2015/src/render3/query.js → esm2020/src/render3/query.mjs} +0 -0
  192. package/{esm2015/src/render3/state.js → esm2020/src/render3/state.mjs} +0 -0
  193. package/{esm2015/src/render3/styling/class_differ.js → esm2020/src/render3/styling/class_differ.mjs} +0 -0
  194. package/{esm2015/src/render3/styling/static_styling.js → esm2020/src/render3/styling/static_styling.mjs} +0 -0
  195. package/{esm2015/src/render3/styling/style_binding_list.js → esm2020/src/render3/styling/style_binding_list.mjs} +0 -0
  196. package/{esm2015/src/render3/styling/styling_parser.js → esm2020/src/render3/styling/styling_parser.mjs} +0 -0
  197. package/{esm2015/src/render3/tokens.js → esm2020/src/render3/tokens.mjs} +0 -0
  198. package/{esm2015/src/render3/util/attrs_utils.js → esm2020/src/render3/util/attrs_utils.mjs} +0 -0
  199. package/{esm2015/src/render3/util/change_detection_utils.js → esm2020/src/render3/util/change_detection_utils.mjs} +0 -0
  200. package/{esm2015/src/render3/util/debug_utils.js → esm2020/src/render3/util/debug_utils.mjs} +0 -0
  201. package/esm2020/src/render3/util/discovery_utils.mjs +411 -0
  202. package/esm2020/src/render3/util/global_utils.mjs +77 -0
  203. package/{esm2015/src/render3/util/injector_utils.js → esm2020/src/render3/util/injector_utils.mjs} +0 -0
  204. package/esm2020/src/render3/util/misc_utils.mjs +61 -0
  205. package/{esm2015/src/render3/util/stringify_utils.js → esm2020/src/render3/util/stringify_utils.mjs} +0 -0
  206. package/{esm2015/src/render3/util/view_traversal_utils.js → esm2020/src/render3/util/view_traversal_utils.mjs} +0 -0
  207. package/{esm2015/src/render3/util/view_utils.js → esm2020/src/render3/util/view_utils.mjs} +0 -0
  208. package/{esm2015/src/render3/view_engine_compatibility_prebound.js → esm2020/src/render3/view_engine_compatibility_prebound.mjs} +0 -0
  209. package/{esm2015/src/render3/view_ref.js → esm2020/src/render3/view_ref.mjs} +0 -0
  210. package/{esm2015/src/sanitization/bypass.js → esm2020/src/sanitization/bypass.mjs} +0 -0
  211. package/{esm2015/src/sanitization/html_sanitizer.js → esm2020/src/sanitization/html_sanitizer.mjs} +0 -0
  212. package/{esm2015/src/sanitization/inert_body.js → esm2020/src/sanitization/inert_body.mjs} +3 -3
  213. package/{esm2015/src/sanitization/sanitization.js → esm2020/src/sanitization/sanitization.mjs} +0 -0
  214. package/{esm2015/src/sanitization/sanitizer.js → esm2020/src/sanitization/sanitizer.mjs} +0 -0
  215. package/{esm2015/src/sanitization/security.js → esm2020/src/sanitization/security.mjs} +0 -0
  216. package/{esm2015/src/sanitization/url_sanitizer.js → esm2020/src/sanitization/url_sanitizer.mjs} +0 -0
  217. package/esm2020/src/testability/testability.mjs +258 -0
  218. package/{esm2015/src/util/array_utils.js → esm2020/src/util/array_utils.mjs} +0 -0
  219. package/{esm2015/src/util/assert.js → esm2020/src/util/assert.mjs} +0 -0
  220. package/{esm2015/src/util/char_code.js → esm2020/src/util/char_code.mjs} +0 -0
  221. package/{esm2015/src/util/closure.js → esm2020/src/util/closure.mjs} +0 -0
  222. package/{esm2015/src/util/comparison.js → esm2020/src/util/comparison.mjs} +0 -0
  223. package/{esm2015/src/util/decorators.js → esm2020/src/util/decorators.mjs} +0 -0
  224. package/{esm2015/src/util/dom.js → esm2020/src/util/dom.mjs} +0 -0
  225. package/{esm2015/src/util/empty.js → esm2020/src/util/empty.mjs} +0 -0
  226. package/{esm2015/src/util/errors.js → esm2020/src/util/errors.mjs} +0 -0
  227. package/{esm2015/src/util/global.js → esm2020/src/util/global.mjs} +0 -0
  228. package/{esm2015/src/util/is_dev_mode.js → esm2020/src/util/is_dev_mode.mjs} +0 -0
  229. package/{esm2015/src/util/iterable.js → esm2020/src/util/iterable.mjs} +0 -0
  230. package/{esm2015/src/util/lang.js → esm2020/src/util/lang.mjs} +0 -0
  231. package/{esm2015/src/util/microtask.js → esm2020/src/util/microtask.mjs} +0 -0
  232. package/{esm2015/src/util/named_array_type.js → esm2020/src/util/named_array_type.mjs} +0 -0
  233. package/{esm2015/src/util/ng_dev_mode.js → esm2020/src/util/ng_dev_mode.mjs} +0 -0
  234. package/{esm2015/src/util/ng_i18n_closure_mode.js → esm2020/src/util/ng_i18n_closure_mode.mjs} +0 -0
  235. package/{esm2015/src/util/ng_jit_mode.js → esm2020/src/util/ng_jit_mode.mjs} +0 -0
  236. package/{esm2015/src/util/ng_reflect.js → esm2020/src/util/ng_reflect.mjs} +0 -0
  237. package/{esm2015/src/util/noop.js → esm2020/src/util/noop.mjs} +0 -0
  238. package/{esm2015/src/util/property.js → esm2020/src/util/property.mjs} +0 -0
  239. package/{esm2015/src/util/raf.js → esm2020/src/util/raf.mjs} +0 -0
  240. package/{esm2015/src/util/security/trusted_type_defs.js → esm2020/src/util/security/trusted_type_defs.mjs} +0 -0
  241. package/esm2020/src/util/security/trusted_types.mjs +130 -0
  242. package/esm2020/src/util/security/trusted_types_bypass.mjs +83 -0
  243. package/{esm2015/src/util/stringify.js → esm2020/src/util/stringify.mjs} +0 -0
  244. package/{esm2015/src/util/symbol.js → esm2020/src/util/symbol.mjs} +0 -0
  245. package/{esm2015/src/version.js → esm2020/src/version.mjs} +1 -1
  246. package/{esm2015/src/view/element.js → esm2020/src/view/element.mjs} +0 -0
  247. package/{esm2015/src/view/entrypoint.js → esm2020/src/view/entrypoint.mjs} +0 -0
  248. package/{esm2015/src/view/errors.js → esm2020/src/view/errors.mjs} +0 -0
  249. package/{esm2015/src/view/index.js → esm2020/src/view/index.mjs} +2 -2
  250. package/{esm2015/src/view/ng_content.js → esm2020/src/view/ng_content.mjs} +0 -0
  251. package/{esm2015/src/view/ng_module.js → esm2020/src/view/ng_module.mjs} +0 -0
  252. package/esm2020/src/view/provider.mjs +490 -0
  253. package/{esm2015/src/view/provider_flags.js → esm2020/src/view/provider_flags.mjs} +0 -0
  254. package/{esm2015/src/view/pure_expression.js → esm2020/src/view/pure_expression.mjs} +0 -0
  255. package/{esm2015/src/view/query.js → esm2020/src/view/query.mjs} +0 -0
  256. package/{esm2015/src/view/refs.js → esm2020/src/view/refs.mjs} +0 -0
  257. package/{esm2015/src/view/services.js → esm2020/src/view/services.mjs} +0 -0
  258. package/{esm2015/src/view/text.js → esm2020/src/view/text.mjs} +0 -0
  259. package/{esm2015/src/view/types.js → esm2020/src/view/types.mjs} +0 -0
  260. package/esm2020/src/view/util.mjs +369 -0
  261. package/{esm2015/src/view/view.js → esm2020/src/view/view.mjs} +0 -0
  262. package/{esm2015/src/view/view_attach.js → esm2020/src/view/view_attach.mjs} +0 -0
  263. package/{esm2015/src/zone/ng_zone.js → esm2020/src/zone/ng_zone.mjs} +0 -0
  264. package/{esm2015/src/zone.js → esm2020/src/zone.mjs} +0 -0
  265. package/{esm2015/testing/index.js → esm2020/testing/index.mjs} +0 -0
  266. package/{esm2015/testing/public_api.js → esm2020/testing/public_api.mjs} +0 -0
  267. package/{esm2015/testing/src/async.js → esm2020/testing/src/async.mjs} +0 -0
  268. package/{esm2015/testing/src/component_fixture.js → esm2020/testing/src/component_fixture.mjs} +0 -0
  269. package/{esm2015/testing/src/fake_async.js → esm2020/testing/src/fake_async.mjs} +0 -0
  270. package/{esm2015/testing/src/lang_utils.js → esm2020/testing/src/lang_utils.mjs} +0 -0
  271. package/esm2020/testing/src/logger.mjs +34 -0
  272. package/{esm2015/testing/src/metadata_override.js → esm2020/testing/src/metadata_override.mjs} +0 -0
  273. package/{esm2015/testing/src/metadata_overrider.js → esm2020/testing/src/metadata_overrider.mjs} +0 -0
  274. package/esm2020/testing/src/ng_zone_mock.mjs +33 -0
  275. package/{esm2015/testing/src/private_export_testing.js → esm2020/testing/src/private_export_testing.mjs} +0 -0
  276. package/esm2020/testing/src/r3_test_bed.mjs +397 -0
  277. package/esm2020/testing/src/r3_test_bed_compiler.mjs +735 -0
  278. package/{esm2015/testing/src/resolvers.js → esm2020/testing/src/resolvers.mjs} +0 -0
  279. package/{esm2015/testing/src/styling.js → esm2020/testing/src/styling.mjs} +0 -0
  280. package/esm2020/testing/src/test_bed.mjs +614 -0
  281. package/esm2020/testing/src/test_bed_common.mjs +28 -0
  282. package/esm2020/testing/src/test_compiler.mjs +69 -0
  283. package/{esm2015/testing/src/test_hooks.js → esm2020/testing/src/test_hooks.mjs} +0 -0
  284. package/{esm2015/testing/src/testing.js → esm2020/testing/src/testing.mjs} +0 -0
  285. package/{esm2015/testing/src/testing_internal.js → esm2020/testing/src/testing_internal.mjs} +0 -0
  286. package/esm2020/testing/testing.mjs +5 -0
  287. package/fesm2015/{core.js → core.mjs} +496 -546
  288. package/fesm2015/core.mjs.map +1 -0
  289. package/fesm2015/{testing.js → testing.mjs} +50 -61
  290. package/fesm2015/testing.mjs.map +1 -0
  291. package/fesm2020/core.mjs +33109 -0
  292. package/fesm2020/core.mjs.map +1 -0
  293. package/fesm2020/testing.mjs +2635 -0
  294. package/fesm2020/testing.mjs.map +1 -0
  295. package/package.json +33 -8
  296. package/schematics/migrations/{move-document → testbed-teardown}/index.d.ts +2 -2
  297. package/schematics/migrations/testbed-teardown/index.js +92 -0
  298. package/schematics/migrations/testbed-teardown/util.d.ts +35 -0
  299. package/schematics/migrations/testbed-teardown/util.js +188 -0
  300. package/schematics/migrations.json +6 -101
  301. package/schematics/package.json +3 -0
  302. package/schematics/utils/import_manager.d.ts +1 -1
  303. package/schematics/utils/import_manager.js +22 -19
  304. package/schematics/utils/load_esm.d.ts +8 -0
  305. package/schematics/utils/load_esm.js +24 -2
  306. package/schematics/utils/ng_component_template.d.ts +1 -1
  307. package/schematics/utils/ng_component_template.js +12 -9
  308. package/schematics/utils/ng_decorators.d.ts +1 -1
  309. package/schematics/utils/ng_decorators.js +1 -1
  310. package/schematics/utils/typescript/class_declaration.d.ts +1 -1
  311. package/schematics/utils/typescript/class_declaration.js +10 -7
  312. package/schematics/utils/typescript/compiler_host.d.ts +1 -1
  313. package/schematics/utils/typescript/compiler_host.js +7 -4
  314. package/schematics/utils/typescript/decorators.d.ts +1 -1
  315. package/schematics/utils/typescript/decorators.js +7 -4
  316. package/schematics/utils/typescript/find_base_classes.d.ts +1 -1
  317. package/schematics/utils/typescript/find_base_classes.js +6 -3
  318. package/schematics/utils/typescript/functions.d.ts +1 -1
  319. package/schematics/utils/typescript/functions.js +9 -6
  320. package/schematics/utils/typescript/imports.d.ts +1 -1
  321. package/schematics/utils/typescript/imports.js +12 -9
  322. package/schematics/utils/typescript/nodes.d.ts +1 -1
  323. package/schematics/utils/typescript/nodes.js +11 -8
  324. package/schematics/utils/typescript/parse_tsconfig.d.ts +1 -1
  325. package/schematics/utils/typescript/parse_tsconfig.js +31 -9
  326. package/schematics/utils/typescript/property_name.d.ts +1 -1
  327. package/schematics/utils/typescript/property_name.js +7 -4
  328. package/schematics/utils/typescript/symbol.d.ts +1 -1
  329. package/schematics/utils/typescript/symbol.js +15 -12
  330. package/testing/package.json +5 -5
  331. package/testing/testing.d.ts +4 -333
  332. package/bundles/core-testing.umd.js +0 -3179
  333. package/bundles/core-testing.umd.js.map +0 -1
  334. package/bundles/core.umd.js +0 -34454
  335. package/bundles/core.umd.js.map +0 -1
  336. package/core.metadata.json +0 -1
  337. package/esm2015/core.externs.js +0 -6
  338. package/esm2015/core.js +0 -38
  339. package/esm2015/index.js +0 -13
  340. package/esm2015/src/application_init.js +0 -142
  341. package/esm2015/src/application_module.js +0 -134
  342. package/esm2015/src/application_ref.js +0 -738
  343. package/esm2015/src/change_detection/change_detection.js +0 -31
  344. package/esm2015/src/change_detection/change_detection_util.js +0 -105
  345. package/esm2015/src/change_detection/change_detector_ref.js +0 -96
  346. package/esm2015/src/change_detection/differs/default_iterable_differ.js +0 -668
  347. package/esm2015/src/change_detection.js +0 -14
  348. package/esm2015/src/codegen_private_exports.js +0 -11
  349. package/esm2015/src/compiler/compiler.externs.js +0 -0
  350. package/esm2015/src/console.js +0 -23
  351. package/esm2015/src/core.js +0 -50
  352. package/esm2015/src/core_private_export.js +0 -35
  353. package/esm2015/src/core_render3_private_export.js +0 -45
  354. package/esm2015/src/debug/debug_node.js +0 -632
  355. package/esm2015/src/di/injectable.js +0 -36
  356. package/esm2015/src/di/injection_token.js +0 -75
  357. package/esm2015/src/di/injector.js +0 -326
  358. package/esm2015/src/di/injector_compatibility.js +0 -187
  359. package/esm2015/src/di/interface/interface.externs.js +0 -0
  360. package/esm2015/src/di/jit/injectable.js +0 -96
  361. package/esm2015/src/di/metadata.js +0 -62
  362. package/esm2015/src/di/metadata_attr.js +0 -24
  363. package/esm2015/src/di/util.js +0 -53
  364. package/esm2015/src/event_emitter.js +0 -54
  365. package/esm2015/src/i18n/locale_en.js +0 -17
  366. package/esm2015/src/interface/interface.externs.js +0 -0
  367. package/esm2015/src/linker/compiler.js +0 -118
  368. package/esm2015/src/linker/element_ref.js +0 -66
  369. package/esm2015/src/linker/ng_module_factory.js +0 -21
  370. package/esm2015/src/linker/ng_module_factory_loader.js +0 -32
  371. package/esm2015/src/linker/view_container_ref.js +0 -290
  372. package/esm2015/src/linker.js +0 -19
  373. package/esm2015/src/metadata/di.js +0 -99
  374. package/esm2015/src/metadata/directives.js +0 -120
  375. package/esm2015/src/metadata/ng_module.js +0 -44
  376. package/esm2015/src/reflection/reflection.externs.js +0 -0
  377. package/esm2015/src/render3/component.js +0 -206
  378. package/esm2015/src/render3/definition.js +0 -299
  379. package/esm2015/src/render3/error_code.js +0 -45
  380. package/esm2015/src/render3/features/ng_onchanges_feature.js +0 -92
  381. package/esm2015/src/render3/fields.js +0 -22
  382. package/esm2015/src/render3/instructions/shared.js +0 -1813
  383. package/esm2015/src/render3/interfaces/renderer.js +0 -29
  384. package/esm2015/src/render3/jit/directive.js +0 -312
  385. package/esm2015/src/render3/jit/environment.js +0 -167
  386. package/esm2015/src/render3/jit/partial.js +0 -105
  387. package/esm2015/src/render3/metadata.js +0 -49
  388. package/esm2015/src/render3/ng_module_ref.js +0 -108
  389. package/esm2015/src/render3/pipe.js +0 -202
  390. package/esm2015/src/render3/util/discovery_utils.js +0 -411
  391. package/esm2015/src/render3/util/global_utils.js +0 -78
  392. package/esm2015/src/render3/util/misc_utils.js +0 -63
  393. package/esm2015/src/testability/testability.js +0 -256
  394. package/esm2015/src/util/security/trusted_types.js +0 -133
  395. package/esm2015/src/util/security/trusted_types_bypass.js +0 -86
  396. package/esm2015/src/util/util.externs.js +0 -0
  397. package/esm2015/src/view/provider.js +0 -490
  398. package/esm2015/src/view/util.js +0 -378
  399. package/esm2015/testing/src/logger.js +0 -32
  400. package/esm2015/testing/src/ng_zone_mock.js +0 -31
  401. package/esm2015/testing/src/r3_test_bed.js +0 -397
  402. package/esm2015/testing/src/r3_test_bed_compiler.js +0 -744
  403. package/esm2015/testing/src/test_bed.js +0 -608
  404. package/esm2015/testing/src/test_bed_common.js +0 -31
  405. package/esm2015/testing/src/test_compiler.js +0 -66
  406. package/esm2015/testing/testing.externs.js +0 -6
  407. package/esm2015/testing/testing.js +0 -7
  408. package/fesm2015/core.js.map +0 -1
  409. package/fesm2015/testing.js.map +0 -1
  410. package/schematics/migrations/abstract-control-parent/index.d.ts +0 -11
  411. package/schematics/migrations/abstract-control-parent/index.js +0 -69
  412. package/schematics/migrations/abstract-control-parent/util.d.ts +0 -14
  413. package/schematics/migrations/abstract-control-parent/util.js +0 -64
  414. package/schematics/migrations/activated-route-snapshot-fragment/index.d.ts +0 -13
  415. package/schematics/migrations/activated-route-snapshot-fragment/index.js +0 -70
  416. package/schematics/migrations/activated-route-snapshot-fragment/util.d.ts +0 -16
  417. package/schematics/migrations/activated-route-snapshot-fragment/util.js +0 -48
  418. package/schematics/migrations/can-activate-with-redirect-to/index.d.ts +0 -11
  419. package/schematics/migrations/can-activate-with-redirect-to/index.js +0 -66
  420. package/schematics/migrations/can-activate-with-redirect-to/util.d.ts +0 -11
  421. package/schematics/migrations/can-activate-with-redirect-to/util.js +0 -70
  422. package/schematics/migrations/deep-shadow-piercing-selector/index.d.ts +0 -10
  423. package/schematics/migrations/deep-shadow-piercing-selector/index.js +0 -49
  424. package/schematics/migrations/dynamic-queries/index.d.ts +0 -13
  425. package/schematics/migrations/dynamic-queries/index.js +0 -73
  426. package/schematics/migrations/dynamic-queries/util.d.ts +0 -25
  427. package/schematics/migrations/dynamic-queries/util.js +0 -81
  428. package/schematics/migrations/initial-navigation/collector.d.ts +0 -22
  429. package/schematics/migrations/initial-navigation/collector.js +0 -119
  430. package/schematics/migrations/initial-navigation/index.d.ts +0 -11
  431. package/schematics/migrations/initial-navigation/index.js +0 -83
  432. package/schematics/migrations/initial-navigation/transform.d.ts +0 -20
  433. package/schematics/migrations/initial-navigation/transform.js +0 -68
  434. package/schematics/migrations/initial-navigation/update_recorder.d.ts +0 -18
  435. package/schematics/migrations/initial-navigation/update_recorder.js +0 -20
  436. package/schematics/migrations/initial-navigation/util.d.ts +0 -12
  437. package/schematics/migrations/initial-navigation/util.js +0 -43
  438. package/schematics/migrations/missing-injectable/definition_collector.d.ts +0 -37
  439. package/schematics/migrations/missing-injectable/definition_collector.js +0 -89
  440. package/schematics/migrations/missing-injectable/index.d.ts +0 -11
  441. package/schematics/migrations/missing-injectable/index.js +0 -122
  442. package/schematics/migrations/missing-injectable/providers_evaluator.d.ts +0 -36
  443. package/schematics/migrations/missing-injectable/providers_evaluator.js +0 -64
  444. package/schematics/migrations/missing-injectable/transform.d.ts +0 -69
  445. package/schematics/migrations/missing-injectable/transform.js +0 -201
  446. package/schematics/migrations/missing-injectable/update_recorder.d.ts +0 -21
  447. package/schematics/migrations/missing-injectable/update_recorder.js +0 -20
  448. package/schematics/migrations/module-with-providers/collector.d.ts +0 -34
  449. package/schematics/migrations/module-with-providers/collector.js +0 -73
  450. package/schematics/migrations/module-with-providers/index.d.ts +0 -13
  451. package/schematics/migrations/module-with-providers/index.js +0 -93
  452. package/schematics/migrations/module-with-providers/transform.d.ts +0 -49
  453. package/schematics/migrations/module-with-providers/transform.js +0 -148
  454. package/schematics/migrations/module-with-providers/util.d.ts +0 -13
  455. package/schematics/migrations/module-with-providers/util.js +0 -40
  456. package/schematics/migrations/move-document/document_import_visitor.d.ts +0 -27
  457. package/schematics/migrations/move-document/document_import_visitor.js +0 -74
  458. package/schematics/migrations/move-document/index.js +0 -93
  459. package/schematics/migrations/move-document/move-import.d.ts +0 -12
  460. package/schematics/migrations/move-document/move-import.js +0 -61
  461. package/schematics/migrations/native-view-encapsulation/index.d.ts +0 -11
  462. package/schematics/migrations/native-view-encapsulation/index.js +0 -63
  463. package/schematics/migrations/native-view-encapsulation/util.d.ts +0 -11
  464. package/schematics/migrations/native-view-encapsulation/util.js +0 -48
  465. package/schematics/migrations/navigation-extras-omissions/index.d.ts +0 -11
  466. package/schematics/migrations/navigation-extras-omissions/index.js +0 -69
  467. package/schematics/migrations/navigation-extras-omissions/util.d.ts +0 -11
  468. package/schematics/migrations/navigation-extras-omissions/util.js +0 -126
  469. package/schematics/migrations/relative-link-resolution/collector.d.ts +0 -22
  470. package/schematics/migrations/relative-link-resolution/collector.js +0 -95
  471. package/schematics/migrations/relative-link-resolution/index.d.ts +0 -11
  472. package/schematics/migrations/relative-link-resolution/index.js +0 -84
  473. package/schematics/migrations/relative-link-resolution/transform.d.ts +0 -22
  474. package/schematics/migrations/relative-link-resolution/transform.js +0 -65
  475. package/schematics/migrations/relative-link-resolution/update_recorder.d.ts +0 -18
  476. package/schematics/migrations/relative-link-resolution/update_recorder.js +0 -20
  477. package/schematics/migrations/relative-link-resolution/util.d.ts +0 -12
  478. package/schematics/migrations/relative-link-resolution/util.js +0 -43
  479. package/schematics/migrations/renderer-to-renderer2/helpers.d.ts +0 -25
  480. package/schematics/migrations/renderer-to-renderer2/helpers.js +0 -238
  481. package/schematics/migrations/renderer-to-renderer2/index.d.ts +0 -14
  482. package/schematics/migrations/renderer-to-renderer2/index.js +0 -135
  483. package/schematics/migrations/renderer-to-renderer2/migration.d.ts +0 -18
  484. package/schematics/migrations/renderer-to-renderer2/migration.js +0 -225
  485. package/schematics/migrations/renderer-to-renderer2/util.d.ts +0 -18
  486. package/schematics/migrations/renderer-to-renderer2/util.js +0 -83
  487. package/schematics/migrations/router-preserve-query-params/index.d.ts +0 -14
  488. package/schematics/migrations/router-preserve-query-params/index.js +0 -72
  489. package/schematics/migrations/router-preserve-query-params/util.d.ts +0 -11
  490. package/schematics/migrations/router-preserve-query-params/util.js +0 -103
  491. package/schematics/migrations/static-queries/angular/directive_inputs.d.ts +0 -11
  492. package/schematics/migrations/static-queries/angular/directive_inputs.js +0 -84
  493. package/schematics/migrations/static-queries/angular/ng_query_visitor.d.ts +0 -45
  494. package/schematics/migrations/static-queries/angular/ng_query_visitor.js +0 -127
  495. package/schematics/migrations/static-queries/angular/query-definition.d.ts +0 -37
  496. package/schematics/migrations/static-queries/angular/query-definition.js +0 -33
  497. package/schematics/migrations/static-queries/angular/super_class.d.ts +0 -15
  498. package/schematics/migrations/static-queries/angular/super_class.js +0 -35
  499. package/schematics/migrations/static-queries/index.d.ts +0 -11
  500. package/schematics/migrations/static-queries/index.js +0 -230
  501. package/schematics/migrations/static-queries/strategies/template_strategy/template_strategy.d.ts +0 -41
  502. package/schematics/migrations/static-queries/strategies/template_strategy/template_strategy.js +0 -214
  503. package/schematics/migrations/static-queries/strategies/test_strategy/test_strategy.d.ts +0 -24
  504. package/schematics/migrations/static-queries/strategies/test_strategy/test_strategy.js +0 -38
  505. package/schematics/migrations/static-queries/strategies/timing-strategy.d.ts +0 -19
  506. package/schematics/migrations/static-queries/strategies/timing-strategy.js +0 -20
  507. package/schematics/migrations/static-queries/strategies/usage_strategy/declaration_usage_visitor.d.ts +0 -82
  508. package/schematics/migrations/static-queries/strategies/usage_strategy/declaration_usage_visitor.js +0 -369
  509. package/schematics/migrations/static-queries/strategies/usage_strategy/super_class_context.d.ts +0 -18
  510. package/schematics/migrations/static-queries/strategies/usage_strategy/super_class_context.js +0 -52
  511. package/schematics/migrations/static-queries/strategies/usage_strategy/template_usage_visitor.d.ts +0 -27
  512. package/schematics/migrations/static-queries/strategies/usage_strategy/template_usage_visitor.js +0 -93
  513. package/schematics/migrations/static-queries/strategies/usage_strategy/usage_strategy.d.ts +0 -34
  514. package/schematics/migrations/static-queries/strategies/usage_strategy/usage_strategy.js +0 -169
  515. package/schematics/migrations/static-queries/transform.d.ts +0 -21
  516. package/schematics/migrations/static-queries/transform.js +0 -102
  517. package/schematics/migrations/template-var-assignment/analyze_template.d.ts +0 -20
  518. package/schematics/migrations/template-var-assignment/analyze_template.js +0 -38
  519. package/schematics/migrations/template-var-assignment/angular/html_variable_assignment_visitor.d.ts +0 -28
  520. package/schematics/migrations/template-var-assignment/angular/html_variable_assignment_visitor.js +0 -80
  521. package/schematics/migrations/template-var-assignment/index.d.ts +0 -11
  522. package/schematics/migrations/template-var-assignment/index.js +0 -101
  523. package/schematics/migrations/undecorated-classes-with-decorated-fields/index.d.ts +0 -14
  524. package/schematics/migrations/undecorated-classes-with-decorated-fields/index.js +0 -114
  525. package/schematics/migrations/undecorated-classes-with-decorated-fields/transform.d.ts +0 -63
  526. package/schematics/migrations/undecorated-classes-with-decorated-fields/transform.js +0 -300
  527. package/schematics/migrations/undecorated-classes-with-decorated-fields/update_recorder.d.ts +0 -19
  528. package/schematics/migrations/undecorated-classes-with-decorated-fields/update_recorder.js +0 -20
  529. package/schematics/migrations/undecorated-classes-with-di/create_ngc_program.d.ts +0 -18
  530. package/schematics/migrations/undecorated-classes-with-di/create_ngc_program.js +0 -57
  531. package/schematics/migrations/undecorated-classes-with-di/decorator_rewrite/convert_directive_metadata.d.ts +0 -18
  532. package/schematics/migrations/undecorated-classes-with-di/decorator_rewrite/convert_directive_metadata.js +0 -96
  533. package/schematics/migrations/undecorated-classes-with-di/decorator_rewrite/decorator_rewriter.d.ts +0 -39
  534. package/schematics/migrations/undecorated-classes-with-di/decorator_rewrite/decorator_rewriter.js +0 -116
  535. package/schematics/migrations/undecorated-classes-with-di/decorator_rewrite/import_rewrite_visitor.d.ts +0 -37
  536. package/schematics/migrations/undecorated-classes-with-di/decorator_rewrite/import_rewrite_visitor.js +0 -126
  537. package/schematics/migrations/undecorated-classes-with-di/decorator_rewrite/path_format.d.ts +0 -10
  538. package/schematics/migrations/undecorated-classes-with-di/decorator_rewrite/path_format.js +0 -31
  539. package/schematics/migrations/undecorated-classes-with-di/decorator_rewrite/source_file_exports.d.ts +0 -16
  540. package/schematics/migrations/undecorated-classes-with-di/decorator_rewrite/source_file_exports.js +0 -65
  541. package/schematics/migrations/undecorated-classes-with-di/index.d.ts +0 -11
  542. package/schematics/migrations/undecorated-classes-with-di/index.js +0 -195
  543. package/schematics/migrations/undecorated-classes-with-di/ng_declaration_collector.d.ts +0 -38
  544. package/schematics/migrations/undecorated-classes-with-di/ng_declaration_collector.js +0 -142
  545. package/schematics/migrations/undecorated-classes-with-di/transform.d.ts +0 -98
  546. package/schematics/migrations/undecorated-classes-with-di/transform.js +0 -371
  547. package/schematics/migrations/undecorated-classes-with-di/update_recorder.d.ts +0 -20
  548. package/schematics/migrations/undecorated-classes-with-di/update_recorder.js +0 -20
  549. package/schematics/migrations/wait-for-async/index.d.ts +0 -11
  550. package/schematics/migrations/wait-for-async/index.js +0 -98
  551. package/schematics/migrations/wait-for-async/util.d.ts +0 -11
  552. package/schematics/migrations/wait-for-async/util.js +0 -37
  553. package/schematics/migrations/xhr-factory/index.d.ts +0 -10
  554. package/schematics/migrations/xhr-factory/index.js +0 -104
  555. package/src/r3_symbols.d.ts +0 -1025
  556. package/testing/testing.metadata.json +0 -1
  557. package/testing.d.ts +0 -7
  558. package/testing.metadata.json +0 -1
@@ -1,3179 +0,0 @@
1
- /**
2
- * @license Angular v13.0.0-next.9
3
- * (c) 2010-2021 Google LLC. https://angular.io/
4
- * License: MIT
5
- */
6
-
7
- (function (global, factory) {
8
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/compiler')) :
9
- typeof define === 'function' && define.amd ? define('@angular/core/testing', ['exports', '@angular/core', '@angular/compiler'], factory) :
10
- (global = global || self, factory((global.ng = global.ng || {}, global.ng.core = global.ng.core || {}, global.ng.core.testing = {}), global.ng.core, global.ng.compiler));
11
- }(this, (function (exports, core, compiler) { 'use strict';
12
-
13
- /**
14
- * @license
15
- * Copyright Google LLC All Rights Reserved.
16
- *
17
- * Use of this source code is governed by an MIT-style license that can be
18
- * found in the LICENSE file at https://angular.io/license
19
- */
20
- /**
21
- * Wraps a test function in an asynchronous test zone. The test will automatically
22
- * complete when all asynchronous calls within this zone are done. Can be used
23
- * to wrap an {@link inject} call.
24
- *
25
- * Example:
26
- *
27
- * ```
28
- * it('...', waitForAsync(inject([AClass], (object) => {
29
- * object.doSomething.then(() => {
30
- * expect(...);
31
- * })
32
- * });
33
- * ```
34
- *
35
- * @publicApi
36
- */
37
- function waitForAsync(fn) {
38
- var _Zone = typeof Zone !== 'undefined' ? Zone : null;
39
- if (!_Zone) {
40
- return function () {
41
- return Promise.reject('Zone is needed for the waitForAsync() test helper but could not be found. ' +
42
- 'Please make sure that your environment includes zone.js');
43
- };
44
- }
45
- var asyncTest = _Zone && _Zone[_Zone.__symbol__('asyncTest')];
46
- if (typeof asyncTest === 'function') {
47
- return asyncTest(fn);
48
- }
49
- return function () {
50
- return Promise.reject('zone-testing.js is needed for the async() test helper but could not be found. ' +
51
- 'Please make sure that your environment includes zone.js/testing');
52
- };
53
- }
54
- /**
55
- * @deprecated use `waitForAsync()`, (expected removal in v12)
56
- * @see {@link waitForAsync}
57
- * @publicApi
58
- * */
59
- function async(fn) {
60
- return waitForAsync(fn);
61
- }
62
-
63
- /**
64
- * @license
65
- * Copyright Google LLC All Rights Reserved.
66
- *
67
- * Use of this source code is governed by an MIT-style license that can be
68
- * found in the LICENSE file at https://angular.io/license
69
- */
70
- /**
71
- * Fixture for debugging and testing a component.
72
- *
73
- * @publicApi
74
- */
75
- var ComponentFixture = /** @class */ (function () {
76
- function ComponentFixture(componentRef, ngZone, _autoDetect) {
77
- var _this = this;
78
- this.componentRef = componentRef;
79
- this.ngZone = ngZone;
80
- this._autoDetect = _autoDetect;
81
- this._isStable = true;
82
- this._isDestroyed = false;
83
- this._resolve = null;
84
- this._promise = null;
85
- this._onUnstableSubscription = null;
86
- this._onStableSubscription = null;
87
- this._onMicrotaskEmptySubscription = null;
88
- this._onErrorSubscription = null;
89
- this.changeDetectorRef = componentRef.changeDetectorRef;
90
- this.elementRef = componentRef.location;
91
- this.debugElement = core.getDebugNode(this.elementRef.nativeElement);
92
- this.componentInstance = componentRef.instance;
93
- this.nativeElement = this.elementRef.nativeElement;
94
- this.componentRef = componentRef;
95
- this.ngZone = ngZone;
96
- if (ngZone) {
97
- // Create subscriptions outside the NgZone so that the callbacks run oustide
98
- // of NgZone.
99
- ngZone.runOutsideAngular(function () {
100
- _this._onUnstableSubscription = ngZone.onUnstable.subscribe({
101
- next: function () {
102
- _this._isStable = false;
103
- }
104
- });
105
- _this._onMicrotaskEmptySubscription = ngZone.onMicrotaskEmpty.subscribe({
106
- next: function () {
107
- if (_this._autoDetect) {
108
- // Do a change detection run with checkNoChanges set to true to check
109
- // there are no changes on the second run.
110
- _this.detectChanges(true);
111
- }
112
- }
113
- });
114
- _this._onStableSubscription = ngZone.onStable.subscribe({
115
- next: function () {
116
- _this._isStable = true;
117
- // Check whether there is a pending whenStable() completer to resolve.
118
- if (_this._promise !== null) {
119
- // If so check whether there are no pending macrotasks before resolving.
120
- // Do this check in the next tick so that ngZone gets a chance to update the state of
121
- // pending macrotasks.
122
- scheduleMicroTask(function () {
123
- if (!ngZone.hasPendingMacrotasks) {
124
- if (_this._promise !== null) {
125
- _this._resolve(true);
126
- _this._resolve = null;
127
- _this._promise = null;
128
- }
129
- }
130
- });
131
- }
132
- }
133
- });
134
- _this._onErrorSubscription = ngZone.onError.subscribe({
135
- next: function (error) {
136
- throw error;
137
- }
138
- });
139
- });
140
- }
141
- }
142
- ComponentFixture.prototype._tick = function (checkNoChanges) {
143
- this.changeDetectorRef.detectChanges();
144
- if (checkNoChanges) {
145
- this.checkNoChanges();
146
- }
147
- };
148
- /**
149
- * Trigger a change detection cycle for the component.
150
- */
151
- ComponentFixture.prototype.detectChanges = function (checkNoChanges) {
152
- var _this = this;
153
- if (checkNoChanges === void 0) { checkNoChanges = true; }
154
- if (this.ngZone != null) {
155
- // Run the change detection inside the NgZone so that any async tasks as part of the change
156
- // detection are captured by the zone and can be waited for in isStable.
157
- this.ngZone.run(function () {
158
- _this._tick(checkNoChanges);
159
- });
160
- }
161
- else {
162
- // Running without zone. Just do the change detection.
163
- this._tick(checkNoChanges);
164
- }
165
- };
166
- /**
167
- * Do a change detection run to make sure there were no changes.
168
- */
169
- ComponentFixture.prototype.checkNoChanges = function () {
170
- this.changeDetectorRef.checkNoChanges();
171
- };
172
- /**
173
- * Set whether the fixture should autodetect changes.
174
- *
175
- * Also runs detectChanges once so that any existing change is detected.
176
- */
177
- ComponentFixture.prototype.autoDetectChanges = function (autoDetect) {
178
- if (autoDetect === void 0) { autoDetect = true; }
179
- if (this.ngZone == null) {
180
- throw new Error('Cannot call autoDetectChanges when ComponentFixtureNoNgZone is set');
181
- }
182
- this._autoDetect = autoDetect;
183
- this.detectChanges();
184
- };
185
- /**
186
- * Return whether the fixture is currently stable or has async tasks that have not been completed
187
- * yet.
188
- */
189
- ComponentFixture.prototype.isStable = function () {
190
- return this._isStable && !this.ngZone.hasPendingMacrotasks;
191
- };
192
- /**
193
- * Get a promise that resolves when the fixture is stable.
194
- *
195
- * This can be used to resume testing after events have triggered asynchronous activity or
196
- * asynchronous change detection.
197
- */
198
- ComponentFixture.prototype.whenStable = function () {
199
- var _this = this;
200
- if (this.isStable()) {
201
- return Promise.resolve(false);
202
- }
203
- else if (this._promise !== null) {
204
- return this._promise;
205
- }
206
- else {
207
- this._promise = new Promise(function (res) {
208
- _this._resolve = res;
209
- });
210
- return this._promise;
211
- }
212
- };
213
- ComponentFixture.prototype._getRenderer = function () {
214
- if (this._renderer === undefined) {
215
- this._renderer = this.componentRef.injector.get(core.RendererFactory2, null);
216
- }
217
- return this._renderer;
218
- };
219
- /**
220
- * Get a promise that resolves when the ui state is stable following animations.
221
- */
222
- ComponentFixture.prototype.whenRenderingDone = function () {
223
- var renderer = this._getRenderer();
224
- if (renderer && renderer.whenRenderingDone) {
225
- return renderer.whenRenderingDone();
226
- }
227
- return this.whenStable();
228
- };
229
- /**
230
- * Trigger component destruction.
231
- */
232
- ComponentFixture.prototype.destroy = function () {
233
- if (!this._isDestroyed) {
234
- this.componentRef.destroy();
235
- if (this._onUnstableSubscription != null) {
236
- this._onUnstableSubscription.unsubscribe();
237
- this._onUnstableSubscription = null;
238
- }
239
- if (this._onStableSubscription != null) {
240
- this._onStableSubscription.unsubscribe();
241
- this._onStableSubscription = null;
242
- }
243
- if (this._onMicrotaskEmptySubscription != null) {
244
- this._onMicrotaskEmptySubscription.unsubscribe();
245
- this._onMicrotaskEmptySubscription = null;
246
- }
247
- if (this._onErrorSubscription != null) {
248
- this._onErrorSubscription.unsubscribe();
249
- this._onErrorSubscription = null;
250
- }
251
- this._isDestroyed = true;
252
- }
253
- };
254
- return ComponentFixture;
255
- }());
256
- function scheduleMicroTask(fn) {
257
- Zone.current.scheduleMicroTask('scheduleMicrotask', fn);
258
- }
259
-
260
- /**
261
- * @license
262
- * Copyright Google LLC All Rights Reserved.
263
- *
264
- * Use of this source code is governed by an MIT-style license that can be
265
- * found in the LICENSE file at https://angular.io/license
266
- */
267
- var _Zone = typeof Zone !== 'undefined' ? Zone : null;
268
- var fakeAsyncTestModule = _Zone && _Zone[_Zone.__symbol__('fakeAsyncTest')];
269
- var fakeAsyncTestModuleNotLoadedErrorMessage = "zone-testing.js is needed for the fakeAsync() test helper but could not be found.\n Please make sure that your environment includes zone.js/testing";
270
- /**
271
- * Clears out the shared fake async zone for a test.
272
- * To be called in a global `beforeEach`.
273
- *
274
- * @publicApi
275
- */
276
- function resetFakeAsyncZone() {
277
- if (fakeAsyncTestModule) {
278
- return fakeAsyncTestModule.resetFakeAsyncZone();
279
- }
280
- throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
281
- }
282
- /**
283
- * Wraps a function to be executed in the `fakeAsync` zone:
284
- * - Microtasks are manually executed by calling `flushMicrotasks()`.
285
- * - Timers are synchronous; `tick()` simulates the asynchronous passage of time.
286
- *
287
- * If there are any pending timers at the end of the function, an exception is thrown.
288
- *
289
- * Can be used to wrap `inject()` calls.
290
- *
291
- * @param fn The function that you want to wrap in the `fakeAysnc` zone.
292
- *
293
- * @usageNotes
294
- * ### Example
295
- *
296
- * {@example core/testing/ts/fake_async.ts region='basic'}
297
- *
298
- *
299
- * @returns The function wrapped to be executed in the `fakeAsync` zone.
300
- * Any arguments passed when calling this returned function will be passed through to the `fn`
301
- * function in the parameters when it is called.
302
- *
303
- * @publicApi
304
- */
305
- function fakeAsync(fn) {
306
- if (fakeAsyncTestModule) {
307
- return fakeAsyncTestModule.fakeAsync(fn);
308
- }
309
- throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
310
- }
311
- /**
312
- * Simulates the asynchronous passage of time for the timers in the `fakeAsync` zone.
313
- *
314
- * The microtasks queue is drained at the very start of this function and after any timer callback
315
- * has been executed.
316
- *
317
- * @param millis The number of milliseconds to advance the virtual timer.
318
- * @param tickOptions The options to pass to the `tick()` function.
319
- *
320
- * @usageNotes
321
- *
322
- * The `tick()` option is a flag called `processNewMacroTasksSynchronously`,
323
- * which determines whether or not to invoke new macroTasks.
324
- *
325
- * If you provide a `tickOptions` object, but do not specify a
326
- * `processNewMacroTasksSynchronously` property (`tick(100, {})`),
327
- * then `processNewMacroTasksSynchronously` defaults to true.
328
- *
329
- * If you omit the `tickOptions` parameter (`tick(100))`), then
330
- * `tickOptions` defaults to `{processNewMacroTasksSynchronously: true}`.
331
- *
332
- * ### Example
333
- *
334
- * {@example core/testing/ts/fake_async.ts region='basic'}
335
- *
336
- * The following example includes a nested timeout (new macroTask), and
337
- * the `tickOptions` parameter is allowed to default. In this case,
338
- * `processNewMacroTasksSynchronously` defaults to true, and the nested
339
- * function is executed on each tick.
340
- *
341
- * ```
342
- * it ('test with nested setTimeout', fakeAsync(() => {
343
- * let nestedTimeoutInvoked = false;
344
- * function funcWithNestedTimeout() {
345
- * setTimeout(() => {
346
- * nestedTimeoutInvoked = true;
347
- * });
348
- * };
349
- * setTimeout(funcWithNestedTimeout);
350
- * tick();
351
- * expect(nestedTimeoutInvoked).toBe(true);
352
- * }));
353
- * ```
354
- *
355
- * In the following case, `processNewMacroTasksSynchronously` is explicitly
356
- * set to false, so the nested timeout function is not invoked.
357
- *
358
- * ```
359
- * it ('test with nested setTimeout', fakeAsync(() => {
360
- * let nestedTimeoutInvoked = false;
361
- * function funcWithNestedTimeout() {
362
- * setTimeout(() => {
363
- * nestedTimeoutInvoked = true;
364
- * });
365
- * };
366
- * setTimeout(funcWithNestedTimeout);
367
- * tick(0, {processNewMacroTasksSynchronously: false});
368
- * expect(nestedTimeoutInvoked).toBe(false);
369
- * }));
370
- * ```
371
- *
372
- *
373
- * @publicApi
374
- */
375
- function tick(millis, tickOptions) {
376
- if (millis === void 0) { millis = 0; }
377
- if (tickOptions === void 0) { tickOptions = {
378
- processNewMacroTasksSynchronously: true
379
- }; }
380
- if (fakeAsyncTestModule) {
381
- return fakeAsyncTestModule.tick(millis, tickOptions);
382
- }
383
- throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
384
- }
385
- /**
386
- * Simulates the asynchronous passage of time for the timers in the `fakeAsync` zone by
387
- * draining the macrotask queue until it is empty.
388
- *
389
- * @param maxTurns The maximum number of times the scheduler attempts to clear its queue before
390
- * throwing an error.
391
- * @returns The simulated time elapsed, in milliseconds.
392
- *
393
- * @publicApi
394
- */
395
- function flush(maxTurns) {
396
- if (fakeAsyncTestModule) {
397
- return fakeAsyncTestModule.flush(maxTurns);
398
- }
399
- throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
400
- }
401
- /**
402
- * Discard all remaining periodic tasks.
403
- *
404
- * @publicApi
405
- */
406
- function discardPeriodicTasks() {
407
- if (fakeAsyncTestModule) {
408
- return fakeAsyncTestModule.discardPeriodicTasks();
409
- }
410
- throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
411
- }
412
- /**
413
- * Flush any pending microtasks.
414
- *
415
- * @publicApi
416
- */
417
- function flushMicrotasks() {
418
- if (fakeAsyncTestModule) {
419
- return fakeAsyncTestModule.flushMicrotasks();
420
- }
421
- throw new Error(fakeAsyncTestModuleNotLoadedErrorMessage);
422
- }
423
-
424
- /*! *****************************************************************************
425
- Copyright (c) Microsoft Corporation.
426
-
427
- Permission to use, copy, modify, and/or distribute this software for any
428
- purpose with or without fee is hereby granted.
429
-
430
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
431
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
432
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
433
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
434
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
435
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
436
- PERFORMANCE OF THIS SOFTWARE.
437
- ***************************************************************************** */
438
- /* global Reflect, Promise */
439
- var extendStatics = function (d, b) {
440
- extendStatics = Object.setPrototypeOf ||
441
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
442
- function (d, b) { for (var p in b)
443
- if (Object.prototype.hasOwnProperty.call(b, p))
444
- d[p] = b[p]; };
445
- return extendStatics(d, b);
446
- };
447
- function __extends(d, b) {
448
- if (typeof b !== "function" && b !== null)
449
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
450
- extendStatics(d, b);
451
- function __() { this.constructor = d; }
452
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
453
- }
454
- var __assign = function () {
455
- __assign = Object.assign || function __assign(t) {
456
- for (var s, i = 1, n = arguments.length; i < n; i++) {
457
- s = arguments[i];
458
- for (var p in s)
459
- if (Object.prototype.hasOwnProperty.call(s, p))
460
- t[p] = s[p];
461
- }
462
- return t;
463
- };
464
- return __assign.apply(this, arguments);
465
- };
466
- function __rest(s, e) {
467
- var t = {};
468
- for (var p in s)
469
- if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
470
- t[p] = s[p];
471
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
472
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
473
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
474
- t[p[i]] = s[p[i]];
475
- }
476
- return t;
477
- }
478
- function __decorate(decorators, target, key, desc) {
479
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
480
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
481
- r = Reflect.decorate(decorators, target, key, desc);
482
- else
483
- for (var i = decorators.length - 1; i >= 0; i--)
484
- if (d = decorators[i])
485
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
486
- return c > 3 && r && Object.defineProperty(target, key, r), r;
487
- }
488
- function __param(paramIndex, decorator) {
489
- return function (target, key) { decorator(target, key, paramIndex); };
490
- }
491
- function __metadata(metadataKey, metadataValue) {
492
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
493
- return Reflect.metadata(metadataKey, metadataValue);
494
- }
495
- function __awaiter(thisArg, _arguments, P, generator) {
496
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
497
- return new (P || (P = Promise))(function (resolve, reject) {
498
- function fulfilled(value) { try {
499
- step(generator.next(value));
500
- }
501
- catch (e) {
502
- reject(e);
503
- } }
504
- function rejected(value) { try {
505
- step(generator["throw"](value));
506
- }
507
- catch (e) {
508
- reject(e);
509
- } }
510
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
511
- step((generator = generator.apply(thisArg, _arguments || [])).next());
512
- });
513
- }
514
- function __generator(thisArg, body) {
515
- var _ = { label: 0, sent: function () { if (t[0] & 1)
516
- throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
517
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
518
- function verb(n) { return function (v) { return step([n, v]); }; }
519
- function step(op) {
520
- if (f)
521
- throw new TypeError("Generator is already executing.");
522
- while (_)
523
- try {
524
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
525
- return t;
526
- if (y = 0, t)
527
- op = [op[0] & 2, t.value];
528
- switch (op[0]) {
529
- case 0:
530
- case 1:
531
- t = op;
532
- break;
533
- case 4:
534
- _.label++;
535
- return { value: op[1], done: false };
536
- case 5:
537
- _.label++;
538
- y = op[1];
539
- op = [0];
540
- continue;
541
- case 7:
542
- op = _.ops.pop();
543
- _.trys.pop();
544
- continue;
545
- default:
546
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
547
- _ = 0;
548
- continue;
549
- }
550
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
551
- _.label = op[1];
552
- break;
553
- }
554
- if (op[0] === 6 && _.label < t[1]) {
555
- _.label = t[1];
556
- t = op;
557
- break;
558
- }
559
- if (t && _.label < t[2]) {
560
- _.label = t[2];
561
- _.ops.push(op);
562
- break;
563
- }
564
- if (t[2])
565
- _.ops.pop();
566
- _.trys.pop();
567
- continue;
568
- }
569
- op = body.call(thisArg, _);
570
- }
571
- catch (e) {
572
- op = [6, e];
573
- y = 0;
574
- }
575
- finally {
576
- f = t = 0;
577
- }
578
- if (op[0] & 5)
579
- throw op[1];
580
- return { value: op[0] ? op[1] : void 0, done: true };
581
- }
582
- }
583
- var __createBinding = Object.create ? (function (o, m, k, k2) {
584
- if (k2 === undefined)
585
- k2 = k;
586
- Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
587
- }) : (function (o, m, k, k2) {
588
- if (k2 === undefined)
589
- k2 = k;
590
- o[k2] = m[k];
591
- });
592
- function __exportStar(m, o) {
593
- for (var p in m)
594
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
595
- __createBinding(o, m, p);
596
- }
597
- function __values(o) {
598
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
599
- if (m)
600
- return m.call(o);
601
- if (o && typeof o.length === "number")
602
- return {
603
- next: function () {
604
- if (o && i >= o.length)
605
- o = void 0;
606
- return { value: o && o[i++], done: !o };
607
- }
608
- };
609
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
610
- }
611
- function __read(o, n) {
612
- var m = typeof Symbol === "function" && o[Symbol.iterator];
613
- if (!m)
614
- return o;
615
- var i = m.call(o), r, ar = [], e;
616
- try {
617
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
618
- ar.push(r.value);
619
- }
620
- catch (error) {
621
- e = { error: error };
622
- }
623
- finally {
624
- try {
625
- if (r && !r.done && (m = i["return"]))
626
- m.call(i);
627
- }
628
- finally {
629
- if (e)
630
- throw e.error;
631
- }
632
- }
633
- return ar;
634
- }
635
- /** @deprecated */
636
- function __spread() {
637
- for (var ar = [], i = 0; i < arguments.length; i++)
638
- ar = ar.concat(__read(arguments[i]));
639
- return ar;
640
- }
641
- /** @deprecated */
642
- function __spreadArrays() {
643
- for (var s = 0, i = 0, il = arguments.length; i < il; i++)
644
- s += arguments[i].length;
645
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
646
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
647
- r[k] = a[j];
648
- return r;
649
- }
650
- function __spreadArray(to, from, pack) {
651
- if (pack || arguments.length === 2)
652
- for (var i = 0, l = from.length, ar; i < l; i++) {
653
- if (ar || !(i in from)) {
654
- if (!ar)
655
- ar = Array.prototype.slice.call(from, 0, i);
656
- ar[i] = from[i];
657
- }
658
- }
659
- return to.concat(ar || Array.prototype.slice.call(from));
660
- }
661
- function __await(v) {
662
- return this instanceof __await ? (this.v = v, this) : new __await(v);
663
- }
664
- function __asyncGenerator(thisArg, _arguments, generator) {
665
- if (!Symbol.asyncIterator)
666
- throw new TypeError("Symbol.asyncIterator is not defined.");
667
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
668
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
669
- function verb(n) { if (g[n])
670
- i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
671
- function resume(n, v) { try {
672
- step(g[n](v));
673
- }
674
- catch (e) {
675
- settle(q[0][3], e);
676
- } }
677
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
678
- function fulfill(value) { resume("next", value); }
679
- function reject(value) { resume("throw", value); }
680
- function settle(f, v) { if (f(v), q.shift(), q.length)
681
- resume(q[0][0], q[0][1]); }
682
- }
683
- function __asyncDelegator(o) {
684
- var i, p;
685
- return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
686
- function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
687
- }
688
- function __asyncValues(o) {
689
- if (!Symbol.asyncIterator)
690
- throw new TypeError("Symbol.asyncIterator is not defined.");
691
- var m = o[Symbol.asyncIterator], i;
692
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
693
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
694
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
695
- }
696
- function __makeTemplateObject(cooked, raw) {
697
- if (Object.defineProperty) {
698
- Object.defineProperty(cooked, "raw", { value: raw });
699
- }
700
- else {
701
- cooked.raw = raw;
702
- }
703
- return cooked;
704
- }
705
- ;
706
- var __setModuleDefault = Object.create ? (function (o, v) {
707
- Object.defineProperty(o, "default", { enumerable: true, value: v });
708
- }) : function (o, v) {
709
- o["default"] = v;
710
- };
711
- function __importStar(mod) {
712
- if (mod && mod.__esModule)
713
- return mod;
714
- var result = {};
715
- if (mod != null)
716
- for (var k in mod)
717
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
718
- __createBinding(result, mod, k);
719
- __setModuleDefault(result, mod);
720
- return result;
721
- }
722
- function __importDefault(mod) {
723
- return (mod && mod.__esModule) ? mod : { default: mod };
724
- }
725
- function __classPrivateFieldGet(receiver, state, kind, f) {
726
- if (kind === "a" && !f)
727
- throw new TypeError("Private accessor was defined without a getter");
728
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
729
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
730
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
731
- }
732
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
733
- if (kind === "m")
734
- throw new TypeError("Private method is not writable");
735
- if (kind === "a" && !f)
736
- throw new TypeError("Private accessor was defined without a setter");
737
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
738
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
739
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
740
- }
741
-
742
- /**
743
- * @license
744
- * Copyright Google LLC All Rights Reserved.
745
- *
746
- * Use of this source code is governed by an MIT-style license that can be
747
- * found in the LICENSE file at https://angular.io/license
748
- */
749
- /**
750
- * Used to resolve resource URLs on `@Component` when used with JIT compilation.
751
- *
752
- * Example:
753
- * ```
754
- * @Component({
755
- * selector: 'my-comp',
756
- * templateUrl: 'my-comp.html', // This requires asynchronous resolution
757
- * })
758
- * class MyComponent{
759
- * }
760
- *
761
- * // Calling `renderComponent` will fail because `renderComponent` is a synchronous process
762
- * // and `MyComponent`'s `@Component.templateUrl` needs to be resolved asynchronously.
763
- *
764
- * // Calling `resolveComponentResources()` will resolve `@Component.templateUrl` into
765
- * // `@Component.template`, which allows `renderComponent` to proceed in a synchronous manner.
766
- *
767
- * // Use browser's `fetch()` function as the default resource resolution strategy.
768
- * resolveComponentResources(fetch).then(() => {
769
- * // After resolution all URLs have been converted into `template` strings.
770
- * renderComponent(MyComponent);
771
- * });
772
- *
773
- * ```
774
- *
775
- * NOTE: In AOT the resolution happens during compilation, and so there should be no need
776
- * to call this method outside JIT mode.
777
- *
778
- * @param resourceResolver a function which is responsible for returning a `Promise` to the
779
- * contents of the resolved URL. Browser's `fetch()` method is a good default implementation.
780
- */
781
- function resolveComponentResources(resourceResolver) {
782
- // Store all promises which are fetching the resources.
783
- var componentResolved = [];
784
- // Cache so that we don't fetch the same resource more than once.
785
- var urlMap = new Map();
786
- function cachedResourceResolve(url) {
787
- var promise = urlMap.get(url);
788
- if (!promise) {
789
- var resp = resourceResolver(url);
790
- urlMap.set(url, promise = resp.then(unwrapResponse));
791
- }
792
- return promise;
793
- }
794
- componentResourceResolutionQueue.forEach(function (component, type) {
795
- var promises = [];
796
- if (component.templateUrl) {
797
- promises.push(cachedResourceResolve(component.templateUrl).then(function (template) {
798
- component.template = template;
799
- }));
800
- }
801
- var styleUrls = component.styleUrls;
802
- var styles = component.styles || (component.styles = []);
803
- var styleOffset = component.styles.length;
804
- styleUrls && styleUrls.forEach(function (styleUrl, index) {
805
- styles.push(''); // pre-allocate array.
806
- promises.push(cachedResourceResolve(styleUrl).then(function (style) {
807
- styles[styleOffset + index] = style;
808
- styleUrls.splice(styleUrls.indexOf(styleUrl), 1);
809
- if (styleUrls.length == 0) {
810
- component.styleUrls = undefined;
811
- }
812
- }));
813
- });
814
- var fullyResolved = Promise.all(promises).then(function () { return componentDefResolved(type); });
815
- componentResolved.push(fullyResolved);
816
- });
817
- clearResolutionOfComponentResourcesQueue();
818
- return Promise.all(componentResolved).then(function () { return undefined; });
819
- }
820
- var componentResourceResolutionQueue = new Map();
821
- // Track when existing ɵcmp for a Type is waiting on resources.
822
- var componentDefPendingResolution = new Set();
823
- function maybeQueueResolutionOfComponentResources(type, metadata) {
824
- if (componentNeedsResolution(metadata)) {
825
- componentResourceResolutionQueue.set(type, metadata);
826
- componentDefPendingResolution.add(type);
827
- }
828
- }
829
- function isComponentDefPendingResolution(type) {
830
- return componentDefPendingResolution.has(type);
831
- }
832
- function componentNeedsResolution(component) {
833
- return !!((component.templateUrl && !component.hasOwnProperty('template')) ||
834
- component.styleUrls && component.styleUrls.length);
835
- }
836
- function clearResolutionOfComponentResourcesQueue() {
837
- var old = componentResourceResolutionQueue;
838
- componentResourceResolutionQueue = new Map();
839
- return old;
840
- }
841
- function restoreComponentResolutionQueue(queue) {
842
- componentDefPendingResolution.clear();
843
- queue.forEach(function (_, type) { return componentDefPendingResolution.add(type); });
844
- componentResourceResolutionQueue = queue;
845
- }
846
- function isComponentResourceResolutionQueueEmpty() {
847
- return componentResourceResolutionQueue.size === 0;
848
- }
849
- function unwrapResponse(response) {
850
- return typeof response == 'string' ? response : response.text();
851
- }
852
- function componentDefResolved(type) {
853
- componentDefPendingResolution.delete(type);
854
- }
855
-
856
- /**
857
- * @license
858
- * Copyright Google LLC All Rights Reserved.
859
- *
860
- * Use of this source code is governed by an MIT-style license that can be
861
- * found in the LICENSE file at https://angular.io/license
862
- */
863
- var _nextReferenceId = 0;
864
- var MetadataOverrider = /** @class */ (function () {
865
- function MetadataOverrider() {
866
- this._references = new Map();
867
- }
868
- /**
869
- * Creates a new instance for the given metadata class
870
- * based on an old instance and overrides.
871
- */
872
- MetadataOverrider.prototype.overrideMetadata = function (metadataClass, oldMetadata, override) {
873
- var props = {};
874
- if (oldMetadata) {
875
- _valueProps(oldMetadata).forEach(function (prop) { return props[prop] = oldMetadata[prop]; });
876
- }
877
- if (override.set) {
878
- if (override.remove || override.add) {
879
- throw new Error("Cannot set and add/remove " + core.ɵstringify(metadataClass) + " at the same time!");
880
- }
881
- setMetadata(props, override.set);
882
- }
883
- if (override.remove) {
884
- removeMetadata(props, override.remove, this._references);
885
- }
886
- if (override.add) {
887
- addMetadata(props, override.add);
888
- }
889
- return new metadataClass(props);
890
- };
891
- return MetadataOverrider;
892
- }());
893
- function removeMetadata(metadata, remove, references) {
894
- var removeObjects = new Set();
895
- var _loop_1 = function (prop) {
896
- var removeValue = remove[prop];
897
- if (Array.isArray(removeValue)) {
898
- removeValue.forEach(function (value) {
899
- removeObjects.add(_propHashKey(prop, value, references));
900
- });
901
- }
902
- else {
903
- removeObjects.add(_propHashKey(prop, removeValue, references));
904
- }
905
- };
906
- for (var prop in remove) {
907
- _loop_1(prop);
908
- }
909
- var _loop_2 = function (prop) {
910
- var propValue = metadata[prop];
911
- if (Array.isArray(propValue)) {
912
- metadata[prop] = propValue.filter(function (value) { return !removeObjects.has(_propHashKey(prop, value, references)); });
913
- }
914
- else {
915
- if (removeObjects.has(_propHashKey(prop, propValue, references))) {
916
- metadata[prop] = undefined;
917
- }
918
- }
919
- };
920
- for (var prop in metadata) {
921
- _loop_2(prop);
922
- }
923
- }
924
- function addMetadata(metadata, add) {
925
- for (var prop in add) {
926
- var addValue = add[prop];
927
- var propValue = metadata[prop];
928
- if (propValue != null && Array.isArray(propValue)) {
929
- metadata[prop] = propValue.concat(addValue);
930
- }
931
- else {
932
- metadata[prop] = addValue;
933
- }
934
- }
935
- }
936
- function setMetadata(metadata, set) {
937
- for (var prop in set) {
938
- metadata[prop] = set[prop];
939
- }
940
- }
941
- function _propHashKey(propName, propValue, references) {
942
- var replacer = function (key, value) {
943
- if (typeof value === 'function') {
944
- value = _serializeReference(value, references);
945
- }
946
- return value;
947
- };
948
- return propName + ":" + JSON.stringify(propValue, replacer);
949
- }
950
- function _serializeReference(ref, references) {
951
- var id = references.get(ref);
952
- if (!id) {
953
- id = "" + core.ɵstringify(ref) + _nextReferenceId++;
954
- references.set(ref, id);
955
- }
956
- return id;
957
- }
958
- function _valueProps(obj) {
959
- var props = [];
960
- // regular public props
961
- Object.keys(obj).forEach(function (prop) {
962
- if (!prop.startsWith('_')) {
963
- props.push(prop);
964
- }
965
- });
966
- // getters
967
- var proto = obj;
968
- while (proto = Object.getPrototypeOf(proto)) {
969
- Object.keys(proto).forEach(function (protoProp) {
970
- var desc = Object.getOwnPropertyDescriptor(proto, protoProp);
971
- if (!protoProp.startsWith('_') && desc && 'get' in desc) {
972
- props.push(protoProp);
973
- }
974
- });
975
- }
976
- return props;
977
- }
978
-
979
- var reflection = new core.ɵReflectionCapabilities();
980
- /**
981
- * Allows to override ivy metadata for tests (via the `TestBed`).
982
- */
983
- var OverrideResolver = /** @class */ (function () {
984
- function OverrideResolver() {
985
- this.overrides = new Map();
986
- this.resolved = new Map();
987
- }
988
- OverrideResolver.prototype.addOverride = function (type, override) {
989
- var overrides = this.overrides.get(type) || [];
990
- overrides.push(override);
991
- this.overrides.set(type, overrides);
992
- this.resolved.delete(type);
993
- };
994
- OverrideResolver.prototype.setOverrides = function (overrides) {
995
- var _this = this;
996
- this.overrides.clear();
997
- overrides.forEach(function (_a) {
998
- var _b = __read(_a, 2), type = _b[0], override = _b[1];
999
- _this.addOverride(type, override);
1000
- });
1001
- };
1002
- OverrideResolver.prototype.getAnnotation = function (type) {
1003
- var annotations = reflection.annotations(type);
1004
- // Try to find the nearest known Type annotation and make sure that this annotation is an
1005
- // instance of the type we are looking for, so we can use it for resolution. Note: there might
1006
- // be multiple known annotations found due to the fact that Components can extend Directives (so
1007
- // both Directive and Component annotations would be present), so we always check if the known
1008
- // annotation has the right type.
1009
- for (var i = annotations.length - 1; i >= 0; i--) {
1010
- var annotation = annotations[i];
1011
- var isKnownType = annotation instanceof core.Directive || annotation instanceof core.Component ||
1012
- annotation instanceof core.Pipe || annotation instanceof core.NgModule;
1013
- if (isKnownType) {
1014
- return annotation instanceof this.type ? annotation : null;
1015
- }
1016
- }
1017
- return null;
1018
- };
1019
- OverrideResolver.prototype.resolve = function (type) {
1020
- var _this = this;
1021
- var resolved = this.resolved.get(type) || null;
1022
- if (!resolved) {
1023
- resolved = this.getAnnotation(type);
1024
- if (resolved) {
1025
- var overrides = this.overrides.get(type);
1026
- if (overrides) {
1027
- var overrider_1 = new MetadataOverrider();
1028
- overrides.forEach(function (override) {
1029
- resolved = overrider_1.overrideMetadata(_this.type, resolved, override);
1030
- });
1031
- }
1032
- }
1033
- this.resolved.set(type, resolved);
1034
- }
1035
- return resolved;
1036
- };
1037
- return OverrideResolver;
1038
- }());
1039
- var DirectiveResolver = /** @class */ (function (_super) {
1040
- __extends(DirectiveResolver, _super);
1041
- function DirectiveResolver() {
1042
- return _super !== null && _super.apply(this, arguments) || this;
1043
- }
1044
- Object.defineProperty(DirectiveResolver.prototype, "type", {
1045
- get: function () {
1046
- return core.Directive;
1047
- },
1048
- enumerable: false,
1049
- configurable: true
1050
- });
1051
- return DirectiveResolver;
1052
- }(OverrideResolver));
1053
- var ComponentResolver = /** @class */ (function (_super) {
1054
- __extends(ComponentResolver, _super);
1055
- function ComponentResolver() {
1056
- return _super !== null && _super.apply(this, arguments) || this;
1057
- }
1058
- Object.defineProperty(ComponentResolver.prototype, "type", {
1059
- get: function () {
1060
- return core.Component;
1061
- },
1062
- enumerable: false,
1063
- configurable: true
1064
- });
1065
- return ComponentResolver;
1066
- }(OverrideResolver));
1067
- var PipeResolver = /** @class */ (function (_super) {
1068
- __extends(PipeResolver, _super);
1069
- function PipeResolver() {
1070
- return _super !== null && _super.apply(this, arguments) || this;
1071
- }
1072
- Object.defineProperty(PipeResolver.prototype, "type", {
1073
- get: function () {
1074
- return core.Pipe;
1075
- },
1076
- enumerable: false,
1077
- configurable: true
1078
- });
1079
- return PipeResolver;
1080
- }(OverrideResolver));
1081
- var NgModuleResolver = /** @class */ (function (_super) {
1082
- __extends(NgModuleResolver, _super);
1083
- function NgModuleResolver() {
1084
- return _super !== null && _super.apply(this, arguments) || this;
1085
- }
1086
- Object.defineProperty(NgModuleResolver.prototype, "type", {
1087
- get: function () {
1088
- return core.NgModule;
1089
- },
1090
- enumerable: false,
1091
- configurable: true
1092
- });
1093
- return NgModuleResolver;
1094
- }(OverrideResolver));
1095
-
1096
- var TestingModuleOverride;
1097
- (function (TestingModuleOverride) {
1098
- TestingModuleOverride[TestingModuleOverride["DECLARATION"] = 0] = "DECLARATION";
1099
- TestingModuleOverride[TestingModuleOverride["OVERRIDE_TEMPLATE"] = 1] = "OVERRIDE_TEMPLATE";
1100
- })(TestingModuleOverride || (TestingModuleOverride = {}));
1101
- function isTestingModuleOverride(value) {
1102
- return value === TestingModuleOverride.DECLARATION ||
1103
- value === TestingModuleOverride.OVERRIDE_TEMPLATE;
1104
- }
1105
- var R3TestBedCompiler = /** @class */ (function () {
1106
- function R3TestBedCompiler(platform, additionalModuleTypes) {
1107
- this.platform = platform;
1108
- this.additionalModuleTypes = additionalModuleTypes;
1109
- this.originalComponentResolutionQueue = null;
1110
- // Testing module configuration
1111
- this.declarations = [];
1112
- this.imports = [];
1113
- this.providers = [];
1114
- this.schemas = [];
1115
- // Queues of components/directives/pipes that should be recompiled.
1116
- this.pendingComponents = new Set();
1117
- this.pendingDirectives = new Set();
1118
- this.pendingPipes = new Set();
1119
- // Keep track of all components and directives, so we can patch Providers onto defs later.
1120
- this.seenComponents = new Set();
1121
- this.seenDirectives = new Set();
1122
- // Keep track of overridden modules, so that we can collect all affected ones in the module tree.
1123
- this.overriddenModules = new Set();
1124
- // Store resolved styles for Components that have template overrides present and `styleUrls`
1125
- // defined at the same time.
1126
- this.existingComponentStyles = new Map();
1127
- this.resolvers = initResolvers();
1128
- this.componentToModuleScope = new Map();
1129
- // Map that keeps initial version of component/directive/pipe defs in case
1130
- // we compile a Type again, thus overriding respective static fields. This is
1131
- // required to make sure we restore defs to their initial states between test runs
1132
- // TODO: we should support the case with multiple defs on a type
1133
- this.initialNgDefs = new Map();
1134
- // Array that keeps cleanup operations for initial versions of component/directive/pipe/module
1135
- // defs in case TestBed makes changes to the originals.
1136
- this.defCleanupOps = [];
1137
- this._injector = null;
1138
- this.compilerProviders = null;
1139
- this.providerOverrides = [];
1140
- this.rootProviderOverrides = [];
1141
- // Overrides for injectables with `{providedIn: SomeModule}` need to be tracked and added to that
1142
- // module's provider list.
1143
- this.providerOverridesByModule = new Map();
1144
- this.providerOverridesByToken = new Map();
1145
- this.moduleProvidersOverridden = new Set();
1146
- this.testModuleRef = null;
1147
- var DynamicTestModule = /** @class */ (function () {
1148
- function DynamicTestModule() {
1149
- }
1150
- return DynamicTestModule;
1151
- }());
1152
- this.testModuleType = DynamicTestModule;
1153
- }
1154
- R3TestBedCompiler.prototype.setCompilerProviders = function (providers) {
1155
- this.compilerProviders = providers;
1156
- this._injector = null;
1157
- };
1158
- R3TestBedCompiler.prototype.configureTestingModule = function (moduleDef) {
1159
- var _a, _b, _c, _d;
1160
- // Enqueue any compilation tasks for the directly declared component.
1161
- if (moduleDef.declarations !== undefined) {
1162
- this.queueTypeArray(moduleDef.declarations, TestingModuleOverride.DECLARATION);
1163
- (_a = this.declarations).push.apply(_a, __spreadArray([], __read(moduleDef.declarations), false));
1164
- }
1165
- // Enqueue any compilation tasks for imported modules.
1166
- if (moduleDef.imports !== undefined) {
1167
- this.queueTypesFromModulesArray(moduleDef.imports);
1168
- (_b = this.imports).push.apply(_b, __spreadArray([], __read(moduleDef.imports), false));
1169
- }
1170
- if (moduleDef.providers !== undefined) {
1171
- (_c = this.providers).push.apply(_c, __spreadArray([], __read(moduleDef.providers), false));
1172
- }
1173
- if (moduleDef.schemas !== undefined) {
1174
- (_d = this.schemas).push.apply(_d, __spreadArray([], __read(moduleDef.schemas), false));
1175
- }
1176
- };
1177
- R3TestBedCompiler.prototype.overrideModule = function (ngModule, override) {
1178
- this.overriddenModules.add(ngModule);
1179
- // Compile the module right away.
1180
- this.resolvers.module.addOverride(ngModule, override);
1181
- var metadata = this.resolvers.module.resolve(ngModule);
1182
- if (metadata === null) {
1183
- throw invalidTypeError(ngModule.name, 'NgModule');
1184
- }
1185
- this.recompileNgModule(ngModule, metadata);
1186
- // At this point, the module has a valid module def (ɵmod), but the override may have introduced
1187
- // new declarations or imported modules. Ingest any possible new types and add them to the
1188
- // current queue.
1189
- this.queueTypesFromModulesArray([ngModule]);
1190
- };
1191
- R3TestBedCompiler.prototype.overrideComponent = function (component, override) {
1192
- this.resolvers.component.addOverride(component, override);
1193
- this.pendingComponents.add(component);
1194
- };
1195
- R3TestBedCompiler.prototype.overrideDirective = function (directive, override) {
1196
- this.resolvers.directive.addOverride(directive, override);
1197
- this.pendingDirectives.add(directive);
1198
- };
1199
- R3TestBedCompiler.prototype.overridePipe = function (pipe, override) {
1200
- this.resolvers.pipe.addOverride(pipe, override);
1201
- this.pendingPipes.add(pipe);
1202
- };
1203
- R3TestBedCompiler.prototype.overrideProvider = function (token, provider) {
1204
- var providerDef;
1205
- if (provider.useFactory !== undefined) {
1206
- providerDef = {
1207
- provide: token,
1208
- useFactory: provider.useFactory,
1209
- deps: provider.deps || [],
1210
- multi: provider.multi
1211
- };
1212
- }
1213
- else if (provider.useValue !== undefined) {
1214
- providerDef = { provide: token, useValue: provider.useValue, multi: provider.multi };
1215
- }
1216
- else {
1217
- providerDef = { provide: token };
1218
- }
1219
- var injectableDef = typeof token !== 'string' ? core.ɵgetInjectableDef(token) : null;
1220
- var providedIn = injectableDef === null ? null : core.resolveForwardRef(injectableDef.providedIn);
1221
- var overridesBucket = providedIn === 'root' ? this.rootProviderOverrides : this.providerOverrides;
1222
- overridesBucket.push(providerDef);
1223
- // Keep overrides grouped by token as well for fast lookups using token
1224
- this.providerOverridesByToken.set(token, providerDef);
1225
- if (injectableDef !== null && providedIn !== null && typeof providedIn !== 'string') {
1226
- var existingOverrides = this.providerOverridesByModule.get(providedIn);
1227
- if (existingOverrides !== undefined) {
1228
- existingOverrides.push(providerDef);
1229
- }
1230
- else {
1231
- this.providerOverridesByModule.set(providedIn, [providerDef]);
1232
- }
1233
- }
1234
- };
1235
- R3TestBedCompiler.prototype.overrideTemplateUsingTestingModule = function (type, template) {
1236
- var _this = this;
1237
- var def = type[core.ɵNG_COMP_DEF];
1238
- var hasStyleUrls = function () {
1239
- var metadata = _this.resolvers.component.resolve(type);
1240
- return !!metadata.styleUrls && metadata.styleUrls.length > 0;
1241
- };
1242
- var overrideStyleUrls = !!def && !isComponentDefPendingResolution(type) && hasStyleUrls();
1243
- // In Ivy, compiling a component does not require knowing the module providing the
1244
- // component's scope, so overrideTemplateUsingTestingModule can be implemented purely via
1245
- // overrideComponent. Important: overriding template requires full Component re-compilation,
1246
- // which may fail in case styleUrls are also present (thus Component is considered as required
1247
- // resolution). In order to avoid this, we preemptively set styleUrls to an empty array,
1248
- // preserve current styles available on Component def and restore styles back once compilation
1249
- // is complete.
1250
- var override = overrideStyleUrls ? { template: template, styles: [], styleUrls: [] } : { template: template };
1251
- this.overrideComponent(type, { set: override });
1252
- if (overrideStyleUrls && def.styles && def.styles.length > 0) {
1253
- this.existingComponentStyles.set(type, def.styles);
1254
- }
1255
- // Set the component's scope to be the testing module.
1256
- this.componentToModuleScope.set(type, TestingModuleOverride.OVERRIDE_TEMPLATE);
1257
- };
1258
- R3TestBedCompiler.prototype.compileComponents = function () {
1259
- return __awaiter(this, void 0, void 0, function () {
1260
- var needsAsyncResources, resourceLoader_1, resolver;
1261
- var _this = this;
1262
- return __generator(this, function (_a) {
1263
- switch (_a.label) {
1264
- case 0:
1265
- this.clearComponentResolutionQueue();
1266
- needsAsyncResources = this.compileTypesSync();
1267
- if (!needsAsyncResources) return [3 /*break*/, 2];
1268
- resolver = function (url) {
1269
- if (!resourceLoader_1) {
1270
- resourceLoader_1 = _this.injector.get(compiler.ResourceLoader);
1271
- }
1272
- return Promise.resolve(resourceLoader_1.get(url));
1273
- };
1274
- return [4 /*yield*/, resolveComponentResources(resolver)];
1275
- case 1:
1276
- _a.sent();
1277
- _a.label = 2;
1278
- case 2: return [2 /*return*/];
1279
- }
1280
- });
1281
- });
1282
- };
1283
- R3TestBedCompiler.prototype.finalize = function () {
1284
- // One last compile
1285
- this.compileTypesSync();
1286
- // Create the testing module itself.
1287
- this.compileTestModule();
1288
- this.applyTransitiveScopes();
1289
- this.applyProviderOverrides();
1290
- // Patch previously stored `styles` Component values (taken from ɵcmp), in case these
1291
- // Components have `styleUrls` fields defined and template override was requested.
1292
- this.patchComponentsWithExistingStyles();
1293
- // Clear the componentToModuleScope map, so that future compilations don't reset the scope of
1294
- // every component.
1295
- this.componentToModuleScope.clear();
1296
- var parentInjector = this.platform.injector;
1297
- this.testModuleRef = new core.ɵRender3NgModuleRef(this.testModuleType, parentInjector);
1298
- // ApplicationInitStatus.runInitializers() is marked @internal to core.
1299
- // Cast it to any before accessing it.
1300
- this.testModuleRef.injector.get(core.ApplicationInitStatus).runInitializers();
1301
- // Set locale ID after running app initializers, since locale information might be updated while
1302
- // running initializers. This is also consistent with the execution order while bootstrapping an
1303
- // app (see `packages/core/src/application_ref.ts` file).
1304
- var localeId = this.testModuleRef.injector.get(core.LOCALE_ID, core.ɵDEFAULT_LOCALE_ID);
1305
- core.ɵsetLocaleId(localeId);
1306
- return this.testModuleRef;
1307
- };
1308
- /**
1309
- * @internal
1310
- */
1311
- R3TestBedCompiler.prototype._compileNgModuleSync = function (moduleType) {
1312
- this.queueTypesFromModulesArray([moduleType]);
1313
- this.compileTypesSync();
1314
- this.applyProviderOverrides();
1315
- this.applyProviderOverridesToModule(moduleType);
1316
- this.applyTransitiveScopes();
1317
- };
1318
- /**
1319
- * @internal
1320
- */
1321
- R3TestBedCompiler.prototype._compileNgModuleAsync = function (moduleType) {
1322
- return __awaiter(this, void 0, void 0, function () {
1323
- return __generator(this, function (_a) {
1324
- switch (_a.label) {
1325
- case 0:
1326
- this.queueTypesFromModulesArray([moduleType]);
1327
- return [4 /*yield*/, this.compileComponents()];
1328
- case 1:
1329
- _a.sent();
1330
- this.applyProviderOverrides();
1331
- this.applyProviderOverridesToModule(moduleType);
1332
- this.applyTransitiveScopes();
1333
- return [2 /*return*/];
1334
- }
1335
- });
1336
- });
1337
- };
1338
- /**
1339
- * @internal
1340
- */
1341
- R3TestBedCompiler.prototype._getModuleResolver = function () {
1342
- return this.resolvers.module;
1343
- };
1344
- /**
1345
- * @internal
1346
- */
1347
- R3TestBedCompiler.prototype._getComponentFactories = function (moduleType) {
1348
- var _this = this;
1349
- return maybeUnwrapFn(moduleType.ɵmod.declarations).reduce(function (factories, declaration) {
1350
- var componentDef = declaration.ɵcmp;
1351
- componentDef && factories.push(new core.ɵRender3ComponentFactory(componentDef, _this.testModuleRef));
1352
- return factories;
1353
- }, []);
1354
- };
1355
- R3TestBedCompiler.prototype.compileTypesSync = function () {
1356
- var _this = this;
1357
- // Compile all queued components, directives, pipes.
1358
- var needsAsyncResources = false;
1359
- this.pendingComponents.forEach(function (declaration) {
1360
- needsAsyncResources = needsAsyncResources || isComponentDefPendingResolution(declaration);
1361
- var metadata = _this.resolvers.component.resolve(declaration);
1362
- if (metadata === null) {
1363
- throw invalidTypeError(declaration.name, 'Component');
1364
- }
1365
- _this.maybeStoreNgDef(core.ɵNG_COMP_DEF, declaration);
1366
- core.ɵcompileComponent(declaration, metadata);
1367
- });
1368
- this.pendingComponents.clear();
1369
- this.pendingDirectives.forEach(function (declaration) {
1370
- var metadata = _this.resolvers.directive.resolve(declaration);
1371
- if (metadata === null) {
1372
- throw invalidTypeError(declaration.name, 'Directive');
1373
- }
1374
- _this.maybeStoreNgDef(core.ɵNG_DIR_DEF, declaration);
1375
- core.ɵcompileDirective(declaration, metadata);
1376
- });
1377
- this.pendingDirectives.clear();
1378
- this.pendingPipes.forEach(function (declaration) {
1379
- var metadata = _this.resolvers.pipe.resolve(declaration);
1380
- if (metadata === null) {
1381
- throw invalidTypeError(declaration.name, 'Pipe');
1382
- }
1383
- _this.maybeStoreNgDef(core.ɵNG_PIPE_DEF, declaration);
1384
- core.ɵcompilePipe(declaration, metadata);
1385
- });
1386
- this.pendingPipes.clear();
1387
- return needsAsyncResources;
1388
- };
1389
- R3TestBedCompiler.prototype.applyTransitiveScopes = function () {
1390
- var _this = this;
1391
- if (this.overriddenModules.size > 0) {
1392
- // Module overrides (via `TestBed.overrideModule`) might affect scopes that were previously
1393
- // calculated and stored in `transitiveCompileScopes`. If module overrides are present,
1394
- // collect all affected modules and reset scopes to force their re-calculation.
1395
- var testingModuleDef = this.testModuleType[core.ɵNG_MOD_DEF];
1396
- var affectedModules = this.collectModulesAffectedByOverrides(testingModuleDef.imports);
1397
- if (affectedModules.size > 0) {
1398
- affectedModules.forEach(function (moduleType) {
1399
- _this.storeFieldOfDefOnType(moduleType, core.ɵNG_MOD_DEF, 'transitiveCompileScopes');
1400
- moduleType[core.ɵNG_MOD_DEF].transitiveCompileScopes = null;
1401
- });
1402
- }
1403
- }
1404
- var moduleToScope = new Map();
1405
- var getScopeOfModule = function (moduleType) {
1406
- if (!moduleToScope.has(moduleType)) {
1407
- var isTestingModule = isTestingModuleOverride(moduleType);
1408
- var realType = isTestingModule ? _this.testModuleType : moduleType;
1409
- moduleToScope.set(moduleType, core.ɵtransitiveScopesFor(realType));
1410
- }
1411
- return moduleToScope.get(moduleType);
1412
- };
1413
- this.componentToModuleScope.forEach(function (moduleType, componentType) {
1414
- var moduleScope = getScopeOfModule(moduleType);
1415
- _this.storeFieldOfDefOnType(componentType, core.ɵNG_COMP_DEF, 'directiveDefs');
1416
- _this.storeFieldOfDefOnType(componentType, core.ɵNG_COMP_DEF, 'pipeDefs');
1417
- // `tView` that is stored on component def contains information about directives and pipes
1418
- // that are in the scope of this component. Patching component scope will cause `tView` to be
1419
- // changed. Store original `tView` before patching scope, so the `tView` (including scope
1420
- // information) is restored back to its previous/original state before running next test.
1421
- _this.storeFieldOfDefOnType(componentType, core.ɵNG_COMP_DEF, 'tView');
1422
- core.ɵpatchComponentDefWithScope(componentType.ɵcmp, moduleScope);
1423
- });
1424
- this.componentToModuleScope.clear();
1425
- };
1426
- R3TestBedCompiler.prototype.applyProviderOverrides = function () {
1427
- var _this = this;
1428
- var maybeApplyOverrides = function (field) { return function (type) {
1429
- var resolver = field === core.ɵNG_COMP_DEF ? _this.resolvers.component : _this.resolvers.directive;
1430
- var metadata = resolver.resolve(type);
1431
- if (_this.hasProviderOverrides(metadata.providers)) {
1432
- _this.patchDefWithProviderOverrides(type, field);
1433
- }
1434
- }; };
1435
- this.seenComponents.forEach(maybeApplyOverrides(core.ɵNG_COMP_DEF));
1436
- this.seenDirectives.forEach(maybeApplyOverrides(core.ɵNG_DIR_DEF));
1437
- this.seenComponents.clear();
1438
- this.seenDirectives.clear();
1439
- };
1440
- R3TestBedCompiler.prototype.applyProviderOverridesToModule = function (moduleType) {
1441
- var e_1, _a, e_2, _b;
1442
- if (this.moduleProvidersOverridden.has(moduleType)) {
1443
- return;
1444
- }
1445
- this.moduleProvidersOverridden.add(moduleType);
1446
- var injectorDef = moduleType[core.ɵNG_INJ_DEF];
1447
- if (this.providerOverridesByToken.size > 0) {
1448
- var providers = __spreadArray(__spreadArray([], __read(injectorDef.providers), false), __read((this.providerOverridesByModule.get(moduleType) || [])), false);
1449
- if (this.hasProviderOverrides(providers)) {
1450
- this.maybeStoreNgDef(core.ɵNG_INJ_DEF, moduleType);
1451
- this.storeFieldOfDefOnType(moduleType, core.ɵNG_INJ_DEF, 'providers');
1452
- injectorDef.providers = this.getOverriddenProviders(providers);
1453
- }
1454
- // Apply provider overrides to imported modules recursively
1455
- var moduleDef = moduleType[core.ɵNG_MOD_DEF];
1456
- var imports = maybeUnwrapFn(moduleDef.imports);
1457
- try {
1458
- for (var imports_1 = __values(imports), imports_1_1 = imports_1.next(); !imports_1_1.done; imports_1_1 = imports_1.next()) {
1459
- var importedModule = imports_1_1.value;
1460
- this.applyProviderOverridesToModule(importedModule);
1461
- }
1462
- }
1463
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1464
- finally {
1465
- try {
1466
- if (imports_1_1 && !imports_1_1.done && (_a = imports_1.return)) _a.call(imports_1);
1467
- }
1468
- finally { if (e_1) throw e_1.error; }
1469
- }
1470
- try {
1471
- // Also override the providers on any ModuleWithProviders imports since those don't appear in
1472
- // the moduleDef.
1473
- for (var _c = __values(flatten(injectorDef.imports)), _d = _c.next(); !_d.done; _d = _c.next()) {
1474
- var importedModule = _d.value;
1475
- if (isModuleWithProviders(importedModule)) {
1476
- this.defCleanupOps.push({
1477
- object: importedModule,
1478
- fieldName: 'providers',
1479
- originalValue: importedModule.providers
1480
- });
1481
- importedModule.providers = this.getOverriddenProviders(importedModule.providers);
1482
- }
1483
- }
1484
- }
1485
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1486
- finally {
1487
- try {
1488
- if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
1489
- }
1490
- finally { if (e_2) throw e_2.error; }
1491
- }
1492
- }
1493
- };
1494
- R3TestBedCompiler.prototype.patchComponentsWithExistingStyles = function () {
1495
- this.existingComponentStyles.forEach(function (styles, type) { return type[core.ɵNG_COMP_DEF].styles = styles; });
1496
- this.existingComponentStyles.clear();
1497
- };
1498
- R3TestBedCompiler.prototype.queueTypeArray = function (arr, moduleType) {
1499
- var e_3, _a;
1500
- try {
1501
- for (var arr_1 = __values(arr), arr_1_1 = arr_1.next(); !arr_1_1.done; arr_1_1 = arr_1.next()) {
1502
- var value = arr_1_1.value;
1503
- if (Array.isArray(value)) {
1504
- this.queueTypeArray(value, moduleType);
1505
- }
1506
- else {
1507
- this.queueType(value, moduleType);
1508
- }
1509
- }
1510
- }
1511
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1512
- finally {
1513
- try {
1514
- if (arr_1_1 && !arr_1_1.done && (_a = arr_1.return)) _a.call(arr_1);
1515
- }
1516
- finally { if (e_3) throw e_3.error; }
1517
- }
1518
- };
1519
- R3TestBedCompiler.prototype.recompileNgModule = function (ngModule, metadata) {
1520
- // Cache the initial ngModuleDef as it will be overwritten.
1521
- this.maybeStoreNgDef(core.ɵNG_MOD_DEF, ngModule);
1522
- this.maybeStoreNgDef(core.ɵNG_INJ_DEF, ngModule);
1523
- core.ɵcompileNgModuleDefs(ngModule, metadata);
1524
- };
1525
- R3TestBedCompiler.prototype.queueType = function (type, moduleType) {
1526
- var component = this.resolvers.component.resolve(type);
1527
- if (component) {
1528
- // Check whether a give Type has respective NG def (ɵcmp) and compile if def is
1529
- // missing. That might happen in case a class without any Angular decorators extends another
1530
- // class where Component/Directive/Pipe decorator is defined.
1531
- if (isComponentDefPendingResolution(type) || !type.hasOwnProperty(core.ɵNG_COMP_DEF)) {
1532
- this.pendingComponents.add(type);
1533
- }
1534
- this.seenComponents.add(type);
1535
- // Keep track of the module which declares this component, so later the component's scope
1536
- // can be set correctly. If the component has already been recorded here, then one of several
1537
- // cases is true:
1538
- // * the module containing the component was imported multiple times (common).
1539
- // * the component is declared in multiple modules (which is an error).
1540
- // * the component was in 'declarations' of the testing module, and also in an imported module
1541
- // in which case the module scope will be TestingModuleOverride.DECLARATION.
1542
- // * overrideTemplateUsingTestingModule was called for the component in which case the module
1543
- // scope will be TestingModuleOverride.OVERRIDE_TEMPLATE.
1544
- //
1545
- // If the component was previously in the testing module's 'declarations' (meaning the
1546
- // current value is TestingModuleOverride.DECLARATION), then `moduleType` is the component's
1547
- // real module, which was imported. This pattern is understood to mean that the component
1548
- // should use its original scope, but that the testing module should also contain the
1549
- // component in its scope.
1550
- if (!this.componentToModuleScope.has(type) ||
1551
- this.componentToModuleScope.get(type) === TestingModuleOverride.DECLARATION) {
1552
- this.componentToModuleScope.set(type, moduleType);
1553
- }
1554
- return;
1555
- }
1556
- var directive = this.resolvers.directive.resolve(type);
1557
- if (directive) {
1558
- if (!type.hasOwnProperty(core.ɵNG_DIR_DEF)) {
1559
- this.pendingDirectives.add(type);
1560
- }
1561
- this.seenDirectives.add(type);
1562
- return;
1563
- }
1564
- var pipe = this.resolvers.pipe.resolve(type);
1565
- if (pipe && !type.hasOwnProperty(core.ɵNG_PIPE_DEF)) {
1566
- this.pendingPipes.add(type);
1567
- return;
1568
- }
1569
- };
1570
- R3TestBedCompiler.prototype.queueTypesFromModulesArray = function (arr) {
1571
- var _this = this;
1572
- // Because we may encounter the same NgModule while processing the imports and exports of an
1573
- // NgModule tree, we cache them in this set so we can skip ones that have already been seen
1574
- // encountered. In some test setups, this caching resulted in 10X runtime improvement.
1575
- var processedNgModuleDefs = new Set();
1576
- var queueTypesFromModulesArrayRecur = function (arr) {
1577
- var e_4, _a;
1578
- try {
1579
- for (var arr_2 = __values(arr), arr_2_1 = arr_2.next(); !arr_2_1.done; arr_2_1 = arr_2.next()) {
1580
- var value = arr_2_1.value;
1581
- if (Array.isArray(value)) {
1582
- queueTypesFromModulesArrayRecur(value);
1583
- }
1584
- else if (hasNgModuleDef(value)) {
1585
- var def = value.ɵmod;
1586
- if (processedNgModuleDefs.has(def)) {
1587
- continue;
1588
- }
1589
- processedNgModuleDefs.add(def);
1590
- // Look through declarations, imports, and exports, and queue
1591
- // everything found there.
1592
- _this.queueTypeArray(maybeUnwrapFn(def.declarations), value);
1593
- queueTypesFromModulesArrayRecur(maybeUnwrapFn(def.imports));
1594
- queueTypesFromModulesArrayRecur(maybeUnwrapFn(def.exports));
1595
- }
1596
- else if (isModuleWithProviders(value)) {
1597
- queueTypesFromModulesArrayRecur([value.ngModule]);
1598
- }
1599
- }
1600
- }
1601
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1602
- finally {
1603
- try {
1604
- if (arr_2_1 && !arr_2_1.done && (_a = arr_2.return)) _a.call(arr_2);
1605
- }
1606
- finally { if (e_4) throw e_4.error; }
1607
- }
1608
- };
1609
- queueTypesFromModulesArrayRecur(arr);
1610
- };
1611
- // When module overrides (via `TestBed.overrideModule`) are present, it might affect all modules
1612
- // that import (even transitively) an overridden one. For all affected modules we need to
1613
- // recalculate their scopes for a given test run and restore original scopes at the end. The goal
1614
- // of this function is to collect all affected modules in a set for further processing. Example:
1615
- // if we have the following module hierarchy: A -> B -> C (where `->` means `imports`) and module
1616
- // `C` is overridden, we consider `A` and `B` as affected, since their scopes might become
1617
- // invalidated with the override.
1618
- R3TestBedCompiler.prototype.collectModulesAffectedByOverrides = function (arr) {
1619
- var _this = this;
1620
- var seenModules = new Set();
1621
- var affectedModules = new Set();
1622
- var calcAffectedModulesRecur = function (arr, path) {
1623
- var e_5, _a;
1624
- try {
1625
- for (var arr_3 = __values(arr), arr_3_1 = arr_3.next(); !arr_3_1.done; arr_3_1 = arr_3.next()) {
1626
- var value = arr_3_1.value;
1627
- if (Array.isArray(value)) {
1628
- // If the value is an array, just flatten it (by invoking this function recursively),
1629
- // keeping "path" the same.
1630
- calcAffectedModulesRecur(value, path);
1631
- }
1632
- else if (hasNgModuleDef(value)) {
1633
- if (seenModules.has(value)) {
1634
- // If we've seen this module before and it's included into "affected modules" list, mark
1635
- // the whole path that leads to that module as affected, but do not descend into its
1636
- // imports, since we already examined them before.
1637
- if (affectedModules.has(value)) {
1638
- path.forEach(function (item) { return affectedModules.add(item); });
1639
- }
1640
- continue;
1641
- }
1642
- seenModules.add(value);
1643
- if (_this.overriddenModules.has(value)) {
1644
- path.forEach(function (item) { return affectedModules.add(item); });
1645
- }
1646
- // Examine module imports recursively to look for overridden modules.
1647
- var moduleDef = value[core.ɵNG_MOD_DEF];
1648
- calcAffectedModulesRecur(maybeUnwrapFn(moduleDef.imports), path.concat(value));
1649
- }
1650
- }
1651
- }
1652
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1653
- finally {
1654
- try {
1655
- if (arr_3_1 && !arr_3_1.done && (_a = arr_3.return)) _a.call(arr_3);
1656
- }
1657
- finally { if (e_5) throw e_5.error; }
1658
- }
1659
- };
1660
- calcAffectedModulesRecur(arr, []);
1661
- return affectedModules;
1662
- };
1663
- R3TestBedCompiler.prototype.maybeStoreNgDef = function (prop, type) {
1664
- if (!this.initialNgDefs.has(type)) {
1665
- var currentDef = Object.getOwnPropertyDescriptor(type, prop);
1666
- this.initialNgDefs.set(type, [prop, currentDef]);
1667
- }
1668
- };
1669
- R3TestBedCompiler.prototype.storeFieldOfDefOnType = function (type, defField, fieldName) {
1670
- var def = type[defField];
1671
- var originalValue = def[fieldName];
1672
- this.defCleanupOps.push({ object: def, fieldName: fieldName, originalValue: originalValue });
1673
- };
1674
- /**
1675
- * Clears current components resolution queue, but stores the state of the queue, so we can
1676
- * restore it later. Clearing the queue is required before we try to compile components (via
1677
- * `TestBed.compileComponents`), so that component defs are in sync with the resolution queue.
1678
- */
1679
- R3TestBedCompiler.prototype.clearComponentResolutionQueue = function () {
1680
- var _this = this;
1681
- if (this.originalComponentResolutionQueue === null) {
1682
- this.originalComponentResolutionQueue = new Map();
1683
- }
1684
- clearResolutionOfComponentResourcesQueue().forEach(function (value, key) { return _this.originalComponentResolutionQueue.set(key, value); });
1685
- };
1686
- /*
1687
- * Restores component resolution queue to the previously saved state. This operation is performed
1688
- * as a part of restoring the state after completion of the current set of tests (that might
1689
- * potentially mutate the state).
1690
- */
1691
- R3TestBedCompiler.prototype.restoreComponentResolutionQueue = function () {
1692
- if (this.originalComponentResolutionQueue !== null) {
1693
- restoreComponentResolutionQueue(this.originalComponentResolutionQueue);
1694
- this.originalComponentResolutionQueue = null;
1695
- }
1696
- };
1697
- R3TestBedCompiler.prototype.restoreOriginalState = function () {
1698
- // Process cleanup ops in reverse order so the field's original value is restored correctly (in
1699
- // case there were multiple overrides for the same field).
1700
- forEachRight(this.defCleanupOps, function (op) {
1701
- op.object[op.fieldName] = op.originalValue;
1702
- });
1703
- // Restore initial component/directive/pipe defs
1704
- this.initialNgDefs.forEach(function (value, type) {
1705
- var _a = __read(value, 2), prop = _a[0], descriptor = _a[1];
1706
- if (!descriptor) {
1707
- // Delete operations are generally undesirable since they have performance implications
1708
- // on objects they were applied to. In this particular case, situations where this code
1709
- // is invoked should be quite rare to cause any noticeable impact, since it's applied
1710
- // only to some test cases (for example when class with no annotations extends some
1711
- // @Component) when we need to clear 'ɵcmp' field on a given class to restore
1712
- // its original state (before applying overrides and running tests).
1713
- delete type[prop];
1714
- }
1715
- else {
1716
- Object.defineProperty(type, prop, descriptor);
1717
- }
1718
- });
1719
- this.initialNgDefs.clear();
1720
- this.moduleProvidersOverridden.clear();
1721
- this.restoreComponentResolutionQueue();
1722
- // Restore the locale ID to the default value, this shouldn't be necessary but we never know
1723
- core.ɵsetLocaleId(core.ɵDEFAULT_LOCALE_ID);
1724
- };
1725
- R3TestBedCompiler.prototype.compileTestModule = function () {
1726
- var _this = this;
1727
- var RootScopeModule = /** @class */ (function () {
1728
- function RootScopeModule() {
1729
- }
1730
- return RootScopeModule;
1731
- }());
1732
- core.ɵcompileNgModuleDefs(RootScopeModule, {
1733
- providers: __spreadArray([], __read(this.rootProviderOverrides), false),
1734
- });
1735
- var ngZone = new core.NgZone({ enableLongStackTrace: true });
1736
- var providers = __spreadArray(__spreadArray([
1737
- { provide: core.NgZone, useValue: ngZone },
1738
- { provide: core.Compiler, useFactory: function () { return new R3TestCompiler(_this); } }
1739
- ], __read(this.providers), false), __read(this.providerOverrides), false);
1740
- var imports = [RootScopeModule, this.additionalModuleTypes, this.imports || []];
1741
- // clang-format off
1742
- core.ɵcompileNgModuleDefs(this.testModuleType, {
1743
- declarations: this.declarations,
1744
- imports: imports,
1745
- schemas: this.schemas,
1746
- providers: providers,
1747
- }, /* allowDuplicateDeclarationsInRoot */ true);
1748
- // clang-format on
1749
- this.applyProviderOverridesToModule(this.testModuleType);
1750
- };
1751
- Object.defineProperty(R3TestBedCompiler.prototype, "injector", {
1752
- get: function () {
1753
- if (this._injector !== null) {
1754
- return this._injector;
1755
- }
1756
- var providers = [];
1757
- var compilerOptions = this.platform.injector.get(core.COMPILER_OPTIONS);
1758
- compilerOptions.forEach(function (opts) {
1759
- if (opts.providers) {
1760
- providers.push(opts.providers);
1761
- }
1762
- });
1763
- if (this.compilerProviders !== null) {
1764
- providers.push.apply(providers, __spreadArray([], __read(this.compilerProviders), false));
1765
- }
1766
- // TODO(ocombe): make this work with an Injector directly instead of creating a module for it
1767
- var CompilerModule = /** @class */ (function () {
1768
- function CompilerModule() {
1769
- }
1770
- return CompilerModule;
1771
- }());
1772
- core.ɵcompileNgModuleDefs(CompilerModule, { providers: providers });
1773
- var CompilerModuleFactory = new core.ɵNgModuleFactory(CompilerModule);
1774
- this._injector = CompilerModuleFactory.create(this.platform.injector).injector;
1775
- return this._injector;
1776
- },
1777
- enumerable: false,
1778
- configurable: true
1779
- });
1780
- // get overrides for a specific provider (if any)
1781
- R3TestBedCompiler.prototype.getSingleProviderOverrides = function (provider) {
1782
- var token = getProviderToken(provider);
1783
- return this.providerOverridesByToken.get(token) || null;
1784
- };
1785
- R3TestBedCompiler.prototype.getProviderOverrides = function (providers) {
1786
- var _this = this;
1787
- if (!providers || !providers.length || this.providerOverridesByToken.size === 0)
1788
- return [];
1789
- // There are two flattening operations here. The inner flatten() operates on the metadata's
1790
- // providers and applies a mapping function which retrieves overrides for each incoming
1791
- // provider. The outer flatten() then flattens the produced overrides array. If this is not
1792
- // done, the array can contain other empty arrays (e.g. `[[], []]`) which leak into the
1793
- // providers array and contaminate any error messages that might be generated.
1794
- return flatten(flatten(providers, function (provider) { return _this.getSingleProviderOverrides(provider) || []; }));
1795
- };
1796
- R3TestBedCompiler.prototype.getOverriddenProviders = function (providers) {
1797
- var _this = this;
1798
- if (!providers || !providers.length || this.providerOverridesByToken.size === 0)
1799
- return [];
1800
- var flattenedProviders = flatten(providers);
1801
- var overrides = this.getProviderOverrides(flattenedProviders);
1802
- var overriddenProviders = __spreadArray(__spreadArray([], __read(flattenedProviders), false), __read(overrides), false);
1803
- var final = [];
1804
- var seenOverriddenProviders = new Set();
1805
- // We iterate through the list of providers in reverse order to make sure provider overrides
1806
- // take precedence over the values defined in provider list. We also filter out all providers
1807
- // that have overrides, keeping overridden values only. This is needed, since presence of a
1808
- // provider with `ngOnDestroy` hook will cause this hook to be registered and invoked later.
1809
- forEachRight(overriddenProviders, function (provider) {
1810
- var token = getProviderToken(provider);
1811
- if (_this.providerOverridesByToken.has(token)) {
1812
- if (!seenOverriddenProviders.has(token)) {
1813
- seenOverriddenProviders.add(token);
1814
- // Treat all overridden providers as `{multi: false}` (even if it's a multi-provider) to
1815
- // make sure that provided override takes highest precedence and is not combined with
1816
- // other instances of the same multi provider.
1817
- final.unshift(Object.assign(Object.assign({}, provider), { multi: false }));
1818
- }
1819
- }
1820
- else {
1821
- final.unshift(provider);
1822
- }
1823
- });
1824
- return final;
1825
- };
1826
- R3TestBedCompiler.prototype.hasProviderOverrides = function (providers) {
1827
- return this.getProviderOverrides(providers).length > 0;
1828
- };
1829
- R3TestBedCompiler.prototype.patchDefWithProviderOverrides = function (declaration, field) {
1830
- var _this = this;
1831
- var def = declaration[field];
1832
- if (def && def.providersResolver) {
1833
- this.maybeStoreNgDef(field, declaration);
1834
- var resolver_1 = def.providersResolver;
1835
- var processProvidersFn_1 = function (providers) { return _this.getOverriddenProviders(providers); };
1836
- this.storeFieldOfDefOnType(declaration, field, 'providersResolver');
1837
- def.providersResolver = function (ngDef) { return resolver_1(ngDef, processProvidersFn_1); };
1838
- }
1839
- };
1840
- return R3TestBedCompiler;
1841
- }());
1842
- function initResolvers() {
1843
- return {
1844
- module: new NgModuleResolver(),
1845
- component: new ComponentResolver(),
1846
- directive: new DirectiveResolver(),
1847
- pipe: new PipeResolver()
1848
- };
1849
- }
1850
- function hasNgModuleDef(value) {
1851
- return value.hasOwnProperty('ɵmod');
1852
- }
1853
- function maybeUnwrapFn(maybeFn) {
1854
- return maybeFn instanceof Function ? maybeFn() : maybeFn;
1855
- }
1856
- function flatten(values, mapFn) {
1857
- var out = [];
1858
- values.forEach(function (value) {
1859
- if (Array.isArray(value)) {
1860
- out.push.apply(out, __spreadArray([], __read(flatten(value, mapFn)), false));
1861
- }
1862
- else {
1863
- out.push(mapFn ? mapFn(value) : value);
1864
- }
1865
- });
1866
- return out;
1867
- }
1868
- function getProviderField(provider, field) {
1869
- return provider && typeof provider === 'object' && provider[field];
1870
- }
1871
- function getProviderToken(provider) {
1872
- return getProviderField(provider, 'provide') || provider;
1873
- }
1874
- function isModuleWithProviders(value) {
1875
- return value.hasOwnProperty('ngModule');
1876
- }
1877
- function forEachRight(values, fn) {
1878
- for (var idx = values.length - 1; idx >= 0; idx--) {
1879
- fn(values[idx], idx);
1880
- }
1881
- }
1882
- function invalidTypeError(name, expectedType) {
1883
- return new Error(name + " class doesn't have @" + expectedType + " decorator or is missing metadata.");
1884
- }
1885
- var R3TestCompiler = /** @class */ (function () {
1886
- function R3TestCompiler(testBed) {
1887
- this.testBed = testBed;
1888
- }
1889
- R3TestCompiler.prototype.compileModuleSync = function (moduleType) {
1890
- this.testBed._compileNgModuleSync(moduleType);
1891
- return new core.ɵNgModuleFactory(moduleType);
1892
- };
1893
- R3TestCompiler.prototype.compileModuleAsync = function (moduleType) {
1894
- return __awaiter(this, void 0, void 0, function () {
1895
- return __generator(this, function (_a) {
1896
- switch (_a.label) {
1897
- case 0: return [4 /*yield*/, this.testBed._compileNgModuleAsync(moduleType)];
1898
- case 1:
1899
- _a.sent();
1900
- return [2 /*return*/, new core.ɵNgModuleFactory(moduleType)];
1901
- }
1902
- });
1903
- });
1904
- };
1905
- R3TestCompiler.prototype.compileModuleAndAllComponentsSync = function (moduleType) {
1906
- var ngModuleFactory = this.compileModuleSync(moduleType);
1907
- var componentFactories = this.testBed._getComponentFactories(moduleType);
1908
- return new core.ModuleWithComponentFactories(ngModuleFactory, componentFactories);
1909
- };
1910
- R3TestCompiler.prototype.compileModuleAndAllComponentsAsync = function (moduleType) {
1911
- return __awaiter(this, void 0, void 0, function () {
1912
- var ngModuleFactory, componentFactories;
1913
- return __generator(this, function (_a) {
1914
- switch (_a.label) {
1915
- case 0: return [4 /*yield*/, this.compileModuleAsync(moduleType)];
1916
- case 1:
1917
- ngModuleFactory = _a.sent();
1918
- componentFactories = this.testBed._getComponentFactories(moduleType);
1919
- return [2 /*return*/, new core.ModuleWithComponentFactories(ngModuleFactory, componentFactories)];
1920
- }
1921
- });
1922
- });
1923
- };
1924
- R3TestCompiler.prototype.clearCache = function () { };
1925
- R3TestCompiler.prototype.clearCacheFor = function (type) { };
1926
- R3TestCompiler.prototype.getModuleId = function (moduleType) {
1927
- var meta = this.testBed._getModuleResolver().resolve(moduleType);
1928
- return meta && meta.id || undefined;
1929
- };
1930
- return R3TestCompiler;
1931
- }());
1932
-
1933
- /**
1934
- * @license
1935
- * Copyright Google LLC All Rights Reserved.
1936
- *
1937
- * Use of this source code is governed by an MIT-style license that can be
1938
- * found in the LICENSE file at https://angular.io/license
1939
- */
1940
- /**
1941
- * Whether test modules should be torn down by default.
1942
- * Currently disabled for backwards-compatibility reasons.
1943
- */
1944
- var TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT = false;
1945
- /**
1946
- * An abstract class for inserting the root test component element in a platform independent way.
1947
- *
1948
- * @publicApi
1949
- */
1950
- var TestComponentRenderer = /** @class */ (function () {
1951
- function TestComponentRenderer() {
1952
- }
1953
- TestComponentRenderer.prototype.insertRootElement = function (rootElementId) { };
1954
- TestComponentRenderer.prototype.removeAllRootElements = function () { };
1955
- return TestComponentRenderer;
1956
- }());
1957
- /**
1958
- * @publicApi
1959
- */
1960
- var ComponentFixtureAutoDetect = new core.InjectionToken('ComponentFixtureAutoDetect');
1961
- /**
1962
- * @publicApi
1963
- */
1964
- var ComponentFixtureNoNgZone = new core.InjectionToken('ComponentFixtureNoNgZone');
1965
-
1966
- /**
1967
- * @license
1968
- * Copyright Google LLC All Rights Reserved.
1969
- *
1970
- * Use of this source code is governed by an MIT-style license that can be
1971
- * found in the LICENSE file at https://angular.io/license
1972
- */
1973
- var _nextRootElementId = 0;
1974
- /**
1975
- * @description
1976
- * Configures and initializes environment for unit testing and provides methods for
1977
- * creating components and services in unit tests.
1978
- *
1979
- * TestBed is the primary api for writing unit tests for Angular applications and libraries.
1980
- *
1981
- * Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3`
1982
- * according to the compiler used.
1983
- */
1984
- var TestBedRender3 = /** @class */ (function () {
1985
- function TestBedRender3() {
1986
- // Properties
1987
- this.platform = null;
1988
- this.ngModule = null;
1989
- this._compiler = null;
1990
- this._testModuleRef = null;
1991
- this._activeFixtures = [];
1992
- this._globalCompilationChecked = false;
1993
- }
1994
- /**
1995
- * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
1996
- * angular module. These are common to every test in the suite.
1997
- *
1998
- * This may only be called once, to set up the common providers for the current test
1999
- * suite on the current platform. If you absolutely need to change the providers,
2000
- * first use `resetTestEnvironment`.
2001
- *
2002
- * Test modules and platforms for individual platforms are available from
2003
- * '@angular/<platform_name>/testing'.
2004
- *
2005
- * @publicApi
2006
- */
2007
- TestBedRender3.initTestEnvironment = function (ngModule, platform, summariesOrOptions) {
2008
- var testBed = _getTestBedRender3();
2009
- testBed.initTestEnvironment(ngModule, platform, summariesOrOptions);
2010
- return testBed;
2011
- };
2012
- /**
2013
- * Reset the providers for the test injector.
2014
- *
2015
- * @publicApi
2016
- */
2017
- TestBedRender3.resetTestEnvironment = function () {
2018
- _getTestBedRender3().resetTestEnvironment();
2019
- };
2020
- TestBedRender3.configureCompiler = function (config) {
2021
- _getTestBedRender3().configureCompiler(config);
2022
- return TestBedRender3;
2023
- };
2024
- /**
2025
- * Allows overriding default providers, directives, pipes, modules of the test injector,
2026
- * which are defined in test_injector.js
2027
- */
2028
- TestBedRender3.configureTestingModule = function (moduleDef) {
2029
- _getTestBedRender3().configureTestingModule(moduleDef);
2030
- return TestBedRender3;
2031
- };
2032
- /**
2033
- * Compile components with a `templateUrl` for the test's NgModule.
2034
- * It is necessary to call this function
2035
- * as fetching urls is asynchronous.
2036
- */
2037
- TestBedRender3.compileComponents = function () {
2038
- return _getTestBedRender3().compileComponents();
2039
- };
2040
- TestBedRender3.overrideModule = function (ngModule, override) {
2041
- _getTestBedRender3().overrideModule(ngModule, override);
2042
- return TestBedRender3;
2043
- };
2044
- TestBedRender3.overrideComponent = function (component, override) {
2045
- _getTestBedRender3().overrideComponent(component, override);
2046
- return TestBedRender3;
2047
- };
2048
- TestBedRender3.overrideDirective = function (directive, override) {
2049
- _getTestBedRender3().overrideDirective(directive, override);
2050
- return TestBedRender3;
2051
- };
2052
- TestBedRender3.overridePipe = function (pipe, override) {
2053
- _getTestBedRender3().overridePipe(pipe, override);
2054
- return TestBedRender3;
2055
- };
2056
- TestBedRender3.overrideTemplate = function (component, template) {
2057
- _getTestBedRender3().overrideComponent(component, { set: { template: template, templateUrl: null } });
2058
- return TestBedRender3;
2059
- };
2060
- /**
2061
- * Overrides the template of the given component, compiling the template
2062
- * in the context of the TestingModule.
2063
- *
2064
- * Note: This works for JIT and AOTed components as well.
2065
- */
2066
- TestBedRender3.overrideTemplateUsingTestingModule = function (component, template) {
2067
- _getTestBedRender3().overrideTemplateUsingTestingModule(component, template);
2068
- return TestBedRender3;
2069
- };
2070
- TestBedRender3.overrideProvider = function (token, provider) {
2071
- _getTestBedRender3().overrideProvider(token, provider);
2072
- return TestBedRender3;
2073
- };
2074
- TestBedRender3.inject = function (token, notFoundValue, flags) {
2075
- return _getTestBedRender3().inject(token, notFoundValue, flags);
2076
- };
2077
- /** @deprecated from v9.0.0 use TestBed.inject */
2078
- TestBedRender3.get = function (token, notFoundValue, flags) {
2079
- if (notFoundValue === void 0) { notFoundValue = core.Injector.THROW_IF_NOT_FOUND; }
2080
- if (flags === void 0) { flags = core.InjectFlags.Default; }
2081
- return _getTestBedRender3().inject(token, notFoundValue, flags);
2082
- };
2083
- TestBedRender3.createComponent = function (component) {
2084
- return _getTestBedRender3().createComponent(component);
2085
- };
2086
- TestBedRender3.resetTestingModule = function () {
2087
- _getTestBedRender3().resetTestingModule();
2088
- return TestBedRender3;
2089
- };
2090
- TestBedRender3.shouldTearDownTestingModule = function () {
2091
- return _getTestBedRender3().shouldTearDownTestingModule();
2092
- };
2093
- TestBedRender3.tearDownTestingModule = function () {
2094
- _getTestBedRender3().tearDownTestingModule();
2095
- };
2096
- /**
2097
- * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
2098
- * angular module. These are common to every test in the suite.
2099
- *
2100
- * This may only be called once, to set up the common providers for the current test
2101
- * suite on the current platform. If you absolutely need to change the providers,
2102
- * first use `resetTestEnvironment`.
2103
- *
2104
- * Test modules and platforms for individual platforms are available from
2105
- * '@angular/<platform_name>/testing'.
2106
- *
2107
- * @publicApi
2108
- */
2109
- TestBedRender3.prototype.initTestEnvironment = function (ngModule, platform, summariesOrOptions) {
2110
- if (this.platform || this.ngModule) {
2111
- throw new Error('Cannot set base providers because it has already been called');
2112
- }
2113
- // If `summariesOrOptions` is a function, it means that it's
2114
- // an AOT summaries factory which Ivy doesn't support.
2115
- TestBedRender3._environmentTeardownOptions =
2116
- typeof summariesOrOptions === 'function' ? undefined : summariesOrOptions === null || summariesOrOptions === void 0 ? void 0 : summariesOrOptions.teardown;
2117
- this.platform = platform;
2118
- this.ngModule = ngModule;
2119
- this._compiler = new R3TestBedCompiler(this.platform, this.ngModule);
2120
- };
2121
- /**
2122
- * Reset the providers for the test injector.
2123
- *
2124
- * @publicApi
2125
- */
2126
- TestBedRender3.prototype.resetTestEnvironment = function () {
2127
- this.resetTestingModule();
2128
- this._compiler = null;
2129
- this.platform = null;
2130
- this.ngModule = null;
2131
- TestBedRender3._environmentTeardownOptions = undefined;
2132
- };
2133
- TestBedRender3.prototype.resetTestingModule = function () {
2134
- this.checkGlobalCompilationFinished();
2135
- core.ɵresetCompiledComponents();
2136
- if (this._compiler !== null) {
2137
- this.compiler.restoreOriginalState();
2138
- }
2139
- this._compiler = new R3TestBedCompiler(this.platform, this.ngModule);
2140
- // We have to chain a couple of try/finally blocks, because each step can
2141
- // throw errors and we don't want it to interrupt the next step and we also
2142
- // want an error to be thrown at the end.
2143
- try {
2144
- this.destroyActiveFixtures();
2145
- }
2146
- finally {
2147
- try {
2148
- if (this.shouldTearDownTestingModule()) {
2149
- this.tearDownTestingModule();
2150
- }
2151
- }
2152
- finally {
2153
- this._testModuleRef = null;
2154
- this._instanceTeardownOptions = undefined;
2155
- }
2156
- }
2157
- };
2158
- TestBedRender3.prototype.configureCompiler = function (config) {
2159
- if (config.useJit != null) {
2160
- throw new Error('the Render3 compiler JiT mode is not configurable !');
2161
- }
2162
- if (config.providers !== undefined) {
2163
- this.compiler.setCompilerProviders(config.providers);
2164
- }
2165
- };
2166
- TestBedRender3.prototype.configureTestingModule = function (moduleDef) {
2167
- this.assertNotInstantiated('R3TestBed.configureTestingModule', 'configure the test module');
2168
- // Always re-assign the teardown options, even if they're undefined.
2169
- // This ensures that we don't carry the options between tests.
2170
- this._instanceTeardownOptions = moduleDef.teardown;
2171
- this.compiler.configureTestingModule(moduleDef);
2172
- };
2173
- TestBedRender3.prototype.compileComponents = function () {
2174
- return this.compiler.compileComponents();
2175
- };
2176
- TestBedRender3.prototype.inject = function (token, notFoundValue, flags) {
2177
- if (token === TestBedRender3) {
2178
- return this;
2179
- }
2180
- var UNDEFINED = {};
2181
- var result = this.testModuleRef.injector.get(token, UNDEFINED, flags);
2182
- return result === UNDEFINED ? this.compiler.injector.get(token, notFoundValue, flags) :
2183
- result;
2184
- };
2185
- /** @deprecated from v9.0.0 use TestBed.inject */
2186
- TestBedRender3.prototype.get = function (token, notFoundValue, flags) {
2187
- if (notFoundValue === void 0) { notFoundValue = core.Injector.THROW_IF_NOT_FOUND; }
2188
- if (flags === void 0) { flags = core.InjectFlags.Default; }
2189
- return this.inject(token, notFoundValue, flags);
2190
- };
2191
- TestBedRender3.prototype.execute = function (tokens, fn, context) {
2192
- var _this = this;
2193
- var params = tokens.map(function (t) { return _this.inject(t); });
2194
- return fn.apply(context, params);
2195
- };
2196
- TestBedRender3.prototype.overrideModule = function (ngModule, override) {
2197
- this.assertNotInstantiated('overrideModule', 'override module metadata');
2198
- this.compiler.overrideModule(ngModule, override);
2199
- };
2200
- TestBedRender3.prototype.overrideComponent = function (component, override) {
2201
- this.assertNotInstantiated('overrideComponent', 'override component metadata');
2202
- this.compiler.overrideComponent(component, override);
2203
- };
2204
- TestBedRender3.prototype.overrideTemplateUsingTestingModule = function (component, template) {
2205
- this.assertNotInstantiated('R3TestBed.overrideTemplateUsingTestingModule', 'Cannot override template when the test module has already been instantiated');
2206
- this.compiler.overrideTemplateUsingTestingModule(component, template);
2207
- };
2208
- TestBedRender3.prototype.overrideDirective = function (directive, override) {
2209
- this.assertNotInstantiated('overrideDirective', 'override directive metadata');
2210
- this.compiler.overrideDirective(directive, override);
2211
- };
2212
- TestBedRender3.prototype.overridePipe = function (pipe, override) {
2213
- this.assertNotInstantiated('overridePipe', 'override pipe metadata');
2214
- this.compiler.overridePipe(pipe, override);
2215
- };
2216
- /**
2217
- * Overwrites all providers for the given token with the given provider definition.
2218
- */
2219
- TestBedRender3.prototype.overrideProvider = function (token, provider) {
2220
- this.assertNotInstantiated('overrideProvider', 'override provider');
2221
- this.compiler.overrideProvider(token, provider);
2222
- };
2223
- TestBedRender3.prototype.createComponent = function (type) {
2224
- var _this = this;
2225
- var testComponentRenderer = this.inject(TestComponentRenderer);
2226
- var rootElId = "root" + _nextRootElementId++;
2227
- testComponentRenderer.insertRootElement(rootElId);
2228
- var componentDef = type.ɵcmp;
2229
- if (!componentDef) {
2230
- throw new Error("It looks like '" + core.ɵstringify(type) + "' has not been IVY compiled - it has no '\u0275cmp' field");
2231
- }
2232
- // TODO: Don't cast as `InjectionToken<boolean>`, proper type is boolean[]
2233
- var noNgZone = this.inject(ComponentFixtureNoNgZone, false);
2234
- // TODO: Don't cast as `InjectionToken<boolean>`, proper type is boolean[]
2235
- var autoDetect = this.inject(ComponentFixtureAutoDetect, false);
2236
- var ngZone = noNgZone ? null : this.inject(core.NgZone, null);
2237
- var componentFactory = new core.ɵRender3ComponentFactory(componentDef);
2238
- var initComponent = function () {
2239
- var componentRef = componentFactory.create(core.Injector.NULL, [], "#" + rootElId, _this.testModuleRef);
2240
- return new ComponentFixture(componentRef, ngZone, autoDetect);
2241
- };
2242
- var fixture = ngZone ? ngZone.run(initComponent) : initComponent();
2243
- this._activeFixtures.push(fixture);
2244
- return fixture;
2245
- };
2246
- Object.defineProperty(TestBedRender3.prototype, "compiler", {
2247
- /**
2248
- * @internal strip this from published d.ts files due to
2249
- * https://github.com/microsoft/TypeScript/issues/36216
2250
- */
2251
- get: function () {
2252
- if (this._compiler === null) {
2253
- throw new Error("Need to call TestBed.initTestEnvironment() first");
2254
- }
2255
- return this._compiler;
2256
- },
2257
- enumerable: false,
2258
- configurable: true
2259
- });
2260
- Object.defineProperty(TestBedRender3.prototype, "testModuleRef", {
2261
- /**
2262
- * @internal strip this from published d.ts files due to
2263
- * https://github.com/microsoft/TypeScript/issues/36216
2264
- */
2265
- get: function () {
2266
- if (this._testModuleRef === null) {
2267
- this._testModuleRef = this.compiler.finalize();
2268
- }
2269
- return this._testModuleRef;
2270
- },
2271
- enumerable: false,
2272
- configurable: true
2273
- });
2274
- TestBedRender3.prototype.assertNotInstantiated = function (methodName, methodDescription) {
2275
- if (this._testModuleRef !== null) {
2276
- throw new Error("Cannot " + methodDescription + " when the test module has already been instantiated. " +
2277
- ("Make sure you are not using `inject` before `" + methodName + "`."));
2278
- }
2279
- };
2280
- /**
2281
- * Check whether the module scoping queue should be flushed, and flush it if needed.
2282
- *
2283
- * When the TestBed is reset, it clears the JIT module compilation queue, cancelling any
2284
- * in-progress module compilation. This creates a potential hazard - the very first time the
2285
- * TestBed is initialized (or if it's reset without being initialized), there may be pending
2286
- * compilations of modules declared in global scope. These compilations should be finished.
2287
- *
2288
- * To ensure that globally declared modules have their components scoped properly, this function
2289
- * is called whenever TestBed is initialized or reset. The _first_ time that this happens, prior
2290
- * to any other operations, the scoping queue is flushed.
2291
- */
2292
- TestBedRender3.prototype.checkGlobalCompilationFinished = function () {
2293
- // Checking _testNgModuleRef is null should not be necessary, but is left in as an additional
2294
- // guard that compilations queued in tests (after instantiation) are never flushed accidentally.
2295
- if (!this._globalCompilationChecked && this._testModuleRef === null) {
2296
- core.ɵflushModuleScopingQueueAsMuchAsPossible();
2297
- }
2298
- this._globalCompilationChecked = true;
2299
- };
2300
- TestBedRender3.prototype.destroyActiveFixtures = function () {
2301
- var errorCount = 0;
2302
- this._activeFixtures.forEach(function (fixture) {
2303
- try {
2304
- fixture.destroy();
2305
- }
2306
- catch (e) {
2307
- errorCount++;
2308
- console.error('Error during cleanup of component', {
2309
- component: fixture.componentInstance,
2310
- stacktrace: e,
2311
- });
2312
- }
2313
- });
2314
- this._activeFixtures = [];
2315
- if (errorCount > 0 && this.shouldRethrowTeardownErrors()) {
2316
- throw Error(errorCount + " " + (errorCount === 1 ? 'component' : 'components') + " " +
2317
- "threw errors during cleanup");
2318
- }
2319
- };
2320
- TestBedRender3.prototype.shouldRethrowTeardownErrors = function () {
2321
- var _a, _b;
2322
- var instanceOptions = this._instanceTeardownOptions;
2323
- var environmentOptions = TestBedRender3._environmentTeardownOptions;
2324
- // If the new teardown behavior hasn't been configured, preserve the old behavior.
2325
- if (!instanceOptions && !environmentOptions) {
2326
- return false;
2327
- }
2328
- // Otherwise use the configured behavior or default to rethrowing.
2329
- return (_b = (_a = instanceOptions === null || instanceOptions === void 0 ? void 0 : instanceOptions.rethrowErrors) !== null && _a !== void 0 ? _a : environmentOptions === null || environmentOptions === void 0 ? void 0 : environmentOptions.rethrowErrors) !== null && _b !== void 0 ? _b : true;
2330
- };
2331
- TestBedRender3.prototype.shouldTearDownTestingModule = function () {
2332
- var _a, _b, _c, _d;
2333
- return (_d = (_b = (_a = this._instanceTeardownOptions) === null || _a === void 0 ? void 0 : _a.destroyAfterEach) !== null && _b !== void 0 ? _b : (_c = TestBedRender3._environmentTeardownOptions) === null || _c === void 0 ? void 0 : _c.destroyAfterEach) !== null && _d !== void 0 ? _d : TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT;
2334
- };
2335
- TestBedRender3.prototype.tearDownTestingModule = function () {
2336
- var _a;
2337
- // If the module ref has already been destroyed, we won't be able to get a test renderer.
2338
- if (this._testModuleRef === null) {
2339
- return;
2340
- }
2341
- // Resolve the renderer ahead of time, because we want to remove the root elements as the very
2342
- // last step, but the injector will be destroyed as a part of the module ref destruction.
2343
- var testRenderer = this.inject(TestComponentRenderer);
2344
- try {
2345
- this._testModuleRef.destroy();
2346
- }
2347
- catch (e) {
2348
- if (this.shouldRethrowTeardownErrors()) {
2349
- throw e;
2350
- }
2351
- else {
2352
- console.error('Error during cleanup of a testing module', {
2353
- component: this._testModuleRef.instance,
2354
- stacktrace: e,
2355
- });
2356
- }
2357
- }
2358
- finally {
2359
- (_a = testRenderer.removeAllRootElements) === null || _a === void 0 ? void 0 : _a.call(testRenderer);
2360
- }
2361
- };
2362
- return TestBedRender3;
2363
- }());
2364
- var testBed;
2365
- function _getTestBedRender3() {
2366
- return testBed = testBed || new TestBedRender3();
2367
- }
2368
-
2369
- function unimplemented() {
2370
- throw Error('unimplemented');
2371
- }
2372
- /**
2373
- * Special interface to the compiler only used by testing
2374
- *
2375
- * @publicApi
2376
- */
2377
- var TestingCompiler = /** @class */ (function (_super) {
2378
- __extends(TestingCompiler, _super);
2379
- function TestingCompiler() {
2380
- return _super !== null && _super.apply(this, arguments) || this;
2381
- }
2382
- Object.defineProperty(TestingCompiler.prototype, "injector", {
2383
- get: function () {
2384
- throw unimplemented();
2385
- },
2386
- enumerable: false,
2387
- configurable: true
2388
- });
2389
- TestingCompiler.prototype.overrideModule = function (module, overrides) {
2390
- throw unimplemented();
2391
- };
2392
- TestingCompiler.prototype.overrideDirective = function (directive, overrides) {
2393
- throw unimplemented();
2394
- };
2395
- TestingCompiler.prototype.overrideComponent = function (component, overrides) {
2396
- throw unimplemented();
2397
- };
2398
- TestingCompiler.prototype.overridePipe = function (directive, overrides) {
2399
- throw unimplemented();
2400
- };
2401
- /**
2402
- * Allows to pass the compile summary from AOT compilation to the JIT compiler,
2403
- * so that it can use the code generated by AOT.
2404
- */
2405
- TestingCompiler.prototype.loadAotSummaries = function (summaries) {
2406
- throw unimplemented();
2407
- };
2408
- /**
2409
- * Gets the component factory for the given component.
2410
- * This assumes that the component has been compiled before calling this call using
2411
- * `compileModuleAndAllComponents*`.
2412
- */
2413
- TestingCompiler.prototype.getComponentFactory = function (component) {
2414
- throw unimplemented();
2415
- };
2416
- /**
2417
- * Returns the component type that is stored in the given error.
2418
- * This can be used for errors created by compileModule...
2419
- */
2420
- TestingCompiler.prototype.getComponentFromError = function (error) {
2421
- throw unimplemented();
2422
- };
2423
- return TestingCompiler;
2424
- }(core.Compiler));
2425
- TestingCompiler.decorators = [
2426
- { type: core.Injectable }
2427
- ];
2428
- /**
2429
- * A factory for creating a Compiler
2430
- *
2431
- * @publicApi
2432
- */
2433
- var TestingCompilerFactory = /** @class */ (function () {
2434
- function TestingCompilerFactory() {
2435
- }
2436
- return TestingCompilerFactory;
2437
- }());
2438
-
2439
- var _nextRootElementId$1 = 0;
2440
- /**
2441
- * @description
2442
- * Configures and initializes environment for unit testing and provides methods for
2443
- * creating components and services in unit tests.
2444
- *
2445
- * `TestBed` is the primary api for writing unit tests for Angular applications and libraries.
2446
- *
2447
- * Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3`
2448
- * according to the compiler used.
2449
- */
2450
- var TestBedViewEngine = /** @class */ (function () {
2451
- function TestBedViewEngine() {
2452
- this._instantiated = false;
2453
- this._compiler = null;
2454
- this._moduleRef = null;
2455
- this._moduleFactory = null;
2456
- this._pendingModuleFactory = null;
2457
- this._compilerOptions = [];
2458
- this._moduleOverrides = [];
2459
- this._componentOverrides = [];
2460
- this._directiveOverrides = [];
2461
- this._pipeOverrides = [];
2462
- this._providers = [];
2463
- this._declarations = [];
2464
- this._imports = [];
2465
- this._schemas = [];
2466
- this._activeFixtures = [];
2467
- this._testEnvAotSummaries = function () { return []; };
2468
- this._aotSummaries = [];
2469
- this._templateOverrides = [];
2470
- this._isRoot = true;
2471
- this._rootProviderOverrides = [];
2472
- this.platform = null;
2473
- this.ngModule = null;
2474
- }
2475
- /**
2476
- * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
2477
- * angular module. These are common to every test in the suite.
2478
- *
2479
- * This may only be called once, to set up the common providers for the current test
2480
- * suite on the current platform. If you absolutely need to change the providers,
2481
- * first use `resetTestEnvironment`.
2482
- *
2483
- * Test modules and platforms for individual platforms are available from
2484
- * '@angular/<platform_name>/testing'.
2485
- */
2486
- TestBedViewEngine.initTestEnvironment = function (ngModule, platform, summariesOrOptions) {
2487
- var testBed = _getTestBedViewEngine();
2488
- testBed.initTestEnvironment(ngModule, platform, summariesOrOptions);
2489
- return testBed;
2490
- };
2491
- /**
2492
- * Reset the providers for the test injector.
2493
- */
2494
- TestBedViewEngine.resetTestEnvironment = function () {
2495
- _getTestBedViewEngine().resetTestEnvironment();
2496
- };
2497
- TestBedViewEngine.resetTestingModule = function () {
2498
- _getTestBedViewEngine().resetTestingModule();
2499
- return TestBedViewEngine;
2500
- };
2501
- /**
2502
- * Allows overriding default compiler providers and settings
2503
- * which are defined in test_injector.js
2504
- */
2505
- TestBedViewEngine.configureCompiler = function (config) {
2506
- _getTestBedViewEngine().configureCompiler(config);
2507
- return TestBedViewEngine;
2508
- };
2509
- /**
2510
- * Allows overriding default providers, directives, pipes, modules of the test injector,
2511
- * which are defined in test_injector.js
2512
- */
2513
- TestBedViewEngine.configureTestingModule = function (moduleDef) {
2514
- _getTestBedViewEngine().configureTestingModule(moduleDef);
2515
- return TestBedViewEngine;
2516
- };
2517
- /**
2518
- * Compile components with a `templateUrl` for the test's NgModule.
2519
- * It is necessary to call this function
2520
- * as fetching urls is asynchronous.
2521
- */
2522
- TestBedViewEngine.compileComponents = function () {
2523
- return getTestBed().compileComponents();
2524
- };
2525
- TestBedViewEngine.overrideModule = function (ngModule, override) {
2526
- _getTestBedViewEngine().overrideModule(ngModule, override);
2527
- return TestBedViewEngine;
2528
- };
2529
- TestBedViewEngine.overrideComponent = function (component, override) {
2530
- _getTestBedViewEngine().overrideComponent(component, override);
2531
- return TestBedViewEngine;
2532
- };
2533
- TestBedViewEngine.overrideDirective = function (directive, override) {
2534
- _getTestBedViewEngine().overrideDirective(directive, override);
2535
- return TestBedViewEngine;
2536
- };
2537
- TestBedViewEngine.overridePipe = function (pipe, override) {
2538
- _getTestBedViewEngine().overridePipe(pipe, override);
2539
- return TestBedViewEngine;
2540
- };
2541
- TestBedViewEngine.overrideTemplate = function (component, template) {
2542
- _getTestBedViewEngine().overrideComponent(component, { set: { template: template, templateUrl: null } });
2543
- return TestBedViewEngine;
2544
- };
2545
- /**
2546
- * Overrides the template of the given component, compiling the template
2547
- * in the context of the TestingModule.
2548
- *
2549
- * Note: This works for JIT and AOTed components as well.
2550
- */
2551
- TestBedViewEngine.overrideTemplateUsingTestingModule = function (component, template) {
2552
- _getTestBedViewEngine().overrideTemplateUsingTestingModule(component, template);
2553
- return TestBedViewEngine;
2554
- };
2555
- TestBedViewEngine.overrideProvider = function (token, provider) {
2556
- _getTestBedViewEngine().overrideProvider(token, provider);
2557
- return TestBedViewEngine;
2558
- };
2559
- TestBedViewEngine.inject = function (token, notFoundValue, flags) {
2560
- return _getTestBedViewEngine().inject(token, notFoundValue, flags);
2561
- };
2562
- /** @deprecated from v9.0.0 use TestBed.inject */
2563
- TestBedViewEngine.get = function (token, notFoundValue, flags) {
2564
- if (notFoundValue === void 0) { notFoundValue = core.Injector.THROW_IF_NOT_FOUND; }
2565
- if (flags === void 0) { flags = core.InjectFlags.Default; }
2566
- return _getTestBedViewEngine().inject(token, notFoundValue, flags);
2567
- };
2568
- TestBedViewEngine.createComponent = function (component) {
2569
- return _getTestBedViewEngine().createComponent(component);
2570
- };
2571
- TestBedViewEngine.shouldTearDownTestingModule = function () {
2572
- return _getTestBedViewEngine().shouldTearDownTestingModule();
2573
- };
2574
- TestBedViewEngine.tearDownTestingModule = function () {
2575
- _getTestBedViewEngine().tearDownTestingModule();
2576
- };
2577
- /**
2578
- * Initialize the environment for testing with a compiler factory, a PlatformRef, and an
2579
- * angular module. These are common to every test in the suite.
2580
- *
2581
- * This may only be called once, to set up the common providers for the current test
2582
- * suite on the current platform. If you absolutely need to change the providers,
2583
- * first use `resetTestEnvironment`.
2584
- *
2585
- * Test modules and platforms for individual platforms are available from
2586
- * '@angular/<platform_name>/testing'.
2587
- */
2588
- TestBedViewEngine.prototype.initTestEnvironment = function (ngModule, platform, summariesOrOptions) {
2589
- if (this.platform || this.ngModule) {
2590
- throw new Error('Cannot set base providers because it has already been called');
2591
- }
2592
- this.platform = platform;
2593
- this.ngModule = ngModule;
2594
- if (typeof summariesOrOptions === 'function') {
2595
- this._testEnvAotSummaries = summariesOrOptions;
2596
- TestBedViewEngine._environmentTeardownOptions = undefined;
2597
- }
2598
- else {
2599
- this._testEnvAotSummaries = (summariesOrOptions === null || summariesOrOptions === void 0 ? void 0 : summariesOrOptions.aotSummaries) || (function () { return []; });
2600
- TestBedViewEngine._environmentTeardownOptions = summariesOrOptions === null || summariesOrOptions === void 0 ? void 0 : summariesOrOptions.teardown;
2601
- }
2602
- };
2603
- /**
2604
- * Reset the providers for the test injector.
2605
- */
2606
- TestBedViewEngine.prototype.resetTestEnvironment = function () {
2607
- this.resetTestingModule();
2608
- this.platform = null;
2609
- this.ngModule = null;
2610
- this._testEnvAotSummaries = function () { return []; };
2611
- TestBedViewEngine._environmentTeardownOptions = undefined;
2612
- };
2613
- TestBedViewEngine.prototype.resetTestingModule = function () {
2614
- core.ɵclearOverrides();
2615
- this._aotSummaries = [];
2616
- this._templateOverrides = [];
2617
- this._compiler = null;
2618
- this._moduleOverrides = [];
2619
- this._componentOverrides = [];
2620
- this._directiveOverrides = [];
2621
- this._pipeOverrides = [];
2622
- this._isRoot = true;
2623
- this._rootProviderOverrides = [];
2624
- this._moduleFactory = null;
2625
- this._pendingModuleFactory = null;
2626
- this._compilerOptions = [];
2627
- this._providers = [];
2628
- this._declarations = [];
2629
- this._imports = [];
2630
- this._schemas = [];
2631
- // We have to chain a couple of try/finally blocks, because each step can
2632
- // throw errors and we don't want it to interrupt the next step and we also
2633
- // want an error to be thrown at the end.
2634
- try {
2635
- this.destroyActiveFixtures();
2636
- }
2637
- finally {
2638
- try {
2639
- if (this.shouldTearDownTestingModule()) {
2640
- this.tearDownTestingModule();
2641
- }
2642
- }
2643
- finally {
2644
- this._moduleRef = null;
2645
- this._instanceTeardownOptions = undefined;
2646
- this._instantiated = false;
2647
- }
2648
- }
2649
- };
2650
- TestBedViewEngine.prototype.configureCompiler = function (config) {
2651
- this._assertNotInstantiated('TestBed.configureCompiler', 'configure the compiler');
2652
- this._compilerOptions.push(config);
2653
- };
2654
- TestBedViewEngine.prototype.configureTestingModule = function (moduleDef) {
2655
- var _f, _g, _h, _j;
2656
- this._assertNotInstantiated('TestBed.configureTestingModule', 'configure the test module');
2657
- if (moduleDef.providers) {
2658
- (_f = this._providers).push.apply(_f, __spreadArray([], __read(moduleDef.providers), false));
2659
- }
2660
- if (moduleDef.declarations) {
2661
- (_g = this._declarations).push.apply(_g, __spreadArray([], __read(moduleDef.declarations), false));
2662
- }
2663
- if (moduleDef.imports) {
2664
- (_h = this._imports).push.apply(_h, __spreadArray([], __read(moduleDef.imports), false));
2665
- }
2666
- if (moduleDef.schemas) {
2667
- (_j = this._schemas).push.apply(_j, __spreadArray([], __read(moduleDef.schemas), false));
2668
- }
2669
- if (moduleDef.aotSummaries) {
2670
- this._aotSummaries.push(moduleDef.aotSummaries);
2671
- }
2672
- // Always re-assign the teardown options, even if they're undefined.
2673
- // This ensures that we don't carry the options between tests.
2674
- this._instanceTeardownOptions = moduleDef.teardown;
2675
- };
2676
- TestBedViewEngine.prototype.compileComponents = function () {
2677
- var _this = this;
2678
- if (this._moduleFactory || this._instantiated) {
2679
- return Promise.resolve(null);
2680
- }
2681
- var moduleType = this._createCompilerAndModule();
2682
- this._pendingModuleFactory = moduleType;
2683
- return this._compiler.compileModuleAndAllComponentsAsync(moduleType).then(function (result) {
2684
- // If the module mismatches by the time the promise resolves, it means that the module has
2685
- // already been destroyed and a new compilation has started. If that's the case, avoid
2686
- // overwriting the module factory, because it can cause downstream errors.
2687
- if (_this._pendingModuleFactory === moduleType) {
2688
- _this._moduleFactory = result.ngModuleFactory;
2689
- _this._pendingModuleFactory = null;
2690
- }
2691
- });
2692
- };
2693
- TestBedViewEngine.prototype._initIfNeeded = function () {
2694
- var e_1, _f;
2695
- if (this._instantiated) {
2696
- return;
2697
- }
2698
- if (!this._moduleFactory) {
2699
- try {
2700
- var moduleType = this._createCompilerAndModule();
2701
- this._moduleFactory =
2702
- this._compiler.compileModuleAndAllComponentsSync(moduleType).ngModuleFactory;
2703
- }
2704
- catch (e) {
2705
- var errorCompType = this._compiler.getComponentFromError(e);
2706
- if (errorCompType) {
2707
- throw new Error("This test module uses the component " + core.ɵstringify(errorCompType) + " which is using a \"templateUrl\" or \"styleUrls\", but they were never compiled. " +
2708
- "Please call \"TestBed.compileComponents\" before your test.");
2709
- }
2710
- else {
2711
- throw e;
2712
- }
2713
- }
2714
- }
2715
- try {
2716
- for (var _g = __values(this._templateOverrides), _h = _g.next(); !_h.done; _h = _g.next()) {
2717
- var _j = _h.value, component = _j.component, templateOf = _j.templateOf;
2718
- var compFactory = this._compiler.getComponentFactory(templateOf);
2719
- core.ɵoverrideComponentView(component, compFactory);
2720
- }
2721
- }
2722
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2723
- finally {
2724
- try {
2725
- if (_h && !_h.done && (_f = _g.return)) _f.call(_g);
2726
- }
2727
- finally { if (e_1) throw e_1.error; }
2728
- }
2729
- var ngZone = new core.NgZone({ enableLongStackTrace: true, shouldCoalesceEventChangeDetection: false });
2730
- var providers = [{ provide: core.NgZone, useValue: ngZone }];
2731
- var ngZoneInjector = core.Injector.create({
2732
- providers: providers,
2733
- parent: this.platform.injector,
2734
- name: this._moduleFactory.moduleType.name
2735
- });
2736
- this._moduleRef = this._moduleFactory.create(ngZoneInjector);
2737
- // ApplicationInitStatus.runInitializers() is marked @internal to core. So casting to any
2738
- // before accessing it.
2739
- this._moduleRef.injector.get(core.ApplicationInitStatus).runInitializers();
2740
- this._instantiated = true;
2741
- };
2742
- TestBedViewEngine.prototype._createCompilerAndModule = function () {
2743
- var e_2, _f;
2744
- var _this = this;
2745
- var providers = this._providers.concat([{ provide: TestBed, useValue: this }]);
2746
- var declarations = __spreadArray(__spreadArray([], __read(this._declarations), false), __read(this._templateOverrides.map(function (entry) { return entry.templateOf; })), false);
2747
- var rootScopeImports = [];
2748
- var rootProviderOverrides = this._rootProviderOverrides;
2749
- if (this._isRoot) {
2750
- var RootScopeModule = /** @class */ (function () {
2751
- function RootScopeModule() {
2752
- }
2753
- return RootScopeModule;
2754
- }());
2755
- RootScopeModule.decorators = [
2756
- { type: core.NgModule, args: [{
2757
- providers: __spreadArray([], __read(rootProviderOverrides), false),
2758
- jit: true,
2759
- },] }
2760
- ];
2761
- rootScopeImports.push(RootScopeModule);
2762
- }
2763
- providers.push({ provide: core.ɵINJECTOR_SCOPE, useValue: this._isRoot ? 'root' : null });
2764
- var imports = [rootScopeImports, this.ngModule, this._imports];
2765
- var schemas = this._schemas;
2766
- var DynamicTestModule = /** @class */ (function () {
2767
- function DynamicTestModule() {
2768
- }
2769
- return DynamicTestModule;
2770
- }());
2771
- DynamicTestModule.decorators = [
2772
- { type: core.NgModule, args: [{ providers: providers, declarations: declarations, imports: imports, schemas: schemas, jit: true },] }
2773
- ];
2774
- var compilerFactory = this.platform.injector.get(TestingCompilerFactory);
2775
- this._compiler = compilerFactory.createTestingCompiler(this._compilerOptions);
2776
- try {
2777
- for (var _g = __values(__spreadArray([this._testEnvAotSummaries], __read(this._aotSummaries), false)), _h = _g.next(); !_h.done; _h = _g.next()) {
2778
- var summary = _h.value;
2779
- this._compiler.loadAotSummaries(summary);
2780
- }
2781
- }
2782
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
2783
- finally {
2784
- try {
2785
- if (_h && !_h.done && (_f = _g.return)) _f.call(_g);
2786
- }
2787
- finally { if (e_2) throw e_2.error; }
2788
- }
2789
- this._moduleOverrides.forEach(function (entry) { return _this._compiler.overrideModule(entry[0], entry[1]); });
2790
- this._componentOverrides.forEach(function (entry) { return _this._compiler.overrideComponent(entry[0], entry[1]); });
2791
- this._directiveOverrides.forEach(function (entry) { return _this._compiler.overrideDirective(entry[0], entry[1]); });
2792
- this._pipeOverrides.forEach(function (entry) { return _this._compiler.overridePipe(entry[0], entry[1]); });
2793
- return DynamicTestModule;
2794
- };
2795
- TestBedViewEngine.prototype._assertNotInstantiated = function (methodName, methodDescription) {
2796
- if (this._instantiated) {
2797
- throw new Error("Cannot " + methodDescription + " when the test module has already been instantiated. " +
2798
- ("Make sure you are not using `inject` before `" + methodName + "`."));
2799
- }
2800
- };
2801
- TestBedViewEngine.prototype.inject = function (token, notFoundValue, flags) {
2802
- this._initIfNeeded();
2803
- if (token === TestBed) {
2804
- return this;
2805
- }
2806
- // Tests can inject things from the ng module and from the compiler,
2807
- // but the ng module can't inject things from the compiler and vice versa.
2808
- var UNDEFINED = {};
2809
- var result = this._moduleRef.injector.get(token, UNDEFINED, flags);
2810
- return result === UNDEFINED ? this._compiler.injector.get(token, notFoundValue, flags) :
2811
- result;
2812
- };
2813
- /** @deprecated from v9.0.0 use TestBed.inject */
2814
- TestBedViewEngine.prototype.get = function (token, notFoundValue, flags) {
2815
- if (notFoundValue === void 0) { notFoundValue = core.Injector.THROW_IF_NOT_FOUND; }
2816
- if (flags === void 0) { flags = core.InjectFlags.Default; }
2817
- return this.inject(token, notFoundValue, flags);
2818
- };
2819
- TestBedViewEngine.prototype.execute = function (tokens, fn, context) {
2820
- var _this = this;
2821
- this._initIfNeeded();
2822
- var params = tokens.map(function (t) { return _this.inject(t); });
2823
- return fn.apply(context, params);
2824
- };
2825
- TestBedViewEngine.prototype.overrideModule = function (ngModule, override) {
2826
- this._assertNotInstantiated('overrideModule', 'override module metadata');
2827
- this._moduleOverrides.push([ngModule, override]);
2828
- };
2829
- TestBedViewEngine.prototype.overrideComponent = function (component, override) {
2830
- this._assertNotInstantiated('overrideComponent', 'override component metadata');
2831
- this._componentOverrides.push([component, override]);
2832
- };
2833
- TestBedViewEngine.prototype.overrideDirective = function (directive, override) {
2834
- this._assertNotInstantiated('overrideDirective', 'override directive metadata');
2835
- this._directiveOverrides.push([directive, override]);
2836
- };
2837
- TestBedViewEngine.prototype.overridePipe = function (pipe, override) {
2838
- this._assertNotInstantiated('overridePipe', 'override pipe metadata');
2839
- this._pipeOverrides.push([pipe, override]);
2840
- };
2841
- TestBedViewEngine.prototype.overrideProvider = function (token, provider) {
2842
- this._assertNotInstantiated('overrideProvider', 'override provider');
2843
- this.overrideProviderImpl(token, provider);
2844
- };
2845
- TestBedViewEngine.prototype.overrideProviderImpl = function (token, provider, deprecated) {
2846
- if (deprecated === void 0) { deprecated = false; }
2847
- var def = null;
2848
- if (typeof token !== 'string' && (def = core.ɵgetInjectableDef(token)) && def.providedIn === 'root') {
2849
- if (provider.useFactory) {
2850
- this._rootProviderOverrides.push({ provide: token, useFactory: provider.useFactory, deps: provider.deps || [] });
2851
- }
2852
- else {
2853
- this._rootProviderOverrides.push({ provide: token, useValue: provider.useValue });
2854
- }
2855
- }
2856
- var flags = 0;
2857
- var value;
2858
- if (provider.useFactory) {
2859
- flags |= 1024 /* TypeFactoryProvider */;
2860
- value = provider.useFactory;
2861
- }
2862
- else {
2863
- flags |= 256 /* TypeValueProvider */;
2864
- value = provider.useValue;
2865
- }
2866
- var deps = (provider.deps || []).map(function (dep) {
2867
- var depFlags = 0 /* None */;
2868
- var depToken;
2869
- if (Array.isArray(dep)) {
2870
- dep.forEach(function (entry) {
2871
- if (entry instanceof core.Optional) {
2872
- depFlags |= 2 /* Optional */;
2873
- }
2874
- else if (entry instanceof core.SkipSelf) {
2875
- depFlags |= 1 /* SkipSelf */;
2876
- }
2877
- else {
2878
- depToken = entry;
2879
- }
2880
- });
2881
- }
2882
- else {
2883
- depToken = dep;
2884
- }
2885
- return [depFlags, depToken];
2886
- });
2887
- core.ɵoverrideProvider({ token: token, flags: flags, deps: deps, value: value, deprecatedBehavior: deprecated });
2888
- };
2889
- TestBedViewEngine.prototype.overrideTemplateUsingTestingModule = function (component, template) {
2890
- this._assertNotInstantiated('overrideTemplateUsingTestingModule', 'override template');
2891
- var OverrideComponent = /** @class */ (function () {
2892
- function OverrideComponent() {
2893
- }
2894
- return OverrideComponent;
2895
- }());
2896
- OverrideComponent.decorators = [
2897
- { type: core.Component, args: [{ selector: 'empty', template: template, jit: true },] }
2898
- ];
2899
- this._templateOverrides.push({ component: component, templateOf: OverrideComponent });
2900
- };
2901
- TestBedViewEngine.prototype.createComponent = function (component) {
2902
- var _this = this;
2903
- this._initIfNeeded();
2904
- var componentFactory = this._compiler.getComponentFactory(component);
2905
- if (!componentFactory) {
2906
- throw new Error("Cannot create the component " + core.ɵstringify(component) + " as it was not imported into the testing module!");
2907
- }
2908
- // TODO: Don't cast as `InjectionToken<boolean>`, declared type is boolean[]
2909
- var noNgZone = this.inject(ComponentFixtureNoNgZone, false);
2910
- // TODO: Don't cast as `InjectionToken<boolean>`, declared type is boolean[]
2911
- var autoDetect = this.inject(ComponentFixtureAutoDetect, false);
2912
- var ngZone = noNgZone ? null : this.inject(core.NgZone, null);
2913
- var testComponentRenderer = this.inject(TestComponentRenderer);
2914
- var rootElId = "root" + _nextRootElementId$1++;
2915
- testComponentRenderer.insertRootElement(rootElId);
2916
- var initComponent = function () {
2917
- var componentRef = componentFactory.create(core.Injector.NULL, [], "#" + rootElId, _this._moduleRef);
2918
- return new ComponentFixture(componentRef, ngZone, autoDetect);
2919
- };
2920
- var fixture = !ngZone ? initComponent() : ngZone.run(initComponent);
2921
- this._activeFixtures.push(fixture);
2922
- return fixture;
2923
- };
2924
- TestBedViewEngine.prototype.destroyActiveFixtures = function () {
2925
- var errorCount = 0;
2926
- this._activeFixtures.forEach(function (fixture) {
2927
- try {
2928
- fixture.destroy();
2929
- }
2930
- catch (e) {
2931
- errorCount++;
2932
- console.error('Error during cleanup of component', {
2933
- component: fixture.componentInstance,
2934
- stacktrace: e,
2935
- });
2936
- }
2937
- });
2938
- this._activeFixtures = [];
2939
- if (errorCount > 0 && this.shouldRethrowTeardownErrors()) {
2940
- throw Error(errorCount + " " + (errorCount === 1 ? 'component' : 'components') + " " +
2941
- "threw errors during cleanup");
2942
- }
2943
- };
2944
- TestBedViewEngine.prototype.shouldRethrowTeardownErrors = function () {
2945
- var _a, _b;
2946
- var instanceOptions = this._instanceTeardownOptions;
2947
- var environmentOptions = TestBedViewEngine._environmentTeardownOptions;
2948
- // If the new teardown behavior hasn't been configured, preserve the old behavior.
2949
- if (!instanceOptions && !environmentOptions) {
2950
- return false;
2951
- }
2952
- // Otherwise use the configured behavior or default to rethrowing.
2953
- return (_b = (_a = instanceOptions === null || instanceOptions === void 0 ? void 0 : instanceOptions.rethrowErrors) !== null && _a !== void 0 ? _a : environmentOptions === null || environmentOptions === void 0 ? void 0 : environmentOptions.rethrowErrors) !== null && _b !== void 0 ? _b : true;
2954
- };
2955
- TestBedViewEngine.prototype.shouldTearDownTestingModule = function () {
2956
- var _a, _b, _c, _d;
2957
- return (_d = (_b = (_a = this._instanceTeardownOptions) === null || _a === void 0 ? void 0 : _a.destroyAfterEach) !== null && _b !== void 0 ? _b : (_c = TestBedViewEngine._environmentTeardownOptions) === null || _c === void 0 ? void 0 : _c.destroyAfterEach) !== null && _d !== void 0 ? _d : TEARDOWN_TESTING_MODULE_ON_DESTROY_DEFAULT;
2958
- };
2959
- TestBedViewEngine.prototype.tearDownTestingModule = function () {
2960
- var _a, _b, _c, _d, _e;
2961
- // If the module ref has already been destroyed, we won't be able to get a test renderer.
2962
- if (this._moduleRef === null) {
2963
- return;
2964
- }
2965
- // Resolve the renderer ahead of time, because we want to remove the root elements as the very
2966
- // last step, but the injector will be destroyed as a part of the module ref destruction.
2967
- var testRenderer = this.inject(TestComponentRenderer);
2968
- try {
2969
- this._moduleRef.destroy();
2970
- }
2971
- catch (e) {
2972
- if ((_d = (_b = (_a = this._instanceTeardownOptions) === null || _a === void 0 ? void 0 : _a.rethrowErrors) !== null && _b !== void 0 ? _b : (_c = TestBedViewEngine._environmentTeardownOptions) === null || _c === void 0 ? void 0 : _c.rethrowErrors) !== null && _d !== void 0 ? _d : true) {
2973
- throw e;
2974
- }
2975
- else {
2976
- console.error('Error during cleanup of a testing module', {
2977
- component: this._moduleRef.instance,
2978
- stacktrace: e,
2979
- });
2980
- }
2981
- }
2982
- finally {
2983
- (_e = testRenderer === null || testRenderer === void 0 ? void 0 : testRenderer.removeAllRootElements) === null || _e === void 0 ? void 0 : _e.call(testRenderer);
2984
- }
2985
- };
2986
- return TestBedViewEngine;
2987
- }());
2988
- /**
2989
- * @description
2990
- * Configures and initializes environment for unit testing and provides methods for
2991
- * creating components and services in unit tests.
2992
- *
2993
- * `TestBed` is the primary api for writing unit tests for Angular applications and libraries.
2994
- *
2995
- * Note: Use `TestBed` in tests. It will be set to either `TestBedViewEngine` or `TestBedRender3`
2996
- * according to the compiler used.
2997
- *
2998
- * @publicApi
2999
- */
3000
- var TestBed = core.ɵivyEnabled ? TestBedRender3 : TestBedViewEngine;
3001
- /**
3002
- * Returns a singleton of the applicable `TestBed`.
3003
- *
3004
- * It will be either an instance of `TestBedViewEngine` or `TestBedRender3`.
3005
- *
3006
- * @publicApi
3007
- */
3008
- var getTestBed = core.ɵivyEnabled ? _getTestBedRender3 : _getTestBedViewEngine;
3009
- var testBed$1;
3010
- function _getTestBedViewEngine() {
3011
- return testBed$1 = testBed$1 || new TestBedViewEngine();
3012
- }
3013
- /**
3014
- * Allows injecting dependencies in `beforeEach()` and `it()`.
3015
- *
3016
- * Example:
3017
- *
3018
- * ```
3019
- * beforeEach(inject([Dependency, AClass], (dep, object) => {
3020
- * // some code that uses `dep` and `object`
3021
- * // ...
3022
- * }));
3023
- *
3024
- * it('...', inject([AClass], (object) => {
3025
- * object.doSomething();
3026
- * expect(...);
3027
- * })
3028
- * ```
3029
- *
3030
- * @publicApi
3031
- */
3032
- function inject(tokens, fn) {
3033
- var testBed = getTestBed();
3034
- // Not using an arrow function to preserve context passed from call site
3035
- return function () {
3036
- return testBed.execute(tokens, fn, this);
3037
- };
3038
- }
3039
- /**
3040
- * @publicApi
3041
- */
3042
- var InjectSetupWrapper = /** @class */ (function () {
3043
- function InjectSetupWrapper(_moduleDef) {
3044
- this._moduleDef = _moduleDef;
3045
- }
3046
- InjectSetupWrapper.prototype._addModule = function () {
3047
- var moduleDef = this._moduleDef();
3048
- if (moduleDef) {
3049
- getTestBed().configureTestingModule(moduleDef);
3050
- }
3051
- };
3052
- InjectSetupWrapper.prototype.inject = function (tokens, fn) {
3053
- var self = this;
3054
- // Not using an arrow function to preserve context passed from call site
3055
- return function () {
3056
- self._addModule();
3057
- return inject(tokens, fn).call(this);
3058
- };
3059
- };
3060
- return InjectSetupWrapper;
3061
- }());
3062
- function withModule(moduleDef, fn) {
3063
- if (fn) {
3064
- // Not using an arrow function to preserve context passed from call site
3065
- return function () {
3066
- var testBed = getTestBed();
3067
- if (moduleDef) {
3068
- testBed.configureTestingModule(moduleDef);
3069
- }
3070
- return fn.apply(this);
3071
- };
3072
- }
3073
- return new InjectSetupWrapper(function () { return moduleDef; });
3074
- }
3075
-
3076
- /**
3077
- * @license
3078
- * Copyright Google LLC All Rights Reserved.
3079
- *
3080
- * Use of this source code is governed by an MIT-style license that can be
3081
- * found in the LICENSE file at https://angular.io/license
3082
- */
3083
- var _global = (typeof window === 'undefined' ? global : window);
3084
- // Reset the test providers and the fake async zone before each test.
3085
- if (_global.beforeEach) {
3086
- _global.beforeEach(getCleanupHook(false));
3087
- }
3088
- // We provide both a `beforeEach` and `afterEach`, because the updated behavior for
3089
- // tearing down the module is supposed to run after the test so that we can associate
3090
- // teardown errors with the correct test.
3091
- if (_global.afterEach) {
3092
- _global.afterEach(getCleanupHook(true));
3093
- }
3094
- function getCleanupHook(expectedTeardownValue) {
3095
- return function () {
3096
- if (TestBed.shouldTearDownTestingModule() ===
3097
- expectedTeardownValue) {
3098
- TestBed.resetTestingModule();
3099
- resetFakeAsyncZone();
3100
- }
3101
- };
3102
- }
3103
- /**
3104
- * This API should be removed. But doing so seems to break `google3` and so it requires a bit of
3105
- * investigation.
3106
- *
3107
- * A work around is to mark it as `@codeGenApi` for now and investigate later.
3108
- *
3109
- * @codeGenApi
3110
- */
3111
- // TODO(iminar): Remove this code in a safe way.
3112
- var __core_private_testing_placeholder__ = '';
3113
-
3114
- /**
3115
- * @license
3116
- * Copyright Google LLC All Rights Reserved.
3117
- *
3118
- * Use of this source code is governed by an MIT-style license that can be
3119
- * found in the LICENSE file at https://angular.io/license
3120
- */
3121
-
3122
- /**
3123
- * @license
3124
- * Copyright Google LLC All Rights Reserved.
3125
- *
3126
- * Use of this source code is governed by an MIT-style license that can be
3127
- * found in the LICENSE file at https://angular.io/license
3128
- */
3129
-
3130
- /**
3131
- * @license
3132
- * Copyright Google LLC All Rights Reserved.
3133
- *
3134
- * Use of this source code is governed by an MIT-style license that can be
3135
- * found in the LICENSE file at https://angular.io/license
3136
- */
3137
- // This file only reexports content of the `src` folder. Keep it that way.
3138
-
3139
- /**
3140
- * @license
3141
- * Copyright Google LLC All Rights Reserved.
3142
- *
3143
- * Use of this source code is governed by an MIT-style license that can be
3144
- * found in the LICENSE file at https://angular.io/license
3145
- */
3146
-
3147
- /**
3148
- * Generated bundle index. Do not edit.
3149
- */
3150
-
3151
- exports.ComponentFixture = ComponentFixture;
3152
- exports.ComponentFixtureAutoDetect = ComponentFixtureAutoDetect;
3153
- exports.ComponentFixtureNoNgZone = ComponentFixtureNoNgZone;
3154
- exports.InjectSetupWrapper = InjectSetupWrapper;
3155
- exports.TestBed = TestBed;
3156
- exports.TestComponentRenderer = TestComponentRenderer;
3157
- exports.__core_private_testing_placeholder__ = __core_private_testing_placeholder__;
3158
- exports.async = async;
3159
- exports.discardPeriodicTasks = discardPeriodicTasks;
3160
- exports.fakeAsync = fakeAsync;
3161
- exports.flush = flush;
3162
- exports.flushMicrotasks = flushMicrotasks;
3163
- exports.getTestBed = getTestBed;
3164
- exports.inject = inject;
3165
- exports.resetFakeAsyncZone = resetFakeAsyncZone;
3166
- exports.tick = tick;
3167
- exports.waitForAsync = waitForAsync;
3168
- exports.withModule = withModule;
3169
- exports.ɵMetadataOverrider = MetadataOverrider;
3170
- exports.ɵTestingCompiler = TestingCompiler;
3171
- exports.ɵTestingCompilerFactory = TestingCompilerFactory;
3172
- exports.ɵangular_packages_core_testing_testing_a = TestBedViewEngine;
3173
- exports.ɵangular_packages_core_testing_testing_b = TestBedRender3;
3174
- exports.ɵangular_packages_core_testing_testing_c = _getTestBedRender3;
3175
-
3176
- Object.defineProperty(exports, '__esModule', { value: true });
3177
-
3178
- })));
3179
- //# sourceMappingURL=core-testing.umd.js.map