Skip to content
Browse files

tests

  • Loading branch information...
1 parent 9377507 commit b04dc43c7810795d56af702b4cb8b351294c008b @ericz ericz committed Jun 28, 2011
View
1 client/public/now.html
@@ -6,7 +6,6 @@
<!-- include source files here... -->
<script type="text/javascript" src="nowjs/now.js"></script>
-
</head>
<body>
View
1 client/public/spec/ScopeSpec.js
@@ -15,6 +15,7 @@ describe("Server scoping tests", function() {
waits(500);
+
var nowReady = false;
runs(function(){
View
12 client/public/spec/SpecHelper.js
@@ -16,6 +16,7 @@ var SpecHelper = {
}
return document.getElementById(id).contentWindow;
},
+
deepEqual: function(a, b) {
// check object identity
if (a === b) return true;
@@ -58,10 +59,17 @@ var SpecHelper = {
keys: Object.keys || function(obj) {
var r = [];
if (obj === Object(obj)) {
- for (var key in obj) if (has(obj, key)) {
+ for (var key in obj) if (SpecHelper.has(obj, key)) {
r.push(key);
}
}
return r;
+ },
+
+ has: function (obj, prop) {
+ return Object.prototype.hasOwnProperty.call(Object(obj), prop);
}
-};
+};
+
+
+if(!this.JSON){JSON=function(){function f(n){return n<10?'0'+n:n;} Date.prototype.toJSON=function(){return this.getUTCFullYear()+'-'+ f(this.getUTCMonth()+1)+'-'+ f(this.getUTCDate())+'T'+ f(this.getUTCHours())+':'+ f(this.getUTCMinutes())+':'+ f(this.getUTCSeconds())+'Z';};var m={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};function stringify(value,whitelist){var a,i,k,l,r=/["\\\x00-\x1f\x7f-\x9f]/g,v;switch(typeof value){case'string':return r.test(value)?'"'+value.replace(r,function(a){var c=m[a];if(c){return c;} c=a.charCodeAt();return'\\u00'+Math.floor(c/16).toString(16)+ (c%16).toString(16);})+'"':'"'+value+'"';case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';} if(typeof value.toJSON==='function'){return stringify(value.toJSON());} a=[];if(typeof value.length==='number'&&!(value.propertyIsEnumerable('length'))){l=value.length;for(i=0;i<l;i+=1){a.push(stringify(value[i],whitelist)||'null');} return'['+a.join(',')+']';} if(whitelist){l=whitelist.length;for(i=0;i<l;i+=1){k=whitelist[i];if(typeof k==='string'){v=stringify(value[k],whitelist);if(v){a.push(stringify(k)+':'+v);}}}}else{for(k in value){if(typeof k==='string'){v=stringify(value[k],whitelist);if(v){a.push(stringify(k)+':'+v);}}}} return'{'+a.join(',')+'}';}} return{stringify:stringify,parse:function(text,filter){var j;function walk(k,v){var i,n;if(v&&typeof v==='object'){for(i in v){if(Object.prototype.hasOwnProperty.apply(v,[i])){n=walk(i,v[i]);if(n!==undefined){v[i]=n;}}}} return filter(k,v);} if(/^[\],:{}\s]*$/.test(text.replace(/\\./g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof filter==='function'?walk('',j):j;} throw new SyntaxError('parseJSON');}};}();}
View
5 client/public/spec/VariableSpec.js
@@ -48,10 +48,14 @@ describe("Variable Sync", function() {
});
+
+
it("can sync complicated objects from client to server", function() {
function setIfEqual(k, v){
+
equals = key === k && SpecHelper.deepEqual(v, val);
+
}
var key = SpecHelper.generateRandomString();
@@ -60,7 +64,6 @@ describe("Variable Sync", function() {
// Create new variables
now[key] = val;
-
// Call server function to check if value synced
var equals;
runs(function(){
View
2 client/testserver.js
@@ -3,7 +3,7 @@ var static = require('node-static');
//
// Create a node-static server instance to serve the './public' folder
//
-var file = new(static.Server)(__dirname+'/public');
+var file = new(static.Server)(__dirname+'/public', {cache: 0});
var server = require('http').createServer(function (request, response) {
request.addListener('end', function () {

0 comments on commit b04dc43

Please sign in to comment.
Something went wrong with that request. Please try again.