event-valuechange-test.js revision 036fab074da81060fb60b59d53e8098aea321ea4
ArrayAssert = Y.ArrayAssert,
// -- Basic Subscriptions ------------------------------------------------------
name: 'Basic',
_should: {
ignore: {
// fail. Have to rely on manual testing.
'valuechange should stop polling on blur': ignoreFocus,
'valuechange should start polling on focus': ignoreFocus,
'valuechange should not report stale changes that occurred while a node was not focused': ignoreFocus
}
},
setUp: function () {
},
tearDown: function () {
},
'valuechange event should start polling on mousedown and fire an event when the value changes': function () {
var test = this;
});
});
this.wait(100);
},
'valuechange should support textareas as well': function () {
var test = this;
});
});
this.wait(100);
},
'valuechange should start polling on keydown': function () {
var test = this;
});
this.wait(100);
},
'valuechange should stop polling on blur': function () {
var fired;
fired = true;
});
this.wait(function () {
fired = false;
this.wait(function () {
}, 100);
}, 100);
},
'valuechange should start polling on focus': function () {
var test = this;
});
this.wait(100);
},
'valuechange should not report stale changes that occurred while a node was not focused': function () {
var fired = false;
fired = true;
});
this.wait(function () {
}, 100);
},
'valuechange should start polling on keyup for IME keystrokes': function () {
var fired = false;
fired = true;
});
this.wait(function () {
this.wait(function () {
fired = false;
this.wait(function () {
}, 100);
}, 100);
}, 100);
},
'valuechange should stop polling after timeout': function () {
fired = true;
});
this.wait(function () {
fired = false;
this.wait(function () {
this.wait(function () {
}, 60);
}, 71);
}, 60);
},
'valueChange should be an alias for valuechange for backcompat': function () {
var test = this;
});
this.wait(100);
}
}));
// -- Delegation ---------------------------------------------------------------
name: 'Delegation',
setUp: function () {
.append('<input type="text" id="vc-delegate-a" class="odd">')
.append('<input type="text" id="vc-delegate-b" class="even">')
.append('<input type="text" id="vc-delegate-c" class="odd">')
.append('<textarea id="vc-delegate-d" class="even"></textarea>')
.append('<textarea id="vc-delegate-e" class="odd"></textarea>')
.append('<textarea id="vc-delegate-f" class="even"></textarea>');
this.a = Y.one('#vc-delegate-a');
this.b = Y.one('#vc-delegate-b');
this.c = Y.one('#vc-delegate-c');
this.d = Y.one('#vc-delegate-d');
this.e = Y.one('#vc-delegate-e');
this.f = Y.one('#vc-delegate-f');
},
tearDown: function () {
},
'delegation should be supported on input nodes': function () {
var test = this;
Assert.areSame('input', e.currentTarget.get('nodeName').toLowerCase(), 'currentTarget should be the input node');
});
}, '.odd');
this.a.simulate('mousedown');
this.wait(100);
},
'delegation should be supported on textareas': function () {
var test = this;
Assert.areSame('textarea', e.currentTarget.get('nodeName').toLowerCase(), 'currentTarget should be the textarea node');
Assert.areSame('textarea', e.target.get('nodeName').toLowerCase(), 'target should be the textarea node');
});
}, '.even');
this.f.simulate('mousedown');
this.wait(100);
},
'delegate filters should work properly': function () {
var test = this;
}, '.even');
});
}, '.odd');
this.b.simulate('mousedown');
this.wait(100);
},
'multiple delegated handlers should be supported': function () {
var calls = [],
test = this;
}, '.odd');
});
}, '.even');
}, '.odd,.even');
}, 'input');
this.c.simulate('mousedown');
this.wait(function () {
ArrayAssert.itemsAreSame(['one', 'two', 'three'], calls, 'delegated handlers should all be called in the correct order');
}, 100);
}
}));