Tagjavascript

How to assert.throws on an async function with a callback

H

Recently, I was writing a module that took a callback, and needed to write a test, asserting on an exception. Here’s how to do it: JavaScript it('throws error if myParam is less than 10', function(done) { var fn = function(){ myModule.doSomething(8, function(err) { if (err) throw err }); } assert.throws( function() { fn() }, /Value is less than 10/ ) done(); }); 12345678910 it('throws error if...

Using custom options with KnockoutJS Drag and Drop

U

I was recently doing some work involving Knockout and needed to implement drag / drop (with jQuery UI draggable and droppable) I stumbled across this post from Wilsonhut that shows how to use custom binding to attach drag and drop functionality to your view model. Since that post (and previous posts in the series) covers that in detail, I won’t elaborate. However, I had a requirement to be...

Syntax error using Yahoo YUI Compressor .net port – works using java version

S

Recently, I was tasked with creating a minified version of a web applications Javascript files. I settled on the Yahoo YUI Compressor, in particular, the .net port of it When I tried to compress a particular file (the jquery.caret plugin), it would throw up a syntax error. This error only occurred using the .net port of Yahoo YUI Compressor. Using the standard java jar version of YUI Compressor...