<html>
<head>
<title>YUI AOP Tests</title>
</head>
<body class="yui3-skin-sam">
<h1>AOP Tests</h1>
<p><input type="button" value="Run Tests" id="btnRun" disabled="true" /></p>
<script type="text/javascript">
(function() {
YUI({
base: "/build/",
filter: (window.location.search.match(/[?&]filter=([^&]+)/) || [])[1] || 'min',
allowRollup: false,
useConsole: true,
// logInclude: ['event', 'test']
logExclude: {Dom: true, Selector: true, Node: true, attribute: true, base: true, event: true, widget: true}
}).use("dump", "test", "console", "event-custom", function(Y) {
var button = Y.one('#btnRun');
// Set up the page
button.set("disabled", false);
Y.on("click", function() {
}, button);
var myConsole = new Y.Console().render();
var testEventTarget = new Y.Test.Case({
name: "AOP tests",
_should: {
ignore: {
// Trac ticket noted as value
"test originalRetVal not overwritten by nested call": 2530030
}
},
test_alter_return: function() {
var et = new Y.EventTarget(), count = 0;
et.after(function() {
count++;
return new Y.Do.AlterReturn("altered return", "altered");
}, et, 'fire');
et.after(function() {
count++;
Y.Assert.areEqual("altered", Y.Do.currentRetVal);
}, et, 'fire');
et.fire('yay');
Y.Assert.areEqual(2, count);
},
"test originalRetVal not overwritten by nested call": function () {
var obj = {
a: function () {
this.b();
return 'A';
},
b: function () {
return 'B';
}
}
Y.Do.after(function () {
return Y.Do.originalRetVal.toLowerCase();
}, obj, 'a');
Y.Do.after(function () {
// It doesn't matter what happens here, but for example, we
// don't interfere with the return value
}, obj, 'b');
Y.Assert.areSame('a', obj.a());
}
});
Y.Test.Runner.setName("AOP");
Y.Test.Runner.add(testEventTarget);
});
})();
</script>
</body>
</html>