| 
1 |  | -var os = require('os')  | 
2 | 1 | var fs = require('fs')  | 
3 | 2 | var path = require('path')  | 
4 | 3 | var cp = require('child_process')  | 
5 | 4 | var assert = require('assert')  | 
6 | 5 | var supertest = require('supertest')  | 
7 | 6 | var rmrf = require('rimraf')  | 
 | 7 | +var express = require('express')  | 
8 | 8 | var serverReady = require('server-ready')  | 
9 | 9 | var pkg = require('../../package.json')  | 
10 | 10 | 
 
  | 
@@ -95,12 +95,17 @@ describe('cli', function () {  | 
95 | 95 | 
 
  | 
96 | 96 |   })  | 
97 | 97 | 
 
  | 
98 |  | -  describe('http://jsonplaceholder.typicode.com/db', function () {  | 
 | 98 | +  describe('http://localhost:8080/db', function () {  | 
99 | 99 | 
 
  | 
100 | 100 |     beforeEach(function (done) {  | 
101 |  | -      child = cli(['http://jsonplaceholder.typicode.com/db'])  | 
102 |  | -      this.timeout(10000)  | 
103 |  | -      serverReady(PORT, done)  | 
 | 101 | +      var fakeServer = express()  | 
 | 102 | +      fakeServer.get('/db', function (req, res) {  | 
 | 103 | +        res.jsonp({ posts: [] })  | 
 | 104 | +      })  | 
 | 105 | +      fakeServer.listen(8080, function () {  | 
 | 106 | +        child = cli(['http://localhost:8080/db'])  | 
 | 107 | +        serverReady(PORT, done)  | 
 | 108 | +      })  | 
104 | 109 |     })  | 
105 | 110 | 
 
  | 
106 | 111 |     it('should support URL file', function (done) {  | 
@@ -247,31 +252,29 @@ describe('cli', function () {  | 
247 | 252 | 
 
  | 
248 | 253 |   // FIXME test fails on OS X and maybe on Windows  | 
249 | 254 |   // But manually updating db.json works...  | 
250 |  | -  if (os.platform() === 'linux') {  | 
251 |  | -    describe('--watch db.json -r routes.json', function () {  | 
 | 255 | +  describe('--watch db.json -r routes.json', function () {  | 
252 | 256 | 
 
  | 
253 |  | -      beforeEach(function (done) {  | 
254 |  | -        child = cli(['--watch', dbFile, '-r', routesFile])  | 
255 |  | -        serverReady(PORT, done)  | 
256 |  | -      })  | 
257 |  | - | 
258 |  | -      it('should watch db file', function (done) {  | 
259 |  | -        fs.writeFileSync(dbFile, JSON.stringify({ foo: [] }))  | 
260 |  | -        setTimeout(function () {  | 
261 |  | -          request.get('/foo').expect(200, done)  | 
262 |  | -        }, 1000)  | 
263 |  | -      })  | 
 | 257 | +    beforeEach(function (done) {  | 
 | 258 | +      child = cli(['--watch', dbFile, '-r', routesFile])  | 
 | 259 | +      serverReady(PORT, done)  | 
 | 260 | +    })  | 
264 | 261 | 
 
  | 
265 |  | -      it('should watch routes file', function (done) {  | 
266 |  | -        // Can be very slow  | 
267 |  | -        this.timeout(10000)  | 
268 |  | -        fs.writeFileSync(routesFile, JSON.stringify({ '/api/': '/' }))  | 
269 |  | -        setTimeout(function () {  | 
270 |  | -          request.get('/api/posts').expect(200, done)  | 
271 |  | -        }, 9000)  | 
272 |  | -      })  | 
 | 262 | +    it('should watch db file', function (done) {  | 
 | 263 | +      fs.writeFileSync(dbFile, JSON.stringify({ foo: [] }))  | 
 | 264 | +      setTimeout(function () {  | 
 | 265 | +        request.get('/foo').expect(200, done)  | 
 | 266 | +      }, 1000)  | 
 | 267 | +    })  | 
273 | 268 | 
 
  | 
 | 269 | +    it('should watch routes file', function (done) {  | 
 | 270 | +      // Can be very slow  | 
 | 271 | +      this.timeout(10000)  | 
 | 272 | +      fs.writeFileSync(routesFile, JSON.stringify({ '/api/': '/' }))  | 
 | 273 | +      setTimeout(function () {  | 
 | 274 | +        request.get('/api/posts').expect(200, done)  | 
 | 275 | +      }, 9000)  | 
274 | 276 |     })  | 
275 |  | -  }  | 
 | 277 | + | 
 | 278 | +  })  | 
276 | 279 | 
 
  | 
277 | 280 | })  | 
0 commit comments