From c40878365d541ef08f037b059bfca0b4604b679c Mon Sep 17 00:00:00 2001 From: jacobtoye Date: Wed, 19 Dec 2012 15:36:42 +1300 Subject: [PATCH] Fixing addInitHooks specs to test inherited hooks and child class' hooks. --- spec/suites/core/ClassSpec.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/spec/suites/core/ClassSpec.js b/spec/suites/core/ClassSpec.js index 59bfb186..e60e629c 100644 --- a/spec/suites/core/ClassSpec.js +++ b/spec/suites/core/ClassSpec.js @@ -123,20 +123,30 @@ describe("Class", function() { var spy1 = jasmine.createSpy("init hook 1"), spy2 = jasmine.createSpy("init hook 2"); + var Klass2 = Klass.extend({}); + Klass.addInitHook(spy1); + Klass2.addInitHook(spy2); + + var a = new Klass2(); + + expect(spy1).toHaveBeenCalled(); + expect(spy2).toHaveBeenCalled(); + }); + + it("should not call child constructor hooks", function () { + var spy1 = jasmine.createSpy("init hook 1"), + spy2 = jasmine.createSpy("init hook 2"); var Klass2 = Klass.extend({}); + + Klass.addInitHook(spy1); Klass2.addInitHook(spy2); var a = new Klass(); expect(spy1).toHaveBeenCalled(); expect(spy2).not.toHaveBeenCalled(); - - var b = new Klass2(); - - expect(spy2).toHaveBeenCalled(); - expect(spy1.argsForCall.length).toBe(2); }); });