Add some spies on more jQuery functions

This commit is contained in:
Gaël Métais
2015-03-02 11:23:10 +01:00
parent 3756d1185f
commit 71d2e61551
@@ -68,7 +68,7 @@ exports.module = function(phantomas) {
'slideUp',
'slideToggle',
// generic events
// Generic events
'on',
'off',
'live',
@@ -79,7 +79,7 @@ exports.module = function(phantomas) {
'bind',
'unbind',
// more events
// More events
'blur',
'change',
'click',
@@ -106,7 +106,7 @@ exports.module = function(phantomas) {
'submit',
'unload',
// attributes
// Attributes
'attr',
'prop',
'removeAttr',
@@ -115,7 +115,23 @@ exports.module = function(phantomas) {
'hasClass',
'addClass',
'removeClass',
'toggleClass'
'toggleClass',
// Tree traversal
'children',
'closest',
'find',
'next',
'nextAll',
'nextUntil',
'offsetParent',
'parent',
'parents',
'parentsUntil',
'prev',
'prevAll',
'prevUntil',
'siblings'
];
// spy calls to jQuery functions
@@ -178,11 +194,12 @@ exports.module = function(phantomas) {
phantomas.addOffender('jQuerySizzleCalls', '%s (in %s)', selector, (phantomas.getDOMPath(context) || 'unknown'));
phantomas.enterContext({
type: 'jQuery - find',
type: 'jQuery - Sizzle call',
callDetails: {
context: {
length: this.length,
firstElementPath: phantomas.getDOMPath(context)
firstElementPath: phantomas.getDOMPath(context),
toto: this
},
arguments: [selector]
},
@@ -286,9 +303,14 @@ exports.module = function(phantomas) {
args[index] = arg;
});
// Differentiate between $('.foo') and $(...).find('.foo')
var functionNameDisplayed = functionName;
if (functionName === 'find' && this.prevObject === undefined) {
functionNameDisplayed = '$';
}
phantomas.enterContext({
type: 'jQuery - ' + functionName,
type: 'jQuery - ' + functionNameDisplayed,
callDetails: {
context: {
length: this.length,