2 var request = require('supertest');
3 var assert = require('assert');
5 var Server = require('..').Server;
7 var listen = require('./helpers/listen');
9 describe('tiny-lr', function() {
13 describe('GET /', function() {
14 it('respond with nothing, but respond', function(done){
17 .expect('Content-Type', /json/)
18 .expect(/\{"tinylr":"Welcome","version":"[\d].[\d].[\d]+"\}/)
22 it('unknown route respond with proper 404 and error message', function(done){
25 .expect('Content-Type', /json/)
26 .expect('{"error":"not_found","reason":"no such route"}')
32 describe('GET /changed', function() {
33 it('with no clients, no files', function(done) {
36 .expect('Content-Type', /json/)
37 .expect(/"clients":\[\]/)
38 .expect(/"files":\[\]/)
42 it('with no clients, some files', function(done) {
44 .get('/changed?files=gonna.css,test.css,it.css')
45 .expect('Content-Type', /json/)
46 .expect('{"clients":[],"files":["gonna.css","test.css","it.css"]}')
51 describe('POST /changed', function() {
52 it('with no clients, no files', function(done) {
55 .expect('Content-Type', /json/)
56 .expect(/"clients":\[\]/)
57 .expect(/"files":\[\]/)
61 it('with no clients, some files', function(done) {
62 var data = { clients: [], files: ['cat.css', 'sed.css', 'ack.js'] };
67 .send({ files: data.files })
68 .expect('Content-Type', /json/)
69 .expect(JSON.stringify(data))
74 describe('GET /livereload.js', function() {
75 it('respond with livereload script', function(done) {
77 .get('/livereload.js')
83 describe('GET /kill', function() {
84 it('shutdown the server', function(done) {
85 var srv = this.server;
88 .expect(200, function(err) {
89 if(err) return done(err);
90 assert.ok(!srv._handle);