MCPcopy Create free account
hub / github.com/angular-ui/ui-router / $$TestabilityProvider

Function $$TestabilityProvider

test/angular/1.6/angular.js:20654–20767  ·  view source on GitHub ↗

@this

()

Source from the content-addressed store, hash-verified

20652
20653/** @this */
20654function $$TestabilityProvider() {
20655 this.$get = ['$rootScope', '$browser', '$location',
20656 function($rootScope, $browser, $location) {
20657
20658 /**
20659 * @name $testability
20660 *
20661 * @description
20662 * The private $$testability service provides a collection of methods for use when debugging
20663 * or by automated test and debugging tools.
20664 */
20665 var testability = {};
20666
20667 /**
20668 * @name $$testability#findBindings
20669 *
20670 * @description
20671 * Returns an array of elements that are bound (via ng-bind or {{}})
20672 * to expressions matching the input.
20673 *
20674 * @param {Element} element The element root to search from.
20675 * @param {string} expression The binding expression to match.
20676 * @param {boolean} opt_exactMatch If true, only returns exact matches
20677 * for the expression. Filters and whitespace are ignored.
20678 */
20679 testability.findBindings = function(element, expression, opt_exactMatch) {
20680 var bindings = element.getElementsByClassName('ng-binding');
20681 var matches = [];
20682 forEach(bindings, function(binding) {
20683 var dataBinding = angular.element(binding).data('$binding');
20684 if (dataBinding) {
20685 forEach(dataBinding, function(bindingName) {
20686 if (opt_exactMatch) {
20687 var matcher = new RegExp('(^|\\s)' + escapeForRegexp(expression) + '(\\s|\\||$)');
20688 if (matcher.test(bindingName)) {
20689 matches.push(binding);
20690 }
20691 } else {
20692 if (bindingName.indexOf(expression) !== -1) {
20693 matches.push(binding);
20694 }
20695 }
20696 });
20697 }
20698 });
20699 return matches;
20700 };
20701
20702 /**
20703 * @name $$testability#findModels
20704 *
20705 * @description
20706 * Returns an array of elements that are two-way found via ng-model to
20707 * expressions matching the input.
20708 *
20709 * @param {Element} element The element root to search from.
20710 * @param {string} expression The model expression to match.
20711 * @param {boolean} opt_exactMatch If true, only returns exact matches

Callers

nothing calls this directly

Calls 3

urlMethod · 0.80
forEachFunction · 0.70
escapeForRegexpFunction · 0.70

Tested by

no test coverage detected