Skip to content

Instantly share code, notes, and snippets.

@drewbourne
Created March 2, 2011 22:32
Show Gist options
  • Save drewbourne/851909 to your computer and use it in GitHub Desktop.
Save drewbourne/851909 to your computer and use it in GitHub Desktop.
package org.mockolate.issues
{
import flash.external.ExternalInterface;
public class JSBridge
{
private static var instance:JSBridge;
private static var allowInstantionation:Boolean;
public static function getInstance():JSBridge
{
if (instance)
{
return JSBridge.instance;
}
else
{
allowInstantionation = true;
instance = new JSBridge()
allowInstantionation = false;
return instance;
}
}
public function JSBridge()
{
super();
}
public function send(... arguments):void
{
ExternalInterface.call.apply(null, arguments);
}
}
}
package org.mockolate.issues
{
import mockolate.runner.MockolateRule;
public class JSBridgeTest
{
[Rule]
public var mocks:MockolateRule = new MockolateRule();
[Mock(type="strict")]
public var jsBridge:JSBridge;
[Test]
public function testPanelOpenJS():void
{
var delegate:PanelOpenDelegate = new PanelOpenDelegate();
mocks.mock(jsBridge).method("send").args("prOpenPanel", 1, "CID");
delegate.jsBridge = jsBridge;
delegate.openPanelJS(1, "CID");
}
}
}
package org.mockolate.issues
{
public class PanelOpenDelegate
{
public var jsBridge:JSBridge;
public function openPanelJS(id:int, name:String):void
{
jsBridge.send("prOpenPanel", id, name);
}
}
}
@mikeycmccarthy
Copy link

Hey Drew,

Do you have mockolate on a maven repository somewhere or do you just have it installed locally?

Thanks,
Michael

@drewbourne
Copy link
Author

drewbourne commented May 5, 2011 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment