Skip to content

Commit

Permalink
Sort out linting of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
luispabon committed Sep 5, 2017
1 parent 0a3a260 commit 3f8b9ed
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
6 changes: 5 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"extends" : [
"standard"
],
"plugins": [
"mocha"
],
"globals" : {
"expect" : false,
"should" : false,
Expand All @@ -10,6 +13,7 @@
"rules": {
"semi" : [2, "never"],
"max-len": [2, 120, 2],
"generator-star-spacing": 0
"generator-star-spacing": 0,
"mocha/no-exclusive-tests": "error"
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "superagent-retry-delay",
"version": "2.1.0",
"version": "2.1.1",
"description": "A retrying layer for a superagent request with delay support",
"license": "MIT",
"keywords": [
Expand All @@ -13,6 +13,7 @@
"type": "git",
"url": "git://github.com/luispabon/superagent-retry-delay.git"
},
"main": "src/index",
"dependencies": {},
"peerDependencies": {
"superagent": "~3.5.0"
Expand All @@ -33,6 +34,5 @@
"scripts": {
"test": "node_modules/.bin/mocha --recursive --timeout=20000 tests/",
"lint": "node_modules/.bin/eslint src tests"
},
"main": "src/index"
}
}
32 changes: 17 additions & 15 deletions tests/test.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
/* eslint-env mocha */

const express = require('express')

const agent = require('superagent');
require('../')(agent);
const agent = require('superagent')
require('../')(agent)

const should = require('should')
const assert = require('assert')
require('should')
const http = require('http')

http.globalAgent.maxSockets = 2000

describe('superagent-retry-delay', function () {

describe('not-errors', function () {
let requests = 0
const port = 10410
const app = express()
let server

before(function (done) {

app.get('/', function (req, res, next) {
requests++
res.send('hello!')
Expand Down Expand Up @@ -50,7 +49,6 @@ describe('superagent-retry-delay', function () {

before(function (done) {
app.get('/', function (req, res, next) {

requests++
if (requests === 1) {
res.sendStatus(401)
Expand All @@ -65,7 +63,6 @@ describe('superagent-retry-delay', function () {
})

it('should not retry on handled errors', function (done) {

agent
.get('http://localhost:' + port)
.retry(5, 13, [404])
Expand All @@ -86,7 +83,6 @@ describe('superagent-retry-delay', function () {
let server

before(function (done) {

app.get('/', function (req, res, next) {
requests++
if (requests > 4) {
Expand All @@ -100,11 +96,13 @@ describe('superagent-retry-delay', function () {
})

it('should retry on errors', function (done) {

agent
.get('http://localhost:' + port)
.end(function (err, res) {
res.status.should.eql(503)

// appease eslint, do nothing with error to allow it to bubble up
if (err) { }
})

agent
Expand Down Expand Up @@ -139,11 +137,13 @@ describe('superagent-retry-delay', function () {
})

it('should retry on errors', function (done) {

agent
.get('http://localhost:' + port)
.end(function (err, res) {
res.status.should.eql(500)

// appease eslint, do nothing with error to allow it to bubble up
if (err) { }
})

agent
Expand All @@ -167,7 +167,6 @@ describe('superagent-retry-delay', function () {

before(function (done) {
app.get('/', function (req, res, next) {

requests++
if (requests > 4) {
res.send('hello!')
Expand All @@ -180,11 +179,13 @@ describe('superagent-retry-delay', function () {
})

it('should retry on errors', function (done) {

agent
.get('http://localhost:' + port)
.end(function (err, res) {
res.status.should.eql(404)

// appease eslint, do nothing with error to allow it to bubble up
if (err) { }
})

agent
Expand All @@ -208,7 +209,6 @@ describe('superagent-retry-delay', function () {

before(function (done) {
app.get('/', function (req, res, next) {

requests++
if (requests > 4) {
res.send('hello!')
Expand All @@ -221,11 +221,13 @@ describe('superagent-retry-delay', function () {
})

it('should retry on errors', function (done) {

agent
.get('http://localhost:' + port)
.end(function (err, res) {
res.status.should.eql(401)

// appease eslint, do nothing with error to allow it to bubble up
if (err) { }
})

agent
Expand Down

0 comments on commit 3f8b9ed

Please sign in to comment.