Skip to content

Commit

Permalink
__noSuchMethod__ test
Browse files Browse the repository at this point in the history
  • Loading branch information
charliesome committed Jan 20, 2012
1 parent 8033f4f commit c29d423
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/extensions.js
@@ -0,0 +1,26 @@
test("__noSuchMethod__", function() {
var obj = {};
var called = false;
obj.__noSuchMethod__ = function(id, args) {
called = true;
assert_equal("foo", id);
assert_equal(2, args.length);
assert_equal("bar", args[0]);
assert_equal("baz", args[1]);
};
obj.foo("bar", "baz");
assert(called);
});

test("__noSuchMethod__ is called if prop exists but is not callable", function() {
var obj = {};
var called = false;
obj.foo = 123;
obj.__noSuchMethod__ = function(id, args) {
called = true;
assert_equal(123, this.foo);
};
assert_equal(123, obj.foo);
obj.foo();
assert(called);
});

0 comments on commit c29d423

Please sign in to comment.