|
2 | 2 |
|
3 | 3 | var express = require('../') |
4 | 4 | , request = require('supertest'); |
| 5 | +var shouldSkipQuery = require('./support/utils').shouldSkipQuery |
5 | 6 |
|
6 | 7 | describe('req', function(){ |
7 | 8 | describe('.fresh', function(){ |
@@ -46,5 +47,42 @@ describe('req', function(){ |
46 | 47 | .get('/') |
47 | 48 | .expect(200, 'false', done); |
48 | 49 | }) |
| 50 | + |
| 51 | + it('should return true for a QUERY request with a body when the resource is not modified', function(done){ |
| 52 | + if (shouldSkipQuery(process.versions.node)) { |
| 53 | + this.skip() |
| 54 | + } |
| 55 | + var app = express(); |
| 56 | + var etag = '"12345"'; |
| 57 | + |
| 58 | + app.use(function(req, res){ |
| 59 | + res.set('ETag', etag); |
| 60 | + res.send(req.fresh); |
| 61 | + }); |
| 62 | + |
| 63 | + request(app) |
| 64 | + .query('/') |
| 65 | + .set('If-None-Match', etag) |
| 66 | + .send({ ids: ['a', 'b'] }) |
| 67 | + .expect(304, done); |
| 68 | + }) |
| 69 | + |
| 70 | + it('should return false for a QUERY request with a body when the resource is modified', function(done){ |
| 71 | + if (shouldSkipQuery(process.versions.node)) { |
| 72 | + this.skip() |
| 73 | + } |
| 74 | + var app = express(); |
| 75 | + |
| 76 | + app.use(function(req, res){ |
| 77 | + res.set('ETag', '"123"'); |
| 78 | + res.send(req.fresh); |
| 79 | + }); |
| 80 | + |
| 81 | + request(app) |
| 82 | + .query('/') |
| 83 | + .set('If-None-Match', '"12345"') |
| 84 | + .send({ ids: ['a', 'b'] }) |
| 85 | + .expect(200, 'false', done); |
| 86 | + }) |
49 | 87 | }) |
50 | 88 | }) |
0 commit comments