PHP Classes

File: public/js/lib/director/test/server/http/stream-test.js

Recommend this page to a friend!
  Classes of Sergey Beskorovayniy  >  Silex MVC Blog  >  public/js/lib/director/test/server/http/stream-test.js  >  Download  
File: public/js/lib/director/test/server/http/stream-test.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Silex MVC Blog
MVC based blog using on the Silex micro-framework
Author: By
Last change:
Date: 5 years ago
Size: 1,315 bytes
 

Contents

Class file image Download
/*
 * stream-test.js: Tests for streaming HTTP in director.
 *
 * (C) 2011, Charlie Robbins, Paolo Fragomeni, & the Contributors.
 * MIT LICENSE
 *
 */

var assert = require('assert'),
    http = require('http'),
    vows = require('vows'),
    request = require('request'),
    director = require('../../../lib/director'),
    helpers = require('../helpers'),
    macros = helpers.macros,
    handlers = helpers.handlers

vows.describe('director/http/stream').addBatch({
  "An instance of director.http.Router": {
    "with streaming routes": {
      topic: function () {
        var router = new director.http.Router();
        router.post(/foo\/bar/, { stream: true }, handlers.streamBody);
        router.path('/a-path', function () {
          this.post({ stream: true }, handlers.streamBody);
        });

        return router;
      },
      "when passed to an http.Server instance": {
        topic: function (router) {
          helpers.createServer(router)
            .listen(9092, this.callback);
        },
        "a POST request to /foo/bar": macros.assertPost(9092, 'foo/bar', {
          foo: 'foo',
          bar: 'bar'
        }),
        "a POST request to /a-path": macros.assertPost(9092, 'a-path', {
          foo: 'foo',
          bar: 'bar'
        })
      }
    }
  }
}).export(module);
For more information send a message to info at phpclasses dot org.