From 5a3c9190dc0ed037ffca73db61404ff0f3ef2675 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Sat, 19 Feb 2011 20:13:50 -0800 Subject: correct hashchange event registration on window --- test/jqLiteSpec.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'test') diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js index e42e9f14..346017f1 100644 --- a/test/jqLiteSpec.js +++ b/test/jqLiteSpec.js @@ -224,6 +224,35 @@ describe('jqLite', function(){ }); describe('bind', function(){ + it('should bind to window on hashchange', function(){ + if (jqLite.fn) return; // don't run in jQuery + var eventFn; + var window = { + document: {}, + location: {}, + alert: noop, + setInterval: noop, + length:10, // pretend you are an array + addEventListener: function(type, fn){ + expect(type).toEqual('hashchange'); + eventFn = fn; + }, + removeEventListener: noop, + attachEvent: function(type, fn){ + expect(type).toEqual('onhashchange'); + eventFn = fn; + }, + detachEvent: noop + }; + var log; + var jWindow = jqLite(window).bind('hashchange', function(){ + log = 'works!'; + }); + eventFn({}); + expect(log).toEqual('works!'); + dealoc(jWindow); + }); + it('should bind to all elements and return functions', function(){ var selected = jqLite([a, b]); var log = ''; -- cgit v1.2.3