diff options
author | 2017-08-07 11:39:39 +0800 | |
---|---|---|
committer | 2017-08-07 11:39:39 +0800 | |
commit | 21d72c4a80fe2937d0c4ddd20624b27adbcd989b (patch) | |
tree | e5013ee12f74f8452e01cbff16e7b0158bc456cb /common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.hooks.js | |
parent | f533e73e2ae32e010b16abdcf7985abaf31ab843 (diff) |
Upload the ESR GUI seed code
Issue-ID: AAI-68
Change-Id: Ia50ce0570c2fabecd77199d4e8454f56fe587c4e
Signed-off-by: lizi00164331 <li.zi30@zte.com.cn>
Diffstat (limited to 'common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.hooks.js')
-rw-r--r-- | common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.hooks.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.hooks.js b/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.hooks.js new file mode 100644 index 0000000..9207cbc --- /dev/null +++ b/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.hooks.js @@ -0,0 +1,52 @@ +var config = require('./fixtures/config'), + request = require('supertest'), + sinon = require('sinon'); + +describe('Model', function() { + var app, movie, user; + before(function() { + app = config.app; + movie = config.movie; + user = config.user; + }); + describe('before hook', function() { + it('should call the before hook on a GET', function() { + movie.routes.get.before.length.should.equal(1); + movie.routes.get.after.length.should.equal(1); + }); + it('should call the before hook on a POST', function() { + movie.routes.post.before.length.should.equal(1); + movie.routes.post.after.length.should.equal(1); + }); + it('should call the before hook on a PUT', function() { + movie.routes.put.before.length.should.equal(1); + movie.routes.put.after.length.should.equal(1); + }); + it('should call after all hook on user defined all route', function(done) { + request(app) + .get('/api/movies/recommend') + .end(function(err, res) { + res.body.recommend.should.equal('called'); + res.body.after.should.equal('called'); + done(); + }); + }); + it('should call before all hook on user defined get route', function(done) { + request(app) + .get('/api/movies/' + config.movies[2]._id + '/athirdroute') + .end(function(err, res) { + res.body.athirdroute.should.equal('called'); + res.body.after.should.equal('called'); + done(); + }); + }); + it('should use the properties set in a before route for filtering', function(done) { + request(app) + .get('/users') + .end(function(err, res) { + res.body.should.have.length(1); + done(err); + }); + }); + }); +}); |