Skip to content

Instantly share code, notes, and snippets.

@mibalan
Created September 21, 2012 12:29
Show Gist options
  • Save mibalan/3761208 to your computer and use it in GitHub Desktop.
Save mibalan/3761208 to your computer and use it in GitHub Desktop.
/* Desired format for test */
test("Foo test", function() {
var obj = document.getFooObject();
if (ok(obj.someMethod, "FooObject implements <someMethod>")) {
var result = obj.someMethod();
equal(result.length, 42, "Result has proper length");
equal(result.bar, "BAZ", "The bar is where it should be");
}
})
/* This gets currently written as such */
test("Foo test", function() {
var obj = document.getFooObject();
ok(obj.someMethod, "FooObject implements <someMethod>");
var methodSupported = !!obj.someMethod;
if (methodSupported) {
var result = obj.someMethod();
equal(result.length, 42, "Result has proper length");
equal(result.bar, "BAZ", "The bar is where it should be");
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment