UNPKG

este-library-oldschool

Version:

Library for github.com/steida/este.git

162 lines 4.83 kB
// Generated by github.com/steida/coffee2closure 900.1.18 suite('este.ui.Component', function() { var Component, component, el; Component = este.ui.Component; component = null; el = null; setup(function() { component = new Component; return el = document.createElement('div'); }); suite('constructor', function() { return test('should work', function() { return assert.instanceOf(component, Component); }); }); suite('off', function() { return test('should work on element', function() { var count, onClick; count = 0; onClick = function() { return count++; }; component.enterDocument(); component.on(el, 'click', onClick); component.off(el, 'click', onClick); goog.events.fireListeners(el, 'click', false, { type: 'click' }); return assert.equal(count, 0); }); }); return suite('bindModel', function() { suite('on component with collection', function() { test('should work for e-model-cid', function(done) { var event, original, target, wrapped; component.collection = new este.Collection; component.collection.findByClientId = function() { return 'foo'; }; original = function(model, el, e) { assert.equal(model, 'foo'); assert.equal(el, target); assert.equal(e, event); return done(); }; wrapped = component.bindModel(original); target = { nodeType: 1, attributes: { 'e-model-cid': '123' }, hasAttribute: function(name) { return name in this.attributes; }, getAttribute: function(name) { return this.attributes[name]; } }; event = { target: target }; return wrapped.call(component, event); }); return test('should work for data-e-model-cid', function(done) { var event, original, target, wrapped; component.collection = new este.Collection; component.collection.findByClientId = function() { return 'foo'; }; original = function(model, el, e) { assert.equal(model, 'foo'); assert.equal(el, target); assert.equal(e, event); return done(); }; wrapped = component.bindModel(original); target = { nodeType: 1, attributes: { 'data-e-model-cid': '123' }, hasAttribute: function(name) { return name in this.attributes; }, getAttribute: function(name) { return this.attributes[name]; } }; event = { target: target }; return wrapped.call(component, event); }); }); return suite('on component with model', function() { test('should work for e-model-cid', function(done) { var event, original, target, wrapped; component.model = new este.Model; component.model.get = function(attr) { if (attr === '_cid') { return '123'; } }; original = function(model, el, e) { assert.equal(model, component.model); assert.equal(el, target); assert.equal(e, event); return done(); }; wrapped = component.bindModel(original); target = { nodeType: 1, attributes: { 'e-model-cid': '123' }, hasAttribute: function(name) { return name in this.attributes; }, getAttribute: function(name) { return this.attributes[name]; } }; event = { target: target }; return wrapped.call(component, event); }); return test('should work for data-e-model-cid', function(done) { var event, original, target, wrapped; component.model = new este.Model; component.model.get = function(attr) { if (attr === '_cid') { return '123'; } }; original = function(model, el, e) { assert.equal(model, component.model); assert.equal(el, target); assert.equal(e, event); return done(); }; wrapped = component.bindModel(original); target = { nodeType: 1, attributes: { 'data-e-model-cid': '123' }, hasAttribute: function(name) { return name in this.attributes; }, getAttribute: function(name) { return this.attributes[name]; } }; event = { target: target }; return wrapped.call(component, event); }); }); }); });