forked from actionhero/actionhero
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4704f92
commit 11d4312
Showing
12 changed files
with
214 additions
and
65 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
var specHelper = require('../specHelper.js').specHelper; | ||
var suite = specHelper.vows.describe('action: action view'); | ||
var apiObj = {}; | ||
|
||
suite.addBatch({ | ||
'specHelper.prepare':{ | ||
topic: function(){ var cb = this.callback; specHelper.prepare(function(api){ apiObj = specHelper.cleanAPIObject(api); cb(); }) }, | ||
'api object should exist': function(){ specHelper.assert.isObject(apiObj); } } | ||
}); | ||
|
||
suite.addBatch({ | ||
"Actions array": { | ||
topic: function(){ specHelper.apiTest.get('/actionsView', {} ,this.callback ); }, | ||
error: function(res, b){ specHelper.assert.equal(res.body.error, "OK"); }, | ||
actions: function(res, b){ specHelper.assert.isArray(res.body.actions); }, | ||
} | ||
}); | ||
|
||
suite.addBatch({ | ||
"Actions have the right parts": { | ||
topic: function(){ specHelper.apiTest.get('/actionsView', {} ,this.callback ); }, | ||
actions: function(res, b){ | ||
for(var i in res.body.actions){ | ||
var action = res.body.actions[i]; | ||
specHelper.assert.isString(action.name); | ||
specHelper.assert.isString(action.description); | ||
specHelper.assert.isObject(action.inputs); | ||
specHelper.assert.isArray(action.inputs.required); | ||
specHelper.assert.isArray(action.inputs.optional); | ||
specHelper.assert.isObject(action.outputExample); | ||
} | ||
}, | ||
} | ||
}); | ||
|
||
// export | ||
suite.export(module); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
var specHelper = require('../specHelper.js').specHelper; | ||
var suite = specHelper.vows.describe('action: cacheTest'); | ||
var apiObj = {}; | ||
|
||
var actionUrl = "/cacheTest/"; | ||
|
||
suite.addBatch({ | ||
'specHelper.prepare':{ | ||
topic: function(){ var cb = this.callback; specHelper.prepare(function(api){ apiObj = specHelper.cleanAPIObject(api); cb(); }) }, | ||
'api object should exist': function(){ specHelper.assert.isObject(apiObj); } } | ||
}); | ||
|
||
suite.addBatch({ | ||
"cacheTest: no params": { | ||
topic: function(){ specHelper.apiTest.get(actionUrl, {} ,this.callback ); }, | ||
error: function(res, b){ specHelper.assert.equal(res.body.error, "key is a required parameter for this action"); }, | ||
}, | ||
"cacheTest: just key ": { | ||
topic: function(){ specHelper.apiTest.get(actionUrl, {key: "test key"} ,this.callback ); }, | ||
error: function(res, b){ specHelper.assert.equal(res.body.error, "value is a required parameter for this action"); }, | ||
}, | ||
"cacheTest: just value ": { | ||
topic: function(){ specHelper.apiTest.get(actionUrl, {value: "abc123"} ,this.callback ); }, | ||
error: function(res, b){ specHelper.assert.equal(res.body.error, "key is a required parameter for this action"); }, | ||
}, | ||
"cacheTest: gibberish param ": { | ||
topic: function(){ specHelper.apiTest.get(actionUrl, {thingy: "abc123"} ,this.callback ); }, | ||
error: function(res, b){ specHelper.assert.equal(res.body.error, "key is a required parameter for this action"); }, | ||
}, | ||
"correct params ": { | ||
topic: function(){ specHelper.apiTest.get(actionUrl, {key: "testKey", value: "abc123"} ,this.callback ); }, | ||
error: function(res, b){ specHelper.assert.equal(res.body.error, "OK"); }, | ||
params: function(res, b){ | ||
specHelper.assert.equal(res.body.cacheTestResults.key, "testKey"); | ||
specHelper.assert.equal(res.body.cacheTestResults.value, "abc123"); | ||
specHelper.assert.equal(res.body.cacheTestResults.saveResp, "new record"); | ||
specHelper.assert.equal(res.body.cacheTestResults.loadResp, "abc123"); | ||
specHelper.assert.equal(res.body.cacheTestResults.deleteResp, true); | ||
}, | ||
} | ||
}); | ||
|
||
// export | ||
suite.export(module); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
var specHelper = require('../specHelper.js').specHelper; | ||
var suite = specHelper.vows.describe('action: file'); | ||
var apiObj = {}; | ||
|
||
var actionUrl = "/file/"; | ||
|
||
suite.addBatch({ | ||
'specHelper.prepare':{ | ||
topic: function(){ var cb = this.callback; specHelper.prepare(function(api){ apiObj = specHelper.cleanAPIObject(api); cb(); }) }, | ||
'api object should exist': function(){ specHelper.assert.isObject(apiObj); } } | ||
}); | ||
|
||
suite.addBatch({ | ||
"file: response is NOT json": { | ||
topic: function(){ specHelper.apiTest.get(actionUrl + "/someRandomFile", {} ,this.callback ); }, | ||
error: function(res, b){ specHelper.assert.equal(res.body.error, undefined);}, | ||
}, | ||
"file: missing pages": { | ||
topic: function(){ specHelper.apiTest.get(actionUrl + "/someRandomFile", {} ,this.callback ); }, | ||
statusCode: function(res, b){ specHelper.assert.equal(res.statusCode, 404);}, | ||
content: function(res, b){ specHelper.assert.equal(res.body, 'Sorry, that file is not found :(');}, | ||
}, | ||
"file: an html page": { | ||
topic: function(){ specHelper.apiTest.get(actionUrl + "index.html", {} ,this.callback ); }, | ||
statusCode: function(res, b){ specHelper.assert.equal(res.statusCode, 200);}, | ||
content: function(res, b){ specHelper.assert.equal(res.body, '<h1>Hello!</h1>\nI am a flat file being served to you via the API. <br />\nEnjoy!');}, | ||
}, | ||
"file: ?filename should work like a path": { | ||
topic: function(){ specHelper.apiTest.get(actionUrl + "?filename=index.html", {} ,this.callback ); }, | ||
statusCode: function(res, b){ specHelper.assert.equal(res.statusCode, 200);}, | ||
content: function(res, b){ specHelper.assert.equal(res.body, '<h1>Hello!</h1>\nI am a flat file being served to you via the API. <br />\nEnjoy!');}, | ||
}, | ||
"file: index page should be served when requesting a path": { | ||
topic: function(){ specHelper.apiTest.get(actionUrl, {} ,this.callback ); }, | ||
statusCode: function(res, b){ specHelper.assert.equal(res.statusCode, 200);}, | ||
content: function(res, b){ specHelper.assert.equal(res.body, '<h1>Hello!</h1>\nI am a flat file being served to you via the API. <br />\nEnjoy!');}, | ||
}, | ||
"file: sub paths should work": { | ||
topic: function(){ specHelper.apiTest.get(actionUrl + "/img/piano.jpg", {} ,this.callback ); }, | ||
statusCode: function(res, b){ specHelper.assert.equal(res.statusCode, 200);}, | ||
}, | ||
"file: binary files should work": { | ||
topic: function(){ specHelper.apiTest.get(actionUrl + "/img/piano.jpg", {} ,this.callback ); }, | ||
statusCode: function(res, b){ specHelper.assert.equal(res.statusCode, 200);}, | ||
content: function(res, b){ specHelper.assert.equal(res.body.length, 41752);}, // bytes of file | ||
}, | ||
}); | ||
|
||
// export | ||
suite.export(module); |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
var specHelper = require('../specHelper.js').specHelper; | ||
var suite = specHelper.vows.describe('action: status'); | ||
var apiObj = {}; | ||
|
||
var actionUrl = "/status/"; | ||
|
||
suite.addBatch({ | ||
'specHelper.prepare':{ | ||
topic: function(){ var cb = this.callback; specHelper.prepare(function(api){ apiObj = specHelper.cleanAPIObject(api); cb(); }) }, | ||
'api object should exist': function(){ specHelper.assert.isObject(apiObj); } } | ||
}); | ||
|
||
suite.addBatch({ | ||
"status: error": { | ||
topic: function(){ specHelper.apiTest.get(actionUrl, {} ,this.callback ); }, | ||
error: function(res, b){ specHelper.assert.equal(res.body.error, "OK");}, | ||
}, | ||
"status: stats": { | ||
topic: function(){ specHelper.apiTest.get(actionUrl, {} ,this.callback ); }, | ||
stats: function(res, b){ | ||
specHelper.assert.isTrue(res.body.stats.numberOfWebRequests > 0); | ||
specHelper.assert.isTrue(res.body.stats.numberOfSocketRequests >= 0); | ||
specHelper.assert.isTrue(res.body.stats.startTime > 0); | ||
specHelper.assert.isTrue(res.body.stats.uptime > 0); | ||
}, | ||
}, | ||
|
||
}); | ||
|
||
// export | ||
suite.export(module); |
This file contains 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
This file contains 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
Oops, something went wrong.