From 067cab55129b8420a9544914fcf6392283add731 Mon Sep 17 00:00:00 2001 From: Jonnie Spratley Date: Tue, 1 Apr 2014 21:31:07 -0700 Subject: [PATCH] updated node rest tests --- .idea/workspace.xml | 318 ++++++++++++++++++++++++------------ Gruntfile.js | 1 + db/angular-cms.0 | Bin 16777216 -> 16777216 bytes db/angular-cms.ns | Bin 16777216 -> 16777216 bytes routes/rest.js | 2 +- test/routes/restSpec.coffee | 39 ++++- 6 files changed, 246 insertions(+), 114 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 311e166..e24e79b 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,12 @@ - + + + + + + - - + + - - + + - + - - + + - - - - - - - - - - - - - - + + + + @@ -76,30 +71,20 @@ - - - - - - - - - - - - + + - + - + @@ -109,7 +94,7 @@ - + @@ -119,11 +104,31 @@ - - + + + + + + + + + + + + - - + + + + + + + + + + + + @@ -183,11 +188,13 @@ @@ -197,6 +204,8 @@ + + @@ -346,6 +355,9 @@ test + + test:server + uglify @@ -453,15 +465,25 @@ - + + + @@ -730,12 +810,12 @@ - + - + @@ -782,7 +862,20 @@ - + + + + file://$PROJECT_DIR$/.tmp/routes/restSpec.js + 46 + + + file://$PROJECT_DIR$/.tmp/routes/restSpec.js + 40 + + + - - - - - - - - - - - - - - @@ -1004,6 +1083,7 @@ + @@ -1011,13 +1091,7 @@ - - - - - - - + @@ -1064,13 +1138,6 @@ - - - - - - - @@ -1079,14 +1146,6 @@ - - - - - - - - @@ -1103,17 +1162,6 @@ - - - - - - - - - - - @@ -1143,8 +1191,8 @@ - - + + @@ -1153,7 +1201,10 @@ - + + + + @@ -1165,18 +1216,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - + - - + + + + + + + + + + diff --git a/Gruntfile.js b/Gruntfile.js index e845264..47bd9df 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -522,6 +522,7 @@ require('json-proxy').initialize({}); return grunt.task.run(['karma:unit']); } }); + grunt.registerTask('test:server', 'coffee', 'jasmine_node'); grunt.registerTask('build', ['clean:dist', 'useminPrepare', 'concurrent:dist', 'autoprefixer', 'concat', 'ngmin', 'copy:dist', 'cdnify', 'cssmin', 'uglify', 'rev', 'usemin']); diff --git a/db/angular-cms.0 b/db/angular-cms.0 index b3b061dbb61ca434a5baac6bf09a65808b78594c..787e4594c17fd4758f33ed9593cf0dadc748ccdd 100644 GIT binary patch delta 6443 zcmd7Wd013c7{~DgQX-ZMMlQJwio1-n!pvYMmX%p<;D)A-%xI$w5Dc1S4QgeJB}$u_ zVMUhZhE|sCR+dI-Wor9k3zn6sZRXPV;JtT79h*PqQRX~;9(eCPkHh?)bKiUKDJ?CH zFU9KRy4W~t`AXg9I9+=o%4Z~3`dh>ZA#_66ItWpiEJS_kShv^d$rDXD<8*mF`F(0@ zeQtqQ#1=Y>i>DP7xkQ3`)@U+YM7%TC=b7pjF>#ZM3Q7u#MIxtT4dQHd7S*`gIZmIa zAYaH&<;WDjd%E&_ZjsyRbGt-KPM8cvbE?spYP4q?%nq~BVYKP(W=oEU^%l516FuRk z)$_W2PM6c?6rJVAIH&S!k@7kDPOn=uhr_v z_D+zW9Wt0xXGm~7+d3UvKv5Wv*!2YACo?cBqil;3O?IH=*t!WJ7f$GFsxCVYJ=vzWnhoJPPGDX{ zm((F8n_a-zS9Tqx{-5M^Qz`RJ}ncq)|XLxWtOL}m>VgW^AJZTQ2 zMQ^i(ddxZQb{?1)Q9Kisct!-rvn`eT6)PwT<4Jdz?0T~~?CJ^3izuEdC7zMN@x=G! ze#Huk!gy>BgMr=?_I4ha7g0Q0m3T%4$J5Iogj_*U8IQ@TH&~6~dXLSa&Wk9X-AX(; z!SNItg^(*KD&w)3cvcR3=dwA}c@f2PP>E-Ba6FYJA>;~*!g%ZsgI#Ykh3!3od6C4k zAZf#@n$ZVpHkJm*v(wBQIx8qD<1tzE_B4CAi_7j%=S37xiW1LE8BY)8H9gKMg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=JopYS$4=(U0e{qpZT;^}C gaFu_^*a)9{=(m_cvsuJV@yIKY^Z&(*OVf diff --git a/db/angular-cms.ns b/db/angular-cms.ns index d03d9fbcbc3345e820b8a519cc71d1a188800c1e..53c1db5fb558afc29eef48b8e463878c9521ad22 100644 GIT binary patch delta 814 zcmW;52bc~70DxiRjEm4AqpT}?boSmN+u5=Tab)l9$7j22XFGe8eX?g|XOGGrl~wkh zAMf+Lfj}T(;9X)9hqwe0kN6}YA;Ek=A`LPXP*2h{6=1D8(pF2})9m(v+br;yYT?h6viy zj_+wt2RhP;&UB$G-RMpadeV#D^r3G|zg!Vfox?+e;)E578Wr+BKPJk8TR!!te0vpvUi z9qoCZ?*(4yMPBSBUg~9D?jQY=S9qmYd9~Mgt=Bom>;1Dgc%wIYv$uGww|TpFc&B%H zw}0`k{>^*5*ZaKR2Yk?n{JRhPh>!Z1kNbpA`jk)mjQ{YT{>x{5&gXr>7k$Z>eZ^OO z&42qJ|Lg0%;hVnY+y2l0`;PDWp6~mCANr9W`-z|WnVYws(TGkAViJpw2qQLeh)X=;lYoRI;$sq%grp=RIVngd z1js~YvXGT*WG4qX$whARke5%%M}9t|00k*TVTw?cViczYB`HN|%21Yal&1op^92?8 zl1fyj3RS7bS5)U~Y7kCMYEhdy)TJKvX+T37(U>MQr5WGwEzM~`OIqY(34*DrVo8r_sbm-su3Ot3v~_;#E6zL5E>XBs1kc-lnYmx z{vP0g9^{}0dx(b`5A$%3@JNsHXpiw&NBVpJ;2%BC<2}I>J;{?D@=u=Psh;MaJ>4_> zi)VV4XM2w4dY?L06WnS(TUg=d{?KNKObzbic-snx<>@D8vZQkx3 z-s#`{hyV00@Ae+=^*-NuTm*pYebG-)DW!=Y7E! zeaV-7#aDgJ*L}k`eap9f$9H|t_x->R{m75~#83Uq&;7zL{mQTXW?f{&+iszE@O_XG diff --git a/routes/rest.js b/routes/rest.js index 7a08f8f..cec5517 100755 --- a/routes/rest.js +++ b/routes/rest.js @@ -216,7 +216,7 @@ var RestResource = { v2index : function(req, res, next) { RestResource.version = 'v2'; res.json({ - message : ' REST API Server ' + RestResource.useversion + message : 'REST API Server ' + RestResource.useversion }); }, //### hashPassword diff --git a/test/routes/restSpec.coffee b/test/routes/restSpec.coffee index 1d888a0..39ef2c5 100644 --- a/test/routes/restSpec.coffee +++ b/test/routes/restSpec.coffee @@ -1,10 +1,39 @@ #Routes Spec request = require("request") -describe 'Testing api endpoint', () -> - it "should respond with hello world", (done) -> - jsonResponse = { message: ' REST API Server v2' } - request "http://localhost:8181/api/v2", (error, response, body) -> - expect(JSON.prase(response.body)).toEqual jsonResponse +endpoint = 'http://localhost:8181/api/v2' + +describe 'Testing: API Server', () -> + it "GET - /api/v2 - should respond with REST API Server v2", (done) -> + jsonResponse = { message: 'REST API Server v2' } + request endpoint, (error, response, body) -> + expect(JSON.parse(response.body)).toEqual jsonResponse + done() + + it "GET - /angular-cms/users - should return a list of users", (done) -> + request "#{endpoint}/angular-cms/users", (error, response, body) -> + expect(JSON.parse(response.body).length).toBeGreaterThan 0 + done() + + it "POST - /angular-cms/users - should create and return object", (done) -> + postData = + "username": "nodetest", + "email": "nodetest@email.com", + "password": "test", + "active": true, + "groups": ["member"], + "_activation": "", + "_key": "", + "created": new Date(), + "modified": new Date(), + "metadata": {"avatar": "", "name": "Node Test User"} + + options = + uri: "#{endpoint}/angular-cms/users" + method: 'POST' + json: postData + request options, (error, response, body) -> + console.log(body) + expect(response.status).toBe 'ok' done()