Sha256: ca11498b0fbfe2e42b80abeb50a0a943d45f1f9395c1f58578be7a3ce618f6ca

Contents?: true

Size: 1.39 KB

Versions: 12

Compression:

Stored size: 1.39 KB

Contents

(function () {
  /*global describe, it*/

  'use strict';

  var should = require('should'),
    express = require('express'),
    supertest = require('supertest'),
    cors = require('../lib');

  var app,
    mainRouter,
    itemsRouter;

  /* -------------------------------------------------------------------------- */

  itemsRouter = new express.Router();
  itemsRouter.get('/', function (req, res) {
    res.send('hello world');
  });

  mainRouter = new express.Router();
  mainRouter.use('/items', itemsRouter);

  app = express();
  app.use(cors());
  app.use(mainRouter);

  /* -------------------------------------------------------------------------- */

  describe('issue  #31', function () {
    it('OPTIONS works', function (done) {
      supertest(app)
        .options('/items')
        .expect(204)
        .set('Origin', 'http://example.com')
        .end(function (err, res) {
          should.not.exist(err);
          res.headers['access-control-allow-origin'].should.eql('*');
          done();
        });
    });

    it('GET works', function (done) {
      supertest(app)
        .get('/items')
        .expect(200)
        .set('Origin', 'http://example.com')
        .end(function (err, res) {
          should.not.exist(err);
          res.headers['access-control-allow-origin'].should.eql('*');
          res.text.should.eql('hello world');
          done();
        });
    });
  });

}());

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
blsk-sevcore-0.0.2 blsk_old/bluesky-doc/bluesky-doc/node_modules/cors/test/issue-31.js
webpack_rails-2.0.1 lib/webpack_rails/node_modules/cors/test/issue-31.js
webpack_rails-2.0.0 lib/webpack_rails/node_modules/cors/test/issue-31.js
webpack_rails-1.3.1 lib/webpack_rails/node_modules/cors/test/issue-31.js
webpack_rails-1.3.0 lib/webpack_rails/node_modules/cors/test/issue-31.js
webpack_rails-1.2.2 lib/webpack_rails/node_modules/cors/test/issue-31.js
webpack_rails-1.2.1 lib/webpack_rails/node_modules/cors/test/issue-31.js
webpack_rails-1.2.0 lib/webpack_rails/node_modules/cors/test/issue-31.js
webpack_rails-1.1.1 lib/webpack_rails/node_modules/cors/test/issue-31.js
webpack_rails-1.1.0 lib/webpack_rails/node_modules/cors/test/issue-31.js
webpack_rails-1.0.1 lib/webpack_rails/node_modules/cors/test/issue-31.js
webpack_rails-1.0.0 lib/webpack_rails/node_modules/cors/test/issue-31.js