Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Possible Node.js test for AMD support in ZeroClipboard
exports = {
"Test onLoad Event with AMD": function (test) {
test.expect(1);
var amdTester = (function() {
var amdCache = {
"zc": zeroClipboard
};
return function(depIds, cb) {
var depVals = depIds.map(function(id) { return amdCache[id]; });
process.nextTick(function() {
cb.apply(this, depVals);
});
};
})();
var clip = new zeroClipboard({
"amdLoaderName": "amdTester",
"amdModuleId": "zc"
});
clip.glue($("#d_clip_button"));
var id = clip.id;
clip.on( "load", function(client, args) {
test.equal(client.id, id);
test.done();
} );
// fake load event
eval(
'\
(function(eventName, args) {\
' + clip.options.amdLoaderName + '(["' + clip.options.amdModuleId + '"], function(ZeroClipboard) {\
ZeroClipboard.dispatch(eventName, args);\
});\
})("load", { flashVersion: "MAC 9,0,0" });\
'
);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment