Skip to content

Instantly share code, notes, and snippets.

@JamesMGreene
Last active February 11, 2024 22:53
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesMGreene/5555657 to your computer and use it in GitHub Desktop.
Save JamesMGreene/5555657 to your computer and use it in GitHub Desktop.
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