@danielkalen/simplybind
Version:
Magically simple, framework-less one-way/two-way data binding for frontend/backend in ~5kb.
38 lines (24 loc) • 984 B
text/coffeescript
suite "SimplyBind.unBindAll", ()->
import ./one-direction
import ./two-direction
test "Passing objects that were never bound to anything should have no effects and shouldn't trigger any errors", ()->
expect(()->
SimplyBind.unBindAll 'nonbinded': 'object'
SimplyBind.unBindAll 'string'
SimplyBind('prop1').of(objectA).to ()->
SimplyBind.unBindAll objectA
SimplyBind.unBindAll objectA
).not.to.throw()
restartSandbox()
test "Destruction of the binding is guaranteed if the binding doesn't have any subscribers or publishers", ()->
SimplyBind('prop1').of(objectA)
.to('prop1').of(objectB).bothWays()
SimplyBind.unBindAll(objectA)
expect(objectA._sb_map).not.to.be.undefined
expect(objectB._sb_map).not.to.be.undefined
SimplyBind('prop1').of(objectA)
.to('prop1').of(objectB).bothWays()
SimplyBind.unBindAll(objectA, true)
expect(objectA._sb_map).to.be.undefined
expect(objectB._sb_map).to.be.undefined
restartSandbox()