You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@olingo.apache.org by ko...@apache.org on 2014/11/17 17:09:06 UTC

[3/3] olingo-odata4-js git commit: [OLINGO-439] json parsing mocha test and fixes

[OLINGO-439] json parsing mocha test and fixes


Project: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/commit/3f705e2b
Tree: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/tree/3f705e2b
Diff: http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/diff/3f705e2b

Branch: refs/heads/master
Commit: 3f705e2b799c60568557194bc9fe06f2f6b9a475
Parents: 28f9457
Author: Sven Kobler <sv...@sap.com>
Authored: Mon Nov 17 17:03:12 2014 +0100
Committer: Sven Kobler <sv...@sap.com>
Committed: Mon Nov 17 17:08:50 2014 +0100

----------------------------------------------------------------------
 odatajs/demo/tester.html        |   4 +-
 odatajs/grunt-config/rat.js     |   4 +-
 odatajs/src/lib/odata/json.js   |  18 +-
 odatajs/test/mocha.opts         |   2 +
 odatajs/test/test-odata-json.js | 413 +++++++++++++++++++++++++++++++++++
 odatajs/test/test-utils.js      |  33 +++
 odatajs/test/test.js            |  36 +++
 7 files changed, 497 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/3f705e2b/odatajs/demo/tester.html
----------------------------------------------------------------------
diff --git a/odatajs/demo/tester.html b/odatajs/demo/tester.html
index c44aee2..e4e0832 100644
--- a/odatajs/demo/tester.html
+++ b/odatajs/demo/tester.html
@@ -117,8 +117,8 @@
             // Testing 
             function buttonClick(configNr) {
                 var metadata = $("input[name*='inMetadata']:checked").val();
-                var recognizeDates  = ($("#inRecognizeDates").val() ==='on') ? true : false;
-                var inMinimalToFull = ($("#inMinimalToFull").val() ==='on') ? true : false;
+                var recognizeDates  = $("#inRecognizeDates").is(":checked") ? true : false;
+                var inMinimalToFull = $("#inMinimalToFull").is(":checked")  ? true : false;
 
                 var requestUri = {
                     requestUri : config[configNr].url

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/3f705e2b/odatajs/grunt-config/rat.js
----------------------------------------------------------------------
diff --git a/odatajs/grunt-config/rat.js b/odatajs/grunt-config/rat.js
index 716a8c6..30e31d3 100644
--- a/odatajs/grunt-config/rat.js
+++ b/odatajs/grunt-config/rat.js
@@ -26,7 +26,7 @@ module.exports = function(grunt) {
         exclude: [
           "node_modules","extern-tools",".gitignore",
           "DEPENDENCIES","LICENSE","NOTICE",
-          "JSLib.sln","package.json"
+          "JSLib.sln","package.json", "mocha.opts"
         ] },
       files: [
         /*{ src: ['./../dist/<%= artifactname %>/doc'], options:{ tag:"dist-doc"}},generated*/
@@ -40,7 +40,7 @@ module.exports = function(grunt) {
         exclude: [
           "node_modules","extern-tools",".gitignore",
           "DEPENDENCIES","LICENSE","NOTICE",
-          "JSLib.sln","package.json"
+          "JSLib.sln","package.json", "mocha.opts"
         ] },
       files: [
         /*{ src: ['./../dist/<%= artifactname %>/doc'], options:{ tag:"dist-doc"}},generated*/

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/3f705e2b/odatajs/src/lib/odata/json.js
----------------------------------------------------------------------
diff --git a/odatajs/src/lib/odata/json.js b/odatajs/src/lib/odata/json.js
index b15a385..6a6968a 100644
--- a/odatajs/src/lib/odata/json.js
+++ b/odatajs/src/lib/odata/json.js
@@ -188,7 +188,7 @@ function addType(data, name, value ) {
     var fullName = name + '@odata.type';
 
     if ( data[fullName] === undefined) {
-        data[fullName] = value;
+        data[fullName] = '#' + value;
     }
 }
 
@@ -197,9 +197,9 @@ function addTypeNoEdm(data, name, value ) {
 
     if ( data[fullName] === undefined) {
         if ( value.substring(0,4)==='Edm.') {
-            data[fullName] = value.substring(4);
+            data[fullName] = '#' + value.substring(4);
         } else {
-            data[fullName] = value;
+            data[fullName] = '#' + value;
         }
 
     }
@@ -210,9 +210,9 @@ function addTypeColNoEdm(data, name, value ) {
 
     if ( data[fullName] === undefined) {
         if ( value.substring(0,4)==='Edm.') {
-            data[fullName] = 'Collection('+value.substring(4)+ ')';
+            data[fullName] = '#Collection('+value.substring(4)+ ')';
         } else {
-            data[fullName] = 'Collection('+value+ ')';
+            data[fullName] = '#Collection('+value+ ')';
         }
     }
 }
@@ -256,14 +256,14 @@ function readPayloadFull(data, model, recognizeDates) {
                             // To do: we need to get the type from metadata instead of guessing. 
                             var typeFromObject = typeof data[key];
                             if (typeFromObject === 'string') {
-                                addType(data, key, '#String');
+                                addType(data, key, 'String');
                             } else if (typeFromObject === 'boolean') {
-                                addType(data, key, '#Boolean');
+                                addType(data, key, 'Boolean');
                             } else if (typeFromObject === 'number') {
                                 if (data[key] % 1 === 0) { // has fraction 
-                                    addType(data, key, '#Int32'); // the biggst integer
+                                    addType(data, key, 'Int32'); // the biggst integer
                                 } else {
-                                    addType(data, key, '#Decimal'); // the biggst float single,doulbe,decimal
+                                    addType(data, key, 'Decimal'); // the biggst float single,doulbe,decimal
                                 }
                             }
                         }

http://git-wip-us.apache.org/repos/asf/olingo-odata4-js/blob/3f705e2b/odatajs/test/mocha.opts
----------------------------------------------------------------------
diff --git a/odatajs/test/mocha.opts b/odatajs/test/mocha.opts
new file mode 100644
index 0000000..56ffef3
--- /dev/null
+++ b/odatajs/test/mocha.opts
@@ -0,0 +1,2 @@
+--require chai
+--growl
\ No newline at end of file