view-node-map-test.js revision da3fe82a6733256f64c8351879bba6730371b972
76bf9d78d0779795bbf4cf41abec4ff0300706b2Ryan Grovesuite = Y.AppTestSuite || (Y.AppTestSuite = new Y.Test.Suite('App Framework'));
76bf9d78d0779795bbf4cf41abec4ff0300706b2Ryan GroveMappedView = Y.Base.create('mappedView', Y.View, [Y.View.NodeMap]);
76bf9d78d0779795bbf4cf41abec4ff0300706b2Ryan Grove setUp: function () {
76bf9d78d0779795bbf4cf41abec4ff0300706b2Ryan Grove this.container = Y.Node.create('<div id="node-map-container"><div id="node-map-child"></div></div>');
76bf9d78d0779795bbf4cf41abec4ff0300706b2Ryan Grove this.view = new MappedView({container: this.container});
76bf9d78d0779795bbf4cf41abec4ff0300706b2Ryan Grove tearDown: function () {
76bf9d78d0779795bbf4cf41abec4ff0300706b2Ryan Grove 'getByNode() should return a View instance associated with the given Node': function () {
76bf9d78d0779795bbf4cf41abec4ff0300706b2Ryan Grove Assert.areSame(this.view, MappedView.getByNode(this.container), 'Node ref to the container should work.');
76bf9d78d0779795bbf4cf41abec4ff0300706b2Ryan Grove Assert.areSame(this.view, MappedView.getByNode('#node-map-container'), 'Id selector for the container should work.');
76bf9d78d0779795bbf4cf41abec4ff0300706b2Ryan Grove Assert.areSame(this.view, MappedView.getByNode('#node-map-child'), 'Id selector for a child of the container should work.');
76bf9d78d0779795bbf4cf41abec4ff0300706b2Ryan Grove 'getByNode() should return the nearest View instance': function () {
76bf9d78d0779795bbf4cf41abec4ff0300706b2Ryan Grove var subView = new MappedView({container: '#node-map-child'});
76bf9d78d0779795bbf4cf41abec4ff0300706b2Ryan Grove Assert.areSame(subView, MappedView.getByNode('#node-map-child'));
76bf9d78d0779795bbf4cf41abec4ff0300706b2Ryan Grove Assert.areSame(this.view, MappedView.getByNode('#node-map-container'));
76bf9d78d0779795bbf4cf41abec4ff0300706b2Ryan Grove 'getByNode() should return null when no View is found': function () {
57ae29e469a05555e94fa1801b4a2aa13e9ad366Ryan Grove 'View should be removed from the instances map when destroy() is called': function () {
57ae29e469a05555e94fa1801b4a2aa13e9ad366Ryan Grove ObjectAssert.ownsKey(key, Y.View.NodeMap._instances, 'Node stamp should exist in the instances map.');
57ae29e469a05555e94fa1801b4a2aa13e9ad366Ryan Grove Assert.isFalse(key in Y.View.NodeMap._instances, 'Node stamp should not exist in the instances map after the instance is destroyed.');
57ae29e469a05555e94fa1801b4a2aa13e9ad366Ryan Grove this.view = null;
76bf9d78d0779795bbf4cf41abec4ff0300706b2Ryan Grove}, '@VERSION@', {