Skip to content
Myr

resource.js

This file

Path

test/acceptance/resource.js

68 lines · 1.8 KiB · JavaScript

Last changed by

Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d

History of this file

Take it

The walk stopped after 200 commits: lines older than 34c83d7 point at it.

3.4.7Jonathan Ongbefore adoption34c83d7

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

Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d

line 2why, one step back
2var request = require('supertest')

3.4.7Jonathan Ongbefore adoption34c83d7

lines 3–28why, one step back
3
4describe('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 })28

Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d

lines 29–36why, one step back
29 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 })36

3.4.7Jonathan Ongbefore adoption34c83d7

lines 37–45why, one step back
37 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(){

Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d

line 46why, one step back
46 it('should delete user 1', function(done){

3.4.7Jonathan Ongbefore adoption34c83d7

lines 47–49why, one step back
47 request(app)
48 .del('/users/1')49 .expect(/^destroyed/,done)

Merge tag '3.9.0'Douglas Christopher Wilsonbefore adoptiondb4448d

lines 50–57why, one step back
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)

3.4.7Jonathan Ongbefore adoption34c83d7

lines 58–68why, one step back
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})