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

Function $$TestabilityProvider

test/angular/1.5/angular.js:19775–19888  ·  view source on GitHub ↗

@this

()

Source from the content-addressed store, hash-verified

19773
19774/** @this */
19775function $$TestabilityProvider() {
19776 this.$get = ['$rootScope', '$browser', '$location',
19777 function($rootScope, $browser, $location) {
19778
19779 /**
19780 * @name $testability
19781 *
19782 * @description
19783 * The private $$testability service provides a collection of methods for use when debugging
19784 * or by automated test and debugging tools.
19785 */
19786 var testability = {};
19787
19788 /**
19789 * @name $$testability#findBindings
19790 *
19791 * @description
19792 * Returns an array of elements that are bound (via ng-bind or {{}})
19793 * to expressions matching the input.
19794 *
19795 * @param {Element} element The element root to search from.
19796 * @param {string} expression The binding expression to match.
19797 * @param {boolean} opt_exactMatch If true, only returns exact matches
19798 * for the expression. Filters and whitespace are ignored.
19799 */
19800 testability.findBindings = function(element, expression, opt_exactMatch) {
19801 var bindings = element.getElementsByClassName('ng-binding');
19802 var matches = [];
19803 forEach(bindings, function(binding) {
19804 var dataBinding = angular.element(binding).data('$binding');
19805 if (dataBinding) {
19806 forEach(dataBinding, function(bindingName) {
19807 if (opt_exactMatch) {
19808 var matcher = new RegExp('(^|\\s)' + escapeForRegexp(expression) + '(\\s|\\||$)');
19809 if (matcher.test(bindingName)) {
19810 matches.push(binding);
19811 }
19812 } else {
19813 if (bindingName.indexOf(expression) !== -1) {
19814 matches.push(binding);
19815 }
19816 }
19817 });
19818 }
19819 });
19820 return matches;
19821 };
19822
19823 /**
19824 * @name $$testability#findModels
19825 *
19826 * @description
19827 * Returns an array of elements that are two-way found via ng-model to
19828 * expressions matching the input.
19829 *
19830 * @param {Element} element The element root to search from.
19831 * @param {string} expression The model expression to match.
19832 * @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