Commit f8a01123 authored by analog-nico's avatar analog-nico
Browse files

Introduced Chai

parent 93bc0136
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -80,14 +80,15 @@
  "rhino"         : false,    // Enable globals available when your code is running inside of the Rhino runtime environment.
  "wsh"           : false,    // Enable globals available when your code is running as a script for the Windows Script Host.

  // Additional globals introduced by Mocha
  // Additional globals introduced by Mocha and Chai
  "globals": {
    "describe"    : false,
    "xdescribe"   : false,
    "it"          : false,
    "xit"         : false,
    "before"      : false,
    "after"       : false
    "after"       : false,
    "expect"      : false
  },

  // == JSLint Legacy ===================================================
+3 −0
Original line number Diff line number Diff line
@@ -9,6 +9,9 @@ var mocha = require('gulp-mocha');
var chalk = require('chalk');
var rimraf = require('rimraf');

var chai = require("chai");
global.expect = chai.expect;


var paths = {
    libJsFiles: './lib/**/*.js',
+1 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
    "request": "^2.34"
  },
  "devDependencies": {
    "chai": "^1.9.2",
    "chalk": "^0.5.1",
    "gulp": "^3.8.8",
    "gulp-istanbul": "^0.3.1",
+10 −24
Original line number Diff line number Diff line
@@ -3,7 +3,6 @@
var rp = require('../lib/rp.js');
var http = require('http');
var url = require('url');
var assert = require('assert');
var util = require('util');

describe('Request-Promise', function () {
@@ -67,14 +66,11 @@ describe('Request-Promise', function () {
            .then(function () {
                done(new Error('A 500 response code should reject, not resolve'));
            }).catch(function (reason) {
                if (reason.options.method !== 'GET') {
                    done(new Error(util.format("Expected method %s, got %s", 'GET', reason.options.method)));
                } else if (reason.error !== 'GET /500') {
                    done(new Error(util.format("Expected body as '%s', got '%s'", "GET /500", reason.error)));
                } else {
                expect(reason.options.method).to.eql('GET');
                expect(reason.error).to.eql('GET /500');
                done();
                }
            });
            })
            .catch(done);

    });

@@ -204,21 +200,11 @@ describe('Request-Promise', function () {
            };
            rp(options)
                .then(function(response){
                    if (response.statusCode !== 200) {
                        done(new Error(util.format("Expected response status %d, got %d", 200, response.statusCode)));
                    }
                    else if (response.request.method !== 'GET') {
                        done(new Error(util.format("Expected method %s, got %s", 'GET', response.request.method))); 
                    }
                    else if (response.body !== 'GET /200') {
                        done(new Error(util.format("Expected body as '%s', got '%s'", "GET /200", response.body)));
                    }
                    else {
                    expect(response.statusCode).to.eql(200);
                    expect(response.request.method).to.eql('GET');
                    expect(response.body).to.eql('GET /200');
                    done();
                    }
                }).catch(function(err){
                    done(new Error(err));
                });
                }).catch(done);
        });

    });