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

Function $$TestabilityProvider

lib/test/angular/1.7.0/angular.js:20718–20831  ·  view source on GitHub ↗

@this

()

Source from the content-addressed store, hash-verified

20716
20717/** @this */
20718function $$TestabilityProvider() {
20719 this.$get = ['$rootScope', '$browser', '$location',
20720 function($rootScope, $browser, $location) {
20721
20722 /**
20723 * @name $testability
20724 *
20725 * @description
20726 * The private $$testability service provides a collection of methods for use when debugging
20727 * or by automated test and debugging tools.
20728 */
20729 var testability = {};
20730
20731 /**
20732 * @name $$testability#findBindings
20733 *
20734 * @description
20735 * Returns an array of elements that are bound (via ng-bind or {{}})
20736 * to expressions matching the input.
20737 *
20738 * @param {Element} element The element root to search from.
20739 * @param {string} expression The binding expression to match.
20740 * @param {boolean} opt_exactMatch If true, only returns exact matches
20741 * for the expression. Filters and whitespace are ignored.
20742 */
20743 testability.findBindings = function(element, expression, opt_exactMatch) {
20744 var bindings = element.getElementsByClassName('ng-binding');
20745 var matches = [];
20746 forEach(bindings, function(binding) {
20747 var dataBinding = angular.element(binding).data('$binding');
20748 if (dataBinding) {
20749 forEach(dataBinding, function(bindingName) {
20750 if (opt_exactMatch) {
20751 var matcher = new RegExp('(^|\\s)' + escapeForRegexp(expression) + '(\\s|\\||$)');
20752 if (matcher.test(bindingName)) {
20753 matches.push(binding);
20754 }
20755 } else {
20756 if (bindingName.indexOf(expression) !== -1) {
20757 matches.push(binding);
20758 }
20759 }
20760 });
20761 }
20762 });
20763 return matches;
20764 };
20765
20766 /**
20767 * @name $$testability#findModels
20768 *
20769 * @description
20770 * Returns an array of elements that are two-way found via ng-model to
20771 * expressions matching the input.
20772 *
20773 * @param {Element} element The element root to search from.
20774 * @param {string} expression The model expression to match.
20775 * @param {boolean} opt_exactMatch If true, only returns exact matches

Callers

nothing calls this directly

Calls 2

forEachFunction · 0.70
escapeForRegexpFunction · 0.70

Tested by

no test coverage detected