Permalink
Browse files

fixes a bug in frame_interface for reinitialization.

  • Loading branch information...
1 parent 082eceb commit d4dc648686a724a33304aa104ecf839a75970e47 @jejacks0n committed Apr 7, 2013
@@ -12,6 +12,14 @@ class Mercury.FrameInterface extends Mercury.BaseInterface
return super
+ reinitialize: ->
+ if @frame.length
+ @initialized = false
+ @initializeFrame()
+ else
+ super
+
+
bindDefaultEvents: ->
@frame.on('load', => @initializeFrame())
Mercury.on('initialize', => @initializeFrame())
@@ -7,6 +7,7 @@ describe "Mercury.FrameInterface", ->
subject = null
beforeEach ->
+ Mercury.configure 'logging:enabled', false
spyOn($.fn, 'before')
spyOn(Klass::, 'focusActiveRegion')
subject = new Klass(frame: '<iframe>')
@@ -23,6 +24,30 @@ describe "Mercury.FrameInterface", ->
expect( Klass.__super__.initialize ).called
+ describe "#reinitialze", ->
+
+ describe "with frame", ->
+
+ beforeEach ->
+ spyOn(subject, 'initializeFrame')
+
+ it "resets @initialized", ->
+ subject.reinitialize()
+ expect( subject.initialized ).to.be.false
+
+ it "calls #initializeFrame", ->
+ subject.reinitialize()
+ expect( subject.initializeFrame ).called
+
+ describe "with fallback", ->
+
+ it "calls super", ->
+ subject.frame = []
+ spyOn(Klass.__super__, 'reinitialize')
+ subject.reinitialize()
+ expect( Klass.__super__.reinitialize ).called
+
+
describe "#bindDefaultEvents", ->
it "binds to @frame.load", ->

0 comments on commit d4dc648

Please sign in to comment.