UNPKG

@danielkalen/simplybind

Version:

Magically simple, framework-less one-way/two-way data binding for frontend/backend in ~5kb.

47 lines (34 loc) 1.24 kB
suite ".and", ()-> suiteSetup(restartSandbox) test "Allows to add additional publishers to a binding interface during stage 1", ()-> SimplyBind.defaultOptions.updateOnBind = false invokeCount = 0 SimplyBind('prop1').of(objectA) .and('prop2').of(objectA) .and('prop1').of(objectB) .and('prop2').of(objectB) .to ()-> invokeCount++ expect(invokeCount).to.equal 0 objectA.prop1 += 1 expect(invokeCount).to.equal 1 objectA.prop2 += 1 expect(invokeCount).to.equal 2 objectB.prop1 += 1 objectB.prop2 += 1 expect(invokeCount).to.equal 4 SimplyBind.defaultOptions.updateOnBind = true restartSandbox() test "Allows to bind a publisher to additional subscribers during stage 2", ()-> SimplyBind('prop1').of(objectA) .to('prop1').of(objectB) .and.to('prop2').of(objectB) .and.to('prop3').of(objectB) .and.to('prop4').of(objectB) expect ()-> SimplyBind('prop').of(objectA).to('prop').of(objectB).to('prop').of(objectC) .to.throw() objectA.prop1 = 'all at once' expect(objectB.prop1).to.equal 'all at once' expect(objectB.prop2).to.equal 'all at once' expect(objectB.prop3).to.equal 'all at once' expect(objectB.prop4).to.equal 'all at once' restartSandbox()