Merge branch 'implement/testSubjectHelper' into fix/appSwitcher
This commit is contained in:
commit
e49e04565a
19
src/ui/public/jquery/findTestSubject.js
vendored
Normal file
19
src/ui/public/jquery/findTestSubject.js
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
module.exports = function bindToJquery($) {
|
||||
|
||||
$.fn.findTestSubject = function (/* ...subjectSelectors */) {
|
||||
var subjectSelectors = [].slice.apply(arguments);
|
||||
var $els = $();
|
||||
var $context = this;
|
||||
|
||||
subjectSelectors.forEach(function (subjects) {
|
||||
var selector = subjects.split(/\s+/).map(function (subject) {
|
||||
return '[data-test-subj~="' + subject + '"]';
|
||||
}).join(' ');
|
||||
|
||||
$els = $els.add($context.find(selector));
|
||||
});
|
||||
|
||||
return $els;
|
||||
};
|
||||
|
||||
};
|
3
webpackShims/jquery.js
vendored
3
webpackShims/jquery.js
vendored
|
@ -1 +1,2 @@
|
|||
window.jQuery = window.$ = module.exports = require('node_modules/jquery/dist/jquery');
|
||||
var $ = window.jQuery = window.$ = module.exports = require('node_modules/jquery/dist/jquery');
|
||||
require('ui/jquery/findTestSubject')($);
|
||||
|
|
Loading…
Reference in a new issue