Sha256: 4b2d4006120a9404004865f5862f536bfda7759f8d32a73e28dddfd7d4b75cb1

Contents?: true

Size: 1.42 KB

Versions: 12

Compression:

Stored size: 1.42 KB

Contents

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

  'use strict';

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

  var app,
    corsOptions;

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

  app = express();
  corsOptions = {
    origin: true,
    methods: ['POST'],
    credentials: true,
    maxAge: 3600
  };
  app.options('/api/login', cors(corsOptions));
  app.post('/api/login', cors(corsOptions), function (req, res) {
    res.send('LOGIN');
  });

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

  describe('issue  #2', function () {
    it('OPTIONS works', function (done) {
      supertest(app)
        .options('/api/login')
        .expect(204)
        .set('Origin', 'http://example.com')
        .end(function (err, res) {
          should.not.exist(err);
          res.headers['access-control-allow-origin'].should.eql('http://example.com');
          done();
        });
    });
    it('POST works', function (done) {
      supertest(app)
        .post('/api/login')
        .expect(200)
        .set('Origin', 'http://example.com')
        .end(function (err, res) {
          should.not.exist(err);
          res.headers['access-control-allow-origin'].should.eql('http://example.com');
          res.text.should.eql('LOGIN');
          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-2.js
webpack_rails-2.0.1 lib/webpack_rails/node_modules/cors/test/issue-2.js
webpack_rails-2.0.0 lib/webpack_rails/node_modules/cors/test/issue-2.js
webpack_rails-1.3.1 lib/webpack_rails/node_modules/cors/test/issue-2.js
webpack_rails-1.3.0 lib/webpack_rails/node_modules/cors/test/issue-2.js
webpack_rails-1.2.2 lib/webpack_rails/node_modules/cors/test/issue-2.js
webpack_rails-1.2.1 lib/webpack_rails/node_modules/cors/test/issue-2.js
webpack_rails-1.2.0 lib/webpack_rails/node_modules/cors/test/issue-2.js
webpack_rails-1.1.1 lib/webpack_rails/node_modules/cors/test/issue-2.js
webpack_rails-1.1.0 lib/webpack_rails/node_modules/cors/test/issue-2.js
webpack_rails-1.0.1 lib/webpack_rails/node_modules/cors/test/issue-2.js
webpack_rails-1.0.0 lib/webpack_rails/node_modules/cors/test/issue-2.js