more tests
This commit is contained in:
+25
-12
@@ -21,7 +21,7 @@ class BaseTest extends BuddySuite {
|
||||
callNum = 0;
|
||||
});
|
||||
|
||||
it ("bindx should bind/unbind properties (lazySignal=true)", {
|
||||
it ("bindx should bind/unbind fields (lazySignal=true)", {
|
||||
var strFrom = b.str = "a";
|
||||
var callNum2 = 0;
|
||||
|
||||
@@ -51,7 +51,7 @@ class BaseTest extends BuddySuite {
|
||||
callNum2.should.be(1);
|
||||
});
|
||||
|
||||
it ("bindx should bind/unbind properties (lazySignal=false)", {
|
||||
it ("bindx should bind/unbind fields (lazySignal=false)", {
|
||||
var strFrom = b.str2 = "a";
|
||||
var callNum2 = 0;
|
||||
|
||||
@@ -137,6 +137,9 @@ class BaseTest extends BuddySuite {
|
||||
callNum2.should.be(1);
|
||||
});
|
||||
|
||||
it("bindx should bind 2 objects (lazySignal=true)");
|
||||
it("bindx should bind 2 objects (lazySignal=false)");
|
||||
|
||||
it("bindx should bind and notify methods (lazySignal=true)", {
|
||||
var listener = function () callNum++;
|
||||
bind(b.bind, listener);
|
||||
@@ -217,16 +220,21 @@ class BaseTest extends BuddySuite {
|
||||
|
||||
it("bindx should unbind all bindings (signal exists) (lazySignal=true/false)", {
|
||||
bind(b.str, function (_, _) callNum++); // create binding signal
|
||||
bind(b.str2, function (_, _) callNum++); // create binding signal
|
||||
bind(b.str2, function (_, _) callNum++);
|
||||
bind(b.bind, function () callNum++);
|
||||
bind(b.bind2, function () callNum++);
|
||||
|
||||
Bind.unbindAll(b);
|
||||
|
||||
b.str = b.str + "1";
|
||||
b.str2 = b.str2 + "1";
|
||||
Bind.notify(b.bind);
|
||||
Bind.notify(b.bind2);
|
||||
try {
|
||||
b.str = b.str + "1";
|
||||
b.str2 = b.str2 + "1";
|
||||
Bind.notify(b.bind);
|
||||
Bind.notify(b.bind2);
|
||||
}
|
||||
catch (e:Dynamic) {
|
||||
fail();
|
||||
}
|
||||
|
||||
callNum.should.be(0);
|
||||
});
|
||||
@@ -234,12 +242,17 @@ class BaseTest extends BuddySuite {
|
||||
it("bindx should unbind all bindings (signal expected) (lazySignal=true/false)", {
|
||||
Bind.unbindAll(b);
|
||||
|
||||
b.str = b.str + "1";
|
||||
b.str2 = b.str2 + "1";
|
||||
Bind.notify(b.bind);
|
||||
Bind.notify(b.bind2);
|
||||
try {
|
||||
b.str = b.str + "1";
|
||||
b.str2 = b.str2 + "1";
|
||||
Bind.notify(b.bind);
|
||||
Bind.notify(b.bind2);
|
||||
}
|
||||
catch (e:Dynamic) {
|
||||
fail();
|
||||
}
|
||||
|
||||
callNum.should.be(0);
|
||||
true.should.be(true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package ;
|
||||
|
||||
import bindx.Bind;
|
||||
import bindx.Bind.bind in bind;
|
||||
import buddy.*;
|
||||
|
||||
using buddy.Should;
|
||||
|
||||
class SignalTest extends BuddySuite {
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
|
||||
describe("BindSignal functionality tests", {
|
||||
it("signals should dispatch data");
|
||||
});
|
||||
}
|
||||
}
|
||||
+30
-7
@@ -1,13 +1,24 @@
|
||||
package ;
|
||||
|
||||
import bindx.Bind;
|
||||
import bindx.Bind.bind in bind;
|
||||
import buddy.*;
|
||||
|
||||
class TestProperty extends haxe.unit.TestCase {
|
||||
using buddy.Should;
|
||||
|
||||
class TestProperty extends BuddySuite {
|
||||
public function new() {
|
||||
super();
|
||||
|
||||
describe("Bindx modify field setter", {
|
||||
it("bindx should bind/unbind fields with setter (lazySignal=true)");
|
||||
it("bindx should bind/unbind fields with setter (lazySignal=false)");
|
||||
it("bindx should bind 2 objects (custom setter) (lazySignal=true)");
|
||||
it("bindx should bind 2 objects (custom setter) (lazySignal=false)");
|
||||
});
|
||||
}
|
||||
|
||||
function test1() {
|
||||
/*function test1() {
|
||||
var p = new BindableProperty();
|
||||
p.s = "1";
|
||||
var callNum = 0;
|
||||
@@ -40,20 +51,32 @@ class TestProperty extends haxe.unit.TestCase {
|
||||
p.s = "123";
|
||||
assertEquals(t.a, p.s);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
class BindableProperty implements bindx.IBindable {
|
||||
public function new() {
|
||||
}
|
||||
|
||||
@:bindable
|
||||
public var s(default, set):String;
|
||||
@:bindable(lazySignal=true)
|
||||
public var str(default, set):String;
|
||||
|
||||
function set_s(v) {
|
||||
function set_str(v) {
|
||||
if (v == null) {
|
||||
return s = "";
|
||||
return str = "";
|
||||
}
|
||||
s = v;
|
||||
str = v;
|
||||
return v;
|
||||
}
|
||||
|
||||
@:bindable(lazySignal=false)
|
||||
public var str2(default, set):String;
|
||||
|
||||
function set_str2(v) {
|
||||
if (v == null) {
|
||||
return str2 = "";
|
||||
}
|
||||
str2 = v;
|
||||
return v;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user