fix(deps)!: mime-types@^3.0.0 (#5882)
[express.git] / test / acceptance / route-separation.js
blob867fd2952713f5bfe9220fcbe245bc2952918734
2 var app = require('../../examples/route-separation')
3 var request = require('supertest')
5 describe('route-separation', function () {
6 describe('GET /', function () {
7 it('should respond with index', function (done) {
8 request(app)
9 .get('/')
10 .expect(200, /Route Separation Example/, done)
14 describe('GET /users', function () {
15 it('should list users', function (done) {
16 request(app)
17 .get('/users')
18 .expect(/TJ/)
19 .expect(/Tobi/)
20 .expect(200, done)
24 describe('GET /user/:id', function () {
25 it('should get a user', function (done) {
26 request(app)
27 .get('/user/0')
28 .expect(200, /Viewing user TJ/, done)
31 it('should 404 on missing user', function (done) {
32 request(app)
33 .get('/user/10')
34 .expect(404, done)
38 describe('GET /user/:id/view', function () {
39 it('should get a user', function (done) {
40 request(app)
41 .get('/user/0/view')
42 .expect(200, /Viewing user TJ/, done)
45 it('should 404 on missing user', function (done) {
46 request(app)
47 .get('/user/10/view')
48 .expect(404, done)
52 describe('GET /user/:id/edit', function () {
53 it('should get a user to edit', function (done) {
54 request(app)
55 .get('/user/0/edit')
56 .expect(200, /Editing user TJ/, done)
60 describe('PUT /user/:id/edit', function () {
61 it('should edit a user', function (done) {
62 request(app)
63 .put('/user/0/edit')
64 .set('Content-Type', 'application/x-www-form-urlencoded')
65 .send({ user: { name: 'TJ', email: 'tj-invalid@vision-media.ca' } })
66 .expect(302, function (err) {
67 if (err) return done(err)
68 request(app)
69 .get('/user/0')
70 .expect(200, /tj-invalid@vision-media\.ca/, done)
75 describe('POST /user/:id/edit?_method=PUT', function () {
76 it('should edit a user', function (done) {
77 request(app)
78 .post('/user/1/edit?_method=PUT')
79 .set('Content-Type', 'application/x-www-form-urlencoded')
80 .send({ user: { name: 'Tobi', email: 'tobi-invalid@vision-media.ca' } })
81 .expect(302, function (err) {
82 if (err) return done(err)
83 request(app)
84 .get('/user/1')
85 .expect(200, /tobi-invalid@vision-media\.ca/, done)
90 describe('GET /posts', function () {
91 it('should get a list of posts', function (done) {
92 request(app)
93 .get('/posts')
94 .expect(200, /Posts/, done)