app-base-test.js revision 23c56a064638d10a6057e991c7dc113cc15c379a
var ArrayAssert = Y.ArrayAssert,
ObjectAssert = Y.ObjectAssert,
function resetURL() {
if (html5) {
} else {
}
}
// -- Global Suite -------------------------------------------------------------
// -- App Base Suite -----------------------------------------------------------
name: 'App Base',
setUp: function () {
resetURL();
},
tearDown: function () {
resetURL();
}
});
// -- App Base: Lifecycle ------------------------------------------------------
name: 'Lifecycle',
tearDown: function () {
delete this.app;
},
'`container` should default to the `<body>`': function () {
},
'A specified `container` should be used during construction': function () {
},
'`viewContainer` should be a new `<div/>` by default': function () {
},
'A specified `viewContainer` should be used during construction': function () {
},
'`activeView` should be undefined by default': function () {
},
'`activeView` should not be overrideable in the constructor config': function () {
activeView: new Y.View()
});
},
'`linkSelector` should be `"a"` by default': function () {
},
'`serverRouting` should default to undefined': function () {
},
'`serverRouting` should be overrideable via the constructor': function () {
serverRouting: true
});
},
'`views` property should be empty by default': function () {
},
'`views` should be a copy of the `views` object on the prototype': function () {
views: {
home: {
preserve: true
}
}
});
},
'Destroying an app should destroy its `container` and `viewContainer`': function () {
app;
});
},
'Destorying an app with the `<body>` for a container should only remove its CSS classes, not the body from the DOM': function () {
container : 'body',
viewContainer: 'body'
});
}
}));
// -- App Base: Attributes -----------------------------------------------------
name: 'Attributes',
setUp: function () {
},
tearDown: function () {
delete this.html5;
delete this.app;
},
'`activeView` should be read-only': function () {
},
'`activeView` should be modifiable via the `showView()` method': function () {
},
'`container` and `viewContainer` should be able to be the same node': function () {
container : 'body',
viewContainer: 'body'
});
},
'`container` should be stamped with the App CSS class': function () {
},
'`viewContainer` should be stamped with the App Views CSS class': function () {
},
'`viewContainer` should only be settable during initialization': function () {
var viewContainer = new Y.View(),
},
'`serverRouting` should only be settable during initialization': function () {
},
'`serverRouting` should only be settable with a user-specified value during initialization': function () {
},
'Setting `serverRouting` to `false` should force `html5` to default to `false` in HTML5 browsers': function () {
},
'Setting `serverRouting` to `false` should force `html5` to default to `false` in non-HTML5 browsers': function () {
},
'Setting `serverRouting` to `true` should allow `html5` to default to `true` in HTML5 browsers': function () {
},
'Setting `serverRouting` to `true` should allow `html5` to default to `false` in non-HTML5 browsers': function () {
},
'Setting `serverRouting` to `undefined` should allow `html5` to default to `true` in HTML5 browsers': function () {
},
'Setting `serverRouting` to `undefined` should allow `html5` to default to `false` in non-HTML5 browsers': function () {
},
'`html5` should be overridable on construction even when `serverRouting` is false': function () {
serverRouting: false,
html5 : true
});
}
}));
// -- App Base: Events ---------------------------------------------------------
name: 'Events',
setUp: function () {
},
tearDown: function () {
resetURL();
delete this.html5;
delete this.app;
},
'`navigate` should fire when `serverRouting` is falsy, even when `html5` is `false`': function () {
eventCalls = 0,
routeCalls = 0,
test = this;
routeCalls += 1;
});
eventCalls += 1;
});
}, 200);
}
}));
// -- App Base: Methods --------------------------------------------------------
name: 'Methods',
tearDown: function () {
delete this.app;
},
'`create()` should return a `Y.Node` instance stamped with the `Y.App` CSS class': function () {
},
'`createViewContainer()` should return a `Y.Node` instance stamped with the `Y.App` Views CSS class': function () {
},
'`createView()` should always return a new `Y.View` instance': function () {
},
'`createView()` should return a new instance of a named, registered view': function () {
app;
views: {
myview: {
}
}
});
},
'`createView()` should apply the specified `config` to the new `Y.View` instance': function () {
},
'`createView()` should apply the specified `config` to the new instance of a named, registered view': function () {
views: {
myview: {
}
}
});
},
'`getViewInfo()` should return the metadata for a named, registered view': function () {
var myviewInfo = {},
},
'`getViewInfo()` should return the metadata for a view constructed by `createView()`': function () {
var myviewInfo = {},
},
'`render()` should append the `viewContainer` into the `container`': function () {
},
'`render()` should properly handle the `container` already containing the `viewContainer': function () {
});
},
'`render()` should properly handle the `container` and `viewContainer` being the same node': function () {
});
},
'`render()` should append the `activeView` to the `viewContainer`': function () {
// Makes sure the view isn't contained.
}
}));
// -- App Base: Views ----------------------------------------------------------
name: 'Views',
setUp: function () {
},
tearDown: function () {
delete this.app;
delete this.TestView;
delete Y.TestView;
},
'A registered view with falsy `type` should default to `Y.View`': function () {
views: {
unspecifiedView: {},
}
});
},
'A registered view with a function `type` should return an instance of that function': function () {
views: {
}
});
},
'A registered view with a string `type` should look on the `Y` object for the constructor': function () {
views: {
}
});
},
'A View instance should be preserved when registered with `preserve` as `true`': function () {
views: {
}
}),
view;
// Sets `activeView` to a new instance of the `test` registered view.
// Sets the `activeView` to something else.
// Sets the `activeView` back to the registered `test` view, which
// should be the same instance as before.
},
'A view registered with a specified `instance` should be preserved when `preseve` is `true`': function () {
views: {
test: {
preserve: true,
}
}
});
},
views: {
parent: {},
}
});
},
views: {
parent: {},
}
}),
},
'`Y.App` subclasses should be able to specify view metadata on the `prototype`': function () {
views: {
}
}),
},
'The `views` metadata on the `prototype` should be merged with the specified `views` during construction': function () {
views: {
test: {
preserve: false
},
parent: {
}
}
}),
views: {
}
});
},
'`showView()` should set the specified view instance or name as the `activeView`': function () {
views: {
}
});
},
'`showView()` should construct a registered view instance with the specified `config`': function () {
views: {
}
});
},
'`showView()` should accept a `null` `view`': function () {
},
'`showView()` should prepend the new `activeView` when `options.prepend` is `true`': function () {
},
'`options` passed to `showView()` should be mixed into the `activeViewChange` event facade': function () {
calls = 0,
options = {};
calls += 1;
});
},
'`showView()` should accept a `callback` as either the third or fourth param': function () {
calls = 0,
noop = function () {};
function callback() {
calls += 1;
}
},
'`showView()` should call the specified `callback` with `this` context': function () {
calls = 0;
calls += 1;
});
},
'`showView()` should pass the new `activeView` to the `callback`': function () {
calls = 0;
calls += 1;
});
},
'`activeViewChange` event should be preventable': function () {
calls = 0;
calls += 1;
e.preventDefault();
});
calls += 1;
});
},
'An `activeView` should bubble events to the app': function () {
calls = 0;
calls += 1;
});
});
},
'The previous `activeView` should no longer bubble events to the app': function () {
calls = 0;
calls += 1;
});
});
},
'A preserved view should not be destroyed when its no longer the `activeView`': function () {
var calls = 0,
views: {
test: {
preserve: true
}
}
});
calls += 1;
});
}
}));
// -- App Base: Navigation -----------------------------------------------------
name: 'Naivation',
_should: {
error: {
'`_save()` should throw an error when the specified URL is not of the same origin': true
}
},
setUp: function () {
},
tearDown: function () {
resetURL();
delete this.html5;
delete this.hashPrefix;
delete this.app;
},
'`_upgradeURL()` should upgrade a path-like hash-based URL to a full URL': function () {
hash = '#/foo/',
path = '/foo/',
},
'`_upgradeURL()` should not upgrade a hash-based URL which is not path-like': function () {
hash = '#foo';
},
'`_upgradeURL()` should strip any hash-prefix from the hash-based URL': function () {
hash = '/#!/foo/',
path = '/foo/',
},
'`_upgradeURL()` should not upgrade URLs of a different origin': function () {
url = 'http://random.host.example.com/#/foo/',
path = '/foo/',
},
'`navigate()` should upgrade hash-based URLs when `serverRouting` is falsy': function () {
var calls = 0,
noop = function () {},
serverRouting: false,
routes: [
]
});
calls += 1;
e.preventDefault();
});
},
'`navigate()` should upgrade hash-based URLs when `serverRouting` is `true`': function () {
// Force-fake HTML5
var calls = 0,
noop = function () {},
serverRouting: true,
routes: [
]
});
calls += 1;
e.preventDefault();
});
},
'`navigate()` should force the firing of the `navigate` event when `serverRouting` is falsy': function () {
var calls = 0,
noop = function () {},
routes: [
]
});
calls += 1;
e.preventDefault();
});
},
'`navigate()` should replace the history entry when the new and current URLs are the "same"': function () {
var calls = 0,
noop = function () {},
serverRouting: false,
routes: [
]
});
calls += 1;
e.preventDefault();
});
},
'`navigate()` should not override user-specified values for `force` and `replace`': function () {
var calls = 0,
noop = function () {},
html5 : true,
serverRouting: false,
routes: [
]
});
calls += 1;
e.preventDefault();
});
force : false,
replace: true
});
},
'`_save()` should throw an error when the specified URL is not of the same origin': function () {
calls = 0;
}
}));
}, '@VERSION@', {
});