index.html revision 31557e8bce12ddd0d89b20190e50a0141e9491ba
5263N/A }).use("dump", "test", "console", "io-base", "cache", "base", "plugin", "json", "dataparser", "datasource", function(Y) {
5680N/A ARRAYASSERT = Y.ArrayAssert,
5180N/A OBJECTASSERT = Y.ObjectAssert,
7178N/A BTNRUN.set("disabled", false);
5680N/A var testClass = new Y.Test.Case({
7178N/A var ds = new Y.DataSource.Local();
5264N/A var ds = new Y.DataSource.XHR();
5263N/A var testLocal = new Y.Test.Case({
name: "DataSource.Local Tests",
var ds = new Y.DataSource.Local({
var handler = Y.Mock();
Y.Mock.expect(handler,{
args: [Y.Mock.Value(function(e){
ds.sendRequest(null, {
success: handler.handleSuccess,
ASSERT.fail("XHR failure case.");
Y.Mock.verify(handler);
var ds = new Y.DataSource.Local({
var handler = Y.Mock();
Y.Mock.expect(handler,{
args: [Y.Mock.Value(function(e){
Y.Mock.expect(handler,{
args: [Y.Mock.Value(function(e){
Y.Mock.expect(handler,{
args: [Y.Mock.Value(function(e){
ds.sendRequest("a", "callback");
Y.Mock.verify(handler);
var ds = new Y.DataSource.Local({
var handler = Y.Mock();
Y.Mock.expect(handler,{
args: [Y.Mock.Value(function(e){
ds.set("source", undefined);
ds.sendRequest("a", "callback");
var testXHR = new Y.Test.Case({
name: "DataSource.XHR Tests",
var ds = new Y.DataSource.XHR({
var handler = Y.Mock();
Y.Mock.expect(handler,{
args: [Y.Mock.Value(function(e){
OBJECTASSERT.ownsAll({tId:null,request:null,data:null,response:null,callback:null}, e, "Expected all properties.");
ds.sendRequest(null, {
success: handler.handleSuccess,
ASSERT.fail("XHR failure case.");
var ds = new Y.DataSource.XHR({
resultsList: "ResultSet.Result",
var handler = Y.Mock();
Y.Mock.expect(handler,{
args: [Y.Mock.Value(function(e){
Y.Mock.expect(handler,{
args: [Y.Mock.Value(function(e){
Y.Mock.expect(handler,{
args: [Y.Mock.Value(function(e){
ds.sendRequest(null, "callback");
var ds = new Y.DataSource.XHR({
resultsList: "ResultSet.Result",
var handler = Y.Mock();
Y.Mock.expect(handler,{
args: [Y.Mock.Value(function(e){
ds.set("source", "foo");
ds.sendRequest("a", "callback");
var testJSONParser = new Y.Test.Case({
name: "DataSource.XHR JSONParser Tests",
var ds = new Y.DataSource.XHR({
resultsList: "ResultSet.Result",
var handler = Y.Mock();
Y.Mock.expect(handler,{
args: [Y.Mock.Value(function(e){
ds.sendRequest(null, {
success: handler.handleSuccess,
ASSERT.fail("XHR failure case.");
var testCaching = new Y.Test.Case({
var ds = new Y.DataSource.Local();
var ds = new Y.DataSource.Local();
var ds = new Y.DataSource.Local();
ds.cache.set("max", 5);
var ds = new Y.DataSource.Local({
ds.sendRequest("a");
ds.subscribe("data", function(e) {
ASSERT.fail("Entry should be cached -- 'data' event is unexpected");
ds.sendRequest("a");
var ds = new Y.DataSource.Local({
ds.sendRequest("a");
ds.cache.subscribe("retrieve", function(e) {
ASSERT.fail("Cache is unset -- 'retrieve' event is unexpected");
ds.unplug("cache");
ds.sendRequest("a");
var testPolling = new Y.Test.Case({
var ds = new Y.DataSource.Local();
ds = new Y.DataSource.XHR();
var ds = new Y.DataSource.Local();
var handler = Y.Mock();
Y.Mock.expect(handler,{
args: [Y.Mock.Value.Any],
var id = ds.setInterval(500, null, {
success: handler.handleSuccess,
ASSERT.fail("XHR failure case.");
ASSERT.isNumber(id, "Expected interval id.");
this.wait(function(){
ds.clearInterval(id);
this.wait(function(){
Y.Mock.verify(handler);
var ds = new Y.DataSource.Local();
var handler = Y.Mock();
Y.Mock.expect(handler,{
args: [Y.Mock.Value.Any],
var id1 = ds.setInterval(500, null, {
success: handler.handleSuccess,
ASSERT.fail("XHR failure case.");
id2 = ds.setInterval(500, null, {
success: handler.handleSuccess,
ASSERT.fail("XHR failure case.");
id3 = ds.setInterval(500, null, {
success: handler.handleSuccess,
ASSERT.fail("XHR failure case.");
this.wait(function(){
this.wait(function(){
Y.Mock.verify(handler);
Y.Test.Runner.add(testClass);
Y.Test.Runner.add(testLocal);
Y.Test.Runner.add(testXHR);
Y.Test.Runner.add(testJSONParser);
Y.Test.Runner.add(testCaching);
Y.Test.Runner.add(testPolling);