Skip to content
Myr

resource.js

This file

Path

test/acceptance/resource.js

68 lines · 1.8 KiB · JavaScript

Last changed by

examples: make main app file names consistentDouglas Christopher Wilsonbefore adoptionb1d0c19

History of this file

Take it

The walk stopped after 200 commits: lines older than 6bc7574 point at it.

examples: make main app file names consistentDouglas Christopher Wilsonbefore adoptionb1d0c19

line 1why, one step back
1var app = require('../../examples/resource')

docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574

lines 2–68why, one step back
2var request = require('supertest')
34describe('resource', function(){5 describe('GET /', function(){6 it('should respond with instructions', function(done){7 request(app)8 .get('/')9 .expect(/^<h1>Examples:<\/h1>/,done)10 })11 })1213 describe('GET /users', function(){14 it('should respond with all users', function(done){15 request(app)16 .get('/users')17 .expect(/^\[{"name":"tj"},{"name":"ciaran"},{"name":"aaron"},{"name":"guillermo"},{"name":"simon"},{"name":"tobi"}\]/,done)18 })19 })2021 describe('GET /users/1', function(){22 it('should respond with user 1', function(done){23 request(app)24 .get('/users/1')25 .expect(/^{"name":"ciaran"}/,done)26 })27 })2829 describe('GET /users/9', function(){30 it('should respond with error', function(done){31 request(app)32 .get('/users/9')33 .expect('{"error":"Cannot find user"}', done)34 })35 })3637 describe('GET /users/1..3', function(){38 it('should respond with users 1 through 3', function(done){39 request(app)40 .get('/users/1..3')41 .expect(/^<ul><li>ciaran<\/li>\n<li>aaron<\/li>\n<li>guillermo<\/li><\/ul>/,done)42 })43 })4445 describe('DELETE /users/1', function(){46 it('should delete user 1', function(done){47 request(app)48 .del('/users/1')49 .expect(/^destroyed/,done)50 })51 })5253 describe('DELETE /users/9', function(){54 it('should fail', function(done){55 request(app)56 .del('/users/9')57 .expect('Cannot find user', done)58 })59 })6061 describe('GET /users/1..3.json', function(){62 it('should respond with users 2 and 3 as json', function(done){63 request(app)64 .get('/users/1..3.json')65 .expect(/^\[null,{"name":"aaron"},{"name":"guillermo"}\]/,done)66 })67 })68})