var ArrayAssert = Y.ArrayAssert,
ObjectAssert = Y.ObjectAssert,
// -- Global Suite -------------------------------------------------------------
// -- View Suite ---------------------------------------------------------------
// -- View: Lifecycle ----------------------------------------------------------
name: 'Lifecycle',
'container should be a <div> node by default': function () {
},
'default container should be created lazily': function () {
var calls = {
attachEvents: 0,
create: 0
},
attachEvents: function () {
},
create: function () {
}
});
a = new MyView();
Assert.areSame(0, calls.attachEvents, 'attachEvents() should not be called before the container is retrieved');
a.get('container');
Assert.areSame(1, calls.create, 'create() should be called the first time the container is retrieved');
Assert.areSame(1, calls.attachEvents, 'attachEvents() should be called the first time the container is retrieved');
a.get('container');
},
'container events should be attached lazily when specified via a valueFn': function () {
var calls = {
attachEvents: 0,
create: 0
},
attachEvents: function () {
},
create: function () {
}
}, {
ATTRS: {
container: {
valueFn: function () {
}
}
}
});
a = new MyView();
Assert.areSame(0, calls.attachEvents, 'attachEvents() should not be called before the container is retrieved');
Assert.areSame('valuefn-container', a.get('container').get('className'), "container's CSS class should be 'valuefn-container'");
Assert.areSame(1, calls.attachEvents, 'attachEvents() should be called the first time the container is retrieved');
a.get('container');
},
'container events should be attached lazily when specified via an attr value': function () {
var calls = {
attachEvents: 0,
create: 0
},
attachEvents: function () {
},
create: function () {
}
}, {
ATTRS: {
container: {
}
}
});
a = new MyView();
Assert.areSame(0, calls.attachEvents, 'attachEvents() should not be called before the container is retrieved');
Assert.areSame('value-container', a.get('container').get('className'), "container's CSS class should be 'value-container'");
Assert.areSame(1, calls.attachEvents, 'attachEvents() should be called the first time the container is retrieved');
a.get('container');
},
'events property should be an empty object by default': function () {
},
'initializer should allow setting a ad-hoc attrs': function () {
},
'initializer should allow setting a containerTemplate at init': function () {
Assert.isUndefined(view.get('containerTemplate'), 'containerTemplate config should not become an ad-hoc attr');
},
'initializer should allow setting events at init': function () {
var events = {
'.foo': {
click: '_onFooClick'
}
},
},
'initializer should allow setting a template at init': function () {
var template = {},
},
'create() should not be called on init': function () {
create: function () {
}
});
new TestView();
},
'destructor should not remove the container by default': function () {
},
'destructor should remove the container from the DOM if `remove` options is truthy': function () {
}
}));
name: 'Attributes',
'attachEvents() should be called when the container attr changes': function () {
var calls = 0,
attachEvents: function (events) {
calls += 1;
// Ensure that events specified at instantiation time are
// merged into any default events, rather than overwriting
// all default events.
}
});
}
}));
name: 'Methods',
'create() should create and return a container node': function () {
},
'remove() should remove the container node from the DOM': function () {
},
'render() should be a chainable noop': function () {
}
}));
}, '@VERSION@', {
});