Created
January 18, 2012 17:40
-
-
Save santiago/1634400 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var should = require("should"); | |
io = require("socket.io-client"); | |
require('../../lib/touch_on_node'); | |
require('../../lib/touch/sencha-touch-all-debug.js'); | |
require('../../lib/io/sencha-io-debug.js') | |
// | |
// The test requires: | |
// - messaging server | |
// - sync | |
// - rabbitmq | |
// - riak | |
// | |
describe("Sync", function() { | |
Ext.io.setup({ | |
logLevel:'debug', | |
appId:'test', | |
appKey:'test', | |
deviceId:'test', | |
deviceKey:'test', | |
deviceSid:'test', | |
url:'http://127.0.0.1:8080', | |
key:'test', | |
// | |
transportName:'socket', | |
// | |
//transportName:'polling' | |
//pollingDuration:100, | |
//maxEnvelopesPerReceive:1 | |
}); | |
Ext.define("Model", {extend: "Ext.data.Model", | |
fields: [ | |
{name: 'n1'}, | |
], | |
proxy: { | |
type: 'syncstorage', | |
id: 'test', | |
key: 'test' | |
}, | |
}); | |
it("should be able to create/open a store", function(done) { | |
var store= Ext.create('Ext.data.Store',{ | |
model: 'Model', | |
}); | |
should.exist(store); | |
done(); | |
}); | |
it("should be able to sync a store", function(done) { | |
var store= Ext.create('Ext.data.Store',{ | |
model: 'Model', | |
}); | |
should.exist(store); | |
store.sync(function(r){ | |
(r.r).should.eql('ok'); | |
done(); | |
},this); | |
}); | |
it("should be able to sync a store, after an add", function(done) { | |
var store= Ext.create('Ext.data.Store',{ | |
model: 'Model', | |
}); | |
should.exist(store); | |
store.add({n1: 'v1'}); | |
store.sync(function(r){ | |
(r.sent).should.be.above(0); | |
done(); | |
},this); | |
}); | |
it("should be able to sync a store, after an insert", function(done) { | |
var store= Ext.create('Ext.data.Store',{ | |
model: 'Model', | |
}); | |
should.exist(store); | |
var record= Ext.create('Model',{n1: 'v1'}); | |
store.insert(0,record); | |
store.sync(function(r){ | |
(r.sent).should.be.above(0); | |
done(); | |
},this); | |
}); | |
it("should be able to sync a store, after an insert of a record with an id", function(done) { | |
var store= Ext.create('Ext.data.Store',{ | |
model: 'Model', | |
}); | |
should.exist(store); | |
var record= Ext.create('Model',{n1: 'v1'}); | |
record.data.id= '1'; | |
store.insert(0,record); | |
store.sync(function(r){ | |
(r.sent).should.be.above(0); | |
done(); | |
},this); | |
}); | |
it("add, sync, sync - the second sync should send nothing", function(done) { | |
var store= Ext.create('Ext.data.Store',{ | |
model: 'Model', | |
}); | |
should.exist(store); | |
store.add({n1: 'v1'}); | |
store.sync(function(r){ | |
(r.sent).should.be.above(0); | |
store.sync(function(r){ | |
(r.sent).should.eql(0); | |
done(); | |
},this); | |
},this); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment