diff options
Diffstat (limited to 'common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test')
11 files changed, 0 insertions, 869 deletions
diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/fixtures/config.js b/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/fixtures/config.js deleted file mode 100644 index bdb1208..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/fixtures/config.js +++ /dev/null @@ -1,32 +0,0 @@ -var express = require('express'), - fixtures = require('pow-mongodb-fixtures'), - app = require('../../examples/movies/'), - data = require('./data'), - done = false, - mongoose, - callback; - - -exports.app = app; -exports.movie = app.movie; -exports.user = app.user; -exports.review = app.review -mongoose = app.mongoose; -fixtures = fixtures.connect(mongoose.connection.name); - -fixtures.load(data, function(err) { - exports.users = data.users; - exports.movies = data.movies; - exports.reviews = data.reviews; - done = true; - if (callback) return callback(); -}); - -exports.movies = data.movies; -exports.users = data.users; -exports.reviews = data.reviews; - -exports.ready = function(cb) { - callback = cb; - if (done) callback(); -}; diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/fixtures/data.js b/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/fixtures/data.js deleted file mode 100644 index 7beafd9..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/fixtures/data.js +++ /dev/null @@ -1,101 +0,0 @@ -var ObjectId = require('mongodb').ObjectID; - -exports.users = [ - { - _id: new ObjectId(), - username: "test", - pass_hash: 12374238719845134515, - }, - { - _id: new ObjectId(), - username: "test2", - pass_hash: 1237987381263189273123, - } -]; - -exports.movies = [ - { - _id: new ObjectId(), - title: "Title1", - year: 2012, - meta: { - productionco: "idk", - director: exports.users[1]._id, - }, - creator: exports.users[0]._id, - secret: "A SECRET STRING", - }, - { - _id: new ObjectId(), - title: "Title2", - year: 2011 - }, - { - _id: new ObjectId(), - title: "Title3", - year: 2013 - }, - { - _id: new ObjectId(), - title: "Title4", - year: 2013 - }, - { - _id: new ObjectId(), - title: "Title5", - year: 2013 - }, - { - _id: new ObjectId(), - title: "Title6", - year: 2010 - }, - { - _id: new ObjectId(), - title: "Title7", - year: 2011 - }, - { - _id: new ObjectId(), - title: "Title8", - year: 2012 - }, - { - _id: new ObjectId(), - title: "Title9", - year: 2010 - }, - { - _id: new ObjectId(), - title: "Title10", - year: 2011 - }, - { - _id: new ObjectId(), - title: "Title11", - year: 2012 - }, - { - _id: new ObjectId(), - title: "Title12", - year: 2010 - }, - { - _id: new ObjectId(), - title: "Title13", - year: 2011 - }, - { - _id: new ObjectId(), - title: "Title14", - year: 2009 - } -]; - -exports.reviews = [ - { - _id: new ObjectId(), - body: "This is a movie review!", - length: 127 - } -]; diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/fixtures/movies/index.jade b/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/fixtures/movies/index.jade deleted file mode 100644 index a17ae31..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/fixtures/movies/index.jade +++ /dev/null @@ -1,4 +0,0 @@ -h1 index - -each item, i in locals - li #{item.title}: #{i} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/fixtures/movies/show.jade b/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/fixtures/movies/show.jade deleted file mode 100644 index 7cb6b3c..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/fixtures/movies/show.jade +++ /dev/null @@ -1,3 +0,0 @@ -h1 show - -#{title} diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.chainable.js b/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.chainable.js deleted file mode 100644 index 89b083f..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.chainable.js +++ /dev/null @@ -1,48 +0,0 @@ -var should = require('should'), - request = require('supertest'), - restful = require('../'), - mongoose = require('mongoose'), - sinon = require('sinon'); - -describe('Model', function() { - - before(function() { - restful.model('posts', mongoose.Schema({ title: 'string' })); - }); - it('should return a mongoose model', function() { - var posts = restful.model('posts'); - - posts.should.have.property('methods'); - posts.should.have.property('update'); - posts.should.have.property('remove'); - posts.should.have.property('updateOptions'); - posts.should.have.property('removeOptions'); - }); - it('should add methods in a chainable way', function() { - var posts = restful.model('posts'); - posts.allowed_methods.should.have.property('get'); - posts.methods(['get', 'post', 'put']) - .updateOptions({}) - .removeOptions({}) - .template('/idk/where/this/goes/'); - posts.allowed_methods.should.containEql('get'); - posts.allowed_methods.should.containEql('post'); - posts.allowed_methods.should.containEql('put'); - posts.update_options.should.be.an.instanceOf(Object); - posts.remove_options.should.be.an.instanceOf(Object); - posts.templateRoot.should.eql('/idk/where/this/goes'); - - }); - it('should be updateable', function(done) { - var Posts = restful.model('posts'); - Posts.create({ - title: "First post" - }, function(err, post) { - post.title.should.equal('First post'); - Posts.update({_id: post._id}, { title: "Second post"}, function(err, count, resp) { - count.n.should.equal(1); - done() - }); - }) - }); -}); diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.excludes.js b/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.excludes.js deleted file mode 100644 index ca5e902..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.excludes.js +++ /dev/null @@ -1,21 +0,0 @@ -var config = require('./fixtures/config'), - request = require('supertest'); - -describe('Model', function() { - var app, movie, user; - before(function() { - app = config.app; - movie = config.movie; - user = config.user; - }); - describe('excludes', function() { - it('should exclude the excluded fields', function(done) { - request(app) - .get('/api/movies/' + config.movies[0]._id + '/') - .end(function(err, res) { - res.body.should.not.have.property('secret'); - done(); - }); - }); - }); -}); diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.filters.js b/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.filters.js deleted file mode 100644 index 5cab60d..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.filters.js +++ /dev/null @@ -1,191 +0,0 @@ -var should = require('should'), - request = require('supertest'), - sinon = require('sinon'); - -describe('Model', function() { - var config, - movies, - users, - app, - movie1, - movie2, - movie3, - user1, - user2; - before(function(done) { - config = require('./fixtures/config'); - config.ready(function() { - app = config.app; - movies = config.movie; - users = config.user; - movie1 = config.movies[0]; - movie2 = config.movies[1]; - movie3 = config.movies[2]; - user1 = config.users[0]; - user2 = config.users[1]; - done(); - }); - }); - describe('filters', function() { - it('should limit GET to 10', function(done) { - request(app) - .get('/api/movies?limit=10') - .end(function(err, res) { - res.body.length.should.equal(10); - done(); - }); - }); - it('should limit GET to 1', function(done) { - request(app) - .get('/api/movies?limit=1') - .end(function(err, res) { - res.body.length.should.equal(1); - done(); - }); - }); - it('should skip by 5', function(done) { - request(app) - .get('/api/movies?limit=1&skip=5') - .end(function(err, res) { - request(app) - .get('/api/movies?limit=6') - .end(function(err2, res2) { - res.body[0].should.eql(res2.body[res2.body.length-1]); - done(); - }); - }); - }); - it('should select fields', function(done) { - request(app) - .get('/api/movies?select=year') - .end(function(err, res) { - res.body.forEach(function(movie) { - movie.should.not.have.property('title'); - movie.should.have.property('year'); - }); - done(); - }); - }); - it('should sort documents', function(done) { - request(app) - .get('/api/movies?sort=year') - .end(function(err, res) { - for(var i = 1; i < res.body.length; i++) { - (res.body[i].year >= res.body[i-1].year).should.be.true; - } - done(); - }); - }); - it('should filter fields using equal', function(done) { - request(app) - .get('/api/movies?year=2011') - .end(function(err, res) { - res.body.forEach(function(movie) { - movie.year.should.equal(2011); - }); - done(); - }); - }); - it('should filter fields using gte', function(done) { - request(app) - .get('/api/movies?year__gte=2012') - .end(function(err, res) { - res.body.forEach(function(movie) { - movie.year.should.be.above(2011); - }); - done(); - }); - }); - it('should filter fields using gt', function(done) { - request(app) - .get('/api/movies?year__gt=2011') - .end(function(err, res) { - res.body.forEach(function(movie) { - movie.year.should.be.above(2011); - }); - done(); - }); - }); - it('should filter fields using lt', function(done) { - request(app) - .get('/api/movies?year__lt=2013') - .end(function(err, res) { - res.body.forEach(function(movie) { - movie.year.should.be.below(2013); - }); - done(); - }); - }); - it('should filter fields using lte', function(done) { - request(app) - .get('/api/movies?year__lte=2012') - .end(function(err, res) { - res.body.forEach(function(movie) { - movie.year.should.be.below(2013); - }); - done(); - }); - }); - it('should filter fields using ne', function(done) { - request(app) - .get('/api/movies?year__ne=2013') - .end(function(err, res) { - res.body.forEach(function(movie) { - movie.year.should.not.equal(2013); - }); - done(); - }); - }); - it('should filter fields using regex', function(done) { - request(app) - .get('/api/movies?title__regex=2') - .end(function(err, res) { - res.body.forEach(function(movie) { - movie.title.should.containEql('2'); - }); - done(); - }); - }); - it('should filter fields using regex with options', function(done) { - request(app) - .get('/api/movies?title__regex=' + encodeURIComponent("/tITLE/i")) - .end(function(err, res) { - res.body.length.should.be.above(0); - res.body.forEach(function(movie) { - movie.title.toLowerCase().should.containEql('title'); - }); - done(); - }); - }); - it('should populate an objectId', function(done) { - request(app) - .get('/api/movies/' + movie1._id + '?populate=creator') - .end(function(err, res) { - res.body.creator.username.should.equal(user1.username); - res.body.creator.pass_hash.should.equal(user1.pass_hash); - done(); - }); - }); - it('should filter using in', function(done) { - request(app) - .get('/api/movies?year__in=2010,2011') - .end(function(err, res) { - res.body.forEach(function(movie) { - [2010,2011].indexOf(movie.year).should.be.above(-1); - }); - done(); - }); - }); - it('should filter using nin', function(done) { - request(app) - .get('/api/movies?year__nin=2012,2013,2014') - .end(function(err, res) { - res.body.length.should.be.above(0) - res.body.forEach(function(movie) { - [2012,2013,2014].indexOf(movie.year).should.equal(-1); - }); - done(); - }); - }); - }); -}); diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.handle.js b/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.handle.js deleted file mode 100644 index 10b0e22..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.handle.js +++ /dev/null @@ -1,54 +0,0 @@ -var should = require('should'), - request = require('supertest'), - config = require('./fixtures/config'), - sinon = require('sinon'); - -describe.skip('Model', function() { - var movies, - users, - app, - movie1, - movie2, - movie3, - user1, - user2; - before(function() { - app = config.app; - movies = config.movie; - users = config.user; - movie1 = config.movies[0]; - movie2 = config.movies[1]; - movie3 = config.movies[2]; - user1 = config.users[0]; - user2 = config.users[1]; - }); - describe('.handle', function() { - it('should handle a pseudo-get route', function(done) { - request(app) - .get('/api/movies/fakeget') - .end(function(err, res) { - request(app) - .get('/api/movies') - .end(function(err2, res2) { - res.body.should.eql(res2.body); - done(); - }); - }); - }); - it('should handle a pseudo-postroute', function(done) { - request(app) - .post('/api/movies/fakepost') - .send({ - title: "A very stupid movie", - }) - .end(function(err, res) { - res.body.title.should.equal('A very stupid movie'); - res.body._id.should.not.be.empty; - movies.Model.findById(res.body._id, function(err, model) { - model.title.should.equal('A very stupid movie'); - done(); - }); - }); - }); - }); -}); 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 deleted file mode 100644 index 9207cbc..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.hooks.js +++ /dev/null @@ -1,52 +0,0 @@ -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); - }); - }); - }); -}); diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.js b/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.js deleted file mode 100644 index a51d6cb..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.js +++ /dev/null @@ -1,301 +0,0 @@ -var should = require('should'), - request = require('supertest'), - config = require('./fixtures/config'), - sinon = require('sinon'), - checkForHexRegExp = new RegExp("^[0-9a-fA-F]{24}$"); - -var oldA = should.Assertion.prototype.a; -should.Assertion.prototype.a = function(type, desc) { - if (type === '_id') { - this.assert(checkForHexRegExp.test(this.obj), - function() { return 'expected ' + this.inspect + ' to be a ' + type + (desc ? " | " + desc : ""); }, - function(){ return 'expected ' + this.inspect + ' not to be a ' + type + (desc ? " | " + desc : ""); }); - return this; - } - return oldA.call(this, type, desc); -}; - -describe('Model', function() { - var movies, - users, - app, - movie1, - movie2, - movie3, - user1, - user2, - review; - before(function(done) { - config.ready(function() { - app = config.app; - movies = config.movie; - users = config.user; - movie1 = config.movies[0]; - movie2 = config.movies[1]; - movie3 = config.movies[2]; - user1 = config.users[0]; - user2 = config.users[1]; - review = config.reviews[0]; - done(); - }); - }); - describe('handlers', function() { - it('should handle schema request', function(done) { - request(app) - .get('/api/movies/schema') - .expect('Content-Type', /json/) - .expect(200) - .end(function(err, res) { - res.body.resource.should.equal('movies'); - res.body.allowed_methods.should.eql(Object.keys(movies.allowed_methods)); - res.body.fields.should.be.an.instanceOf(Object); - Object.keys(movies.schema.paths).forEach(function(path) { - res.body.fields.should.have.property(path); - }); - res.body.list_uri.should.equal('/api/movies'); - res.body.detail_uri.should.equal('/api/movies/:id'); - done(); - }); - }); - - it('should dispatch to GET', function(done) { - request(app) - .get('/api/movies') - .expect('Content-Type', /json/) - .expect(200, done); - }); - it('should fail POST with no data', function(done) { - request(app) - .post('/api/movies') - .expect('Content-Type', /json/) - .expect(400, done); - }); - it('should POST with data', function(done) { - request(app) - .post('/api/movies') - .send({ - title: "A very stupid movie", - year: "214243" - }) - .expect('Content-Type', /json/) - .expect(201 ) - .end(function(err, res) { - res.body.title.should.equal('A very stupid movie'); - res.body._id.should.type('string'); - done(err); - }); - }); - it('should PUT data', function(done) { - request(app) - .put('/api/movies/' + movie2._id) - .send({ - title: 'I changed the movie title' - }) - .expect('Content-Type', /json/) - .expect(200) - .end(function(err, res) { - res.body.title.should.equal('I changed the movie title'); - movies.findById(movie2._id, function(err, movie) { - movie.title.should.equal('I changed the movie title'); - done(); - }); - }); - }); - it('should fail on GET missing resource', function(done) { - request(app) - .get('/api/movies/55e8169191ad293c221a6c9d') - .expect(404, done); - }); - it('should fail on PUT missing resource (shouldUseAtomicUpdate=false)', function(done) { - request(app) - .put('/api/genres/55e8169191ad293c221a6c9d') - .send({ - name: "Mysterious genre" - }) - .expect(404, done); - }); - it('should fail on PUT missing resource (shouldUseAtomicUpdate=true)', function(done) { - request(app) - .put('/api/movies/55e8169191ad293c221a6c9d') - .send({ - title: "Mysterious genre" - }) - .expect(404, done); - }); - it('should fail on DELETE missing resource (shouldUseAtomicUpdate=false)', function(done) { - request(app) - .del('/api/genres/55e8169191ad293c221a6c9d') - .expect(404, done); - }); - it('should fail on PUT without filter on unsortable model', function(done) { - request(app) - .put('/api/movies') - .send({ - title: "A very stupid movie" - }) - .expect(404, done); - }); - it('should fail on DELETE without a filter', function(done) { - request(app) - .del('/users') - .expect(404, done); - }); - it('should DELETE a movie', function(done) { - request(app) - .del('/api/movies/' + movie3._id) - .expect(200) - .expect('Content-Type', /json/) - .end(function(err, res) { - movies.findById(movie3._id, function(err, movie) { - should.not.exist(movie); - done(); - }); - }); - }); - it("shouldn't put data on deleted resource", function(done) { - request(app) - .del('/api/movies/' + config.movies[5]._id) - .end(function(err, res) { - request(app) - .put('/api/movies/' + config.movies[5]._id) - .send({ - title: 'But I already deleted you' - }) - .expect(404, done); - }); - }); - it('should 400 deleting a resource twice', function(done) { - request(app) - .del('/api/movies/' + config.movies[6]._id) - .end(function() { - request(app) - .del('/api/movies/' + config.movies[6]._id) - .expect(404, done); - }); - }); - it('should 404 on undefined route', function(done) { - request(app) - .del('/api/movies') - .expect(404, done); - }); - it('should return a nested model at the generated endpoint creator', function(done) { - request(app) - .get('/api/movies/' + movie1._id + '/creator') - .expect('Content-Type', /json/) - .expect(200) - .end(function(err, res) { - if (err) return done(err); - res.should.be.json; - res.body.username.should.equal('test'); - res.body.pass_hash.should.equal(12374238719845134515); - done(); - }); - }); - it('should 404 if we request an object endpoint without a filter', function(done) { - request(app) - .get('/api/movies/creator') - .expect(404, done); - }); - it('should retrieve a deeply nested endpoint', function(done) { - request(app) - .get('/api/movies/' + movie1._id + '/meta/director') - .expect('Content-Type', /json/) - .expect(200) - .end(function(err, res) { - res.should.be.json; - res.body.username.should.equal('test2'); - res.body.pass_hash.should.equal(1237987381263189273123); - done(); - }); - - }); - it('should 404 on a nested object', function(done) { - request(app) - .get('/api/movies/' + movie1._id + '/meta') - .expect(404, done) - }); - it('should get a user defined route', function(done) { - request(app) - .get('/api/movies/recommend') - .expect('Content-Type', /json/) - .expect(200) - .end(function(err, res) { - res.should.be.json; - res.body.recommend.should.equal("called"); - done(); - }); - }); - it('should get anotheroute (user defined route)', function(done) { - request(app) - .get('/api/movies/anotherroute') - .expect('Content-Type', /json/) - .expect(200) - .end(function(err, res) { - res.should.be.json; - res.body.anotherroute.should.equal("called"); - done(); - }); - }); - it('should get athirdroute (user defined route)', function(done) { - request(app) - .get('/api/movies/' + movie1._id + '/athirdroute') - .expect('Content-Type', /json/) - .expect(200) - .end(function(err, res) { - res.should.be.json; - res.body.athirdroute.should.equal("called"); - done(); - }); - }); - it('should fail athirdroute (user defined route)', function(done) { - request(app) - .get('/api/movies/athirdroute') - .expect(404, done); - }); - it('should fail athirdroute (user defined route)', function(done) { - request(app) - .put('/api/movies/' + movie1._id + '/athirdroute') - .expect(404, done); - }); - it('should allow put of entire object', function(done) { - request(app) - .get('/api/movies/' + config.movies[7]._id) - .end(function(err, res) { - var movie = res.body; - movie.title = 'A different title'; - request(app) - .put('/api/movies/' + movie._id) - .send(movie) - .expect('Content-Type', /json/) - .expect(201) - .end(function(err, res) { - res.body.title.should.equal('A different title'); - done(); - }); - }); - }); - it('should allow overriding of schema route', function(done) { - request(app) - .get('/users/schema') - .expect(404, done); - }); - it('should allow multiple handlers to be called on a single route', function(done) { - request(app) - .get('/api/movies/pshh') - .expect(200) - .end(function(err, res) { - res.body.pshh.should.equal('called'); - done(err); - }); - }); - it('should allow get request for model with field named `length`', function(done) { - request(app) - .get('/api/reviews/' + review._id) - .expect(200) - .end(function(err, res) { - res.body.body.should.equal('This is a movie review!'); - done(err); - }); - }); - }); -}); diff --git a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.template.js b/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.template.js deleted file mode 100644 index 8174391..0000000 --- a/common/src/main/webapp/usageguide/appserver/node_modules/node-restful/test/model.template.js +++ /dev/null @@ -1,62 +0,0 @@ -var should = require('should'), - request = require('supertest'), - config = require('./fixtures/config'), - sinon = require('sinon'); - -describe.skip('Model', function() { - var movies, - users, - app, - movie1, - movie2, - movie3, - user1, - user2; - before(function() { - app = config.app; - movies = config.movie; - users = config.user; - movie1 = config.movies[0]; - movie2 = config.movies[1]; - movie3 = config.movies[2]; - user1 = config.users[0]; - user2 = config.users[1]; - }); - describe('.template(route, filters)', function() { - it('should work for get', function() { - var template = movies.template(['get'], []); - template.should.equal('index'); - }); - it('should work for getDetail', function() { - var template = movies.template(['get'], [{ key: '_id', value: 'ad' }]); - template.should.equal('show'); - }); - }); - describe('format=html', function() { - it('should render index', function(done) { - request(app) - .get('/api/movies?format=html') - .expect('Content-Type', /html/) - .end(function(err, res) { - res.text.should.match(/index/); - res.text.should.match(new RegExp(movie1.title)); - res.text.should.match(new RegExp(movie2.title)); - res.text.should.match(new RegExp(movie3.title)); - done(); - }); - }); - it('should render show', function(done) { - request(app) - .get('/api/movies/' + movie1._id + '/?format=html') - .expect('Content-Type', /html/) - .end(function(err, res) { - res.text.should.match(/show/); - res.text.should.match(new RegExp(movie1.title)); - res.text.should.not.match(new RegExp(movie2.title)); - res.text.should.not.match(new RegExp(movie3.title)); - done(); - }); - - }); - }); -}); |