Skip to content

Commit

Permalink
updated node rest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonnie Spratley committed Apr 2, 2014
1 parent 42f4ebd commit 067cab5
Show file tree
Hide file tree
Showing 6 changed files with 246 additions and 114 deletions.
318 changes: 210 additions & 108 deletions .idea/workspace.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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']);

Expand Down
Binary file modified db/angular-cms.0
Binary file not shown.
Binary file modified db/angular-cms.ns
Binary file not shown.
2 changes: 1 addition & 1 deletion routes/rest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 34 additions & 5 deletions test/routes/restSpec.coffee
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
"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()

0 comments on commit 067cab5

Please sign in to comment.