Skip to content

Commit

Permalink
lint the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
givanse committed Dec 30, 2018
1 parent be32aff commit 654f317
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 67 deletions.
48 changes: 27 additions & 21 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
module.exports = {
"parser": "typescript-eslint-parser",
"env": {
"browser": true,
"es6": true,
"node": true
'parser': 'typescript-eslint-parser',
'globals': {
'Pretender': true,
'sinon': true, // karma-sinon
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 2015,
"sourceType": "module"
'env': {
'browser': true,
'es6': true,
'node': true,
'jquery': true,
'qunit': true,
},
"rules": {
"indent": [
"error",
'extends': 'eslint:recommended',
'parserOptions': {
'ecmaVersion': 2015,
'sourceType': 'module'
},
'rules': {
'indent': [
'error',
2
],
"linebreak-style": [
"error",
"unix"
'linebreak-style': [
'error',
'unix'
],
"quotes": [
"error",
"single"
'quotes': [
'error',
'single'
],
"semi": [
"error",
"always"
'semi': [
'error',
'always'
]
}
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"tests-only": "karma start --single-run",
"tests-only-ci": "karma start --single-run --browsers PhantomJS",
"lint": "jshint pretender.js test",
"eslint": "eslint src/*.ts",
"eslint": "eslint src/*.ts test",
"test:server": "karma start --no-single-run",
"build": "rollup --config"
},
Expand Down
62 changes: 30 additions & 32 deletions test/calling_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ describe('pretender invoking', function(config) {
});

it('adds requests to the list of handled requests', function(assert) {
var params;
this.pretender.get('/some/path', function(request) {
params = request.queryParams;
this.pretender.get('/some/path', function(/*request*/) {
});

$.ajax({ url: '/some/path' });
Expand All @@ -147,8 +145,8 @@ describe('pretender invoking', function(config) {
assert.equal(req.url, '/some/path');
});

it("increments the handler's request count", function(assert) {
var handler = function(req) {};
it('increments the handler\'s request count', function(assert) {
var handler = function(/*req*/) {};

this.pretender.get('/some/path', handler);

Expand All @@ -161,7 +159,7 @@ describe('pretender invoking', function(config) {
var done = assert.async();

var json = '{foo: "bar"}';
this.pretender.get('/some/path', function(req) {
this.pretender.get('/some/path', function(/*req*/) {
return [200, {}, json];
});

Expand All @@ -182,7 +180,7 @@ describe('pretender invoking', function(config) {

var obj = { foo: 'bar' };
this.pretender.prepareBody = JSON.stringify;
this.pretender.get('/some/path', function(req) {
this.pretender.get('/some/path', function(/*req*/) {
return [200, {}, obj];
});

Expand All @@ -203,7 +201,7 @@ describe('pretender invoking', function(config) {
return headers;
};

this.pretender.get('/some/path', function(req) {
this.pretender.get('/some/path', function(/*req*/) {
return [200, {}, ''];
});

Expand All @@ -220,10 +218,10 @@ describe('pretender invoking', function(config) {
assert.expect(1);

var latestHandlerWasCalled = false;
this.pretender.get('/some/path', function(request) {
this.pretender.get('/some/path', function(/*request*/) {
assert.ok(false);
});
this.pretender.get('/some/path', function(request) {
this.pretender.get('/some/path', function(/*request*/) {
latestHandlerWasCalled = true;
});
$.ajax({ url: '/some/path' });
Expand All @@ -235,7 +233,7 @@ describe('pretender invoking', function(config) {
) {
var pretender = this.pretender;

pretender.get('/some/path', function(request) {
pretender.get('/some/path', function(/*request*/) {
return [200, {}, ''];
});

Expand All @@ -248,7 +246,7 @@ describe('pretender invoking', function(config) {
var done = assert.async();
var val = 'unset';

this.pretender.get('/some/path', function(request) {
this.pretender.get('/some/path', function(/*request*/) {
return [200, {}, ''];
});

Expand All @@ -269,7 +267,7 @@ describe('pretender invoking', function(config) {

this.pretender.get(
'/some/path',
function(request) {
function(/*request*/) {
return [200, {}, ''];
},
false
Expand All @@ -296,7 +294,7 @@ describe('pretender invoking', function(config) {

this.pretender.get(
'/some/path',
function(request) {
function(/*request*/) {
return [200, {}, ''];
},
function() {
Expand Down Expand Up @@ -336,7 +334,7 @@ describe('pretender invoking', function(config) {

this.pretender.get(
'/some/path',
function(request) {
function(/*request*/) {
return [200, {}, ''];
},
100
Expand All @@ -362,7 +360,7 @@ describe('pretender invoking', function(config) {

this.pretender.get(
'/some/path',
function(request) {
function(/*request*/) {
return [200, {}, ''];
},
true
Expand Down Expand Up @@ -391,7 +389,7 @@ describe('pretender invoking', function(config) {
it('requiresManualResolution returns true for endpoints configured with `true` for async', function(
assert
) {
this.pretender.get('/some/path', function(request) {}, true);
this.pretender.get('/some/path', function(/*request*/) {}, true);
this.pretender.get('/some/other/path', function() {});

assert.ok(this.pretender.requiresManualResolution('get', '/some/path'));
Expand All @@ -408,15 +406,15 @@ describe('pretender invoking', function(config) {
var progressEventCount = 0;
this.pretender.post(
'/uploads',
function(request) {
function(/*request*/) {
return [200, {}, ''];
},
300
);

var xhr = new window.XMLHttpRequest();
xhr.open('POST', '/uploads');
xhr.upload.onprogress = function(e) {
xhr.upload.onprogress = function(/*e*/) {
progressEventCount++;
};
xhr.onload = function() {
Expand All @@ -431,22 +429,22 @@ describe('pretender invoking', function(config) {
}
);

it("`onprogress` upload events don't keep firing once the request has ended", function(
it('`onprogress` upload events don\'t keep firing once the request has ended', function(
assert
) {
clock = sinon.useFakeTimers();
var progressEventCount = 0;
this.pretender.post(
'/uploads',
function(request) {
function(/*request*/) {
return [200, {}, ''];
},
210
);

var xhr = new window.XMLHttpRequest();
xhr.open('POST', '/uploads');
xhr.upload.onprogress = function(e) {
xhr.upload.onprogress = function(/*e*/) {
progressEventCount++;
};
xhr.send('some data');
Expand All @@ -467,15 +465,15 @@ describe('pretender invoking', function(config) {

this.pretender.post(
'/uploads',
function(request) {
function(/*request*/) {
return [200, {}, ''];
},
210
);

var xhr = new window.XMLHttpRequest();
xhr.open('POST', '/uploads');
xhr.upload.onprogress = function(e) {
xhr.upload.onprogress = function(/*e*/) {
progressEventCount++;
};
xhr.send('some data');
Expand All @@ -497,15 +495,15 @@ describe('pretender invoking', function(config) {
var progressEventCount = 0;
this.pretender.get(
'/downloads',
function(request) {
function(/*request*/) {
return [200, {}, ''];
},
300
);

var xhr = new window.XMLHttpRequest();
xhr.open('GET', '/downloads');
xhr.onprogress = function(e) {
xhr.onprogress = function(/*e*/) {
progressEventCount++;
};
xhr.onload = function() {
Expand All @@ -519,22 +517,22 @@ describe('pretender invoking', function(config) {
xhr.send('some data');
});

it("`onprogress` download events don't keep firing once the request has ended", function(
it('`onprogress` download events don\'t keep firing once the request has ended', function(
assert
) {
clock = sinon.useFakeTimers();
var progressEventCount = 0;
this.pretender.get(
'/downloads',
function(request) {
function(/*request*/) {
return [200, {}, ''];
},
210
);

var xhr = new window.XMLHttpRequest();
xhr.open('GET', '/downloads');
xhr.onprogress = function(e) {
xhr.onprogress = function(/*e*/) {
progressEventCount++;
};
xhr.send('some data');
Expand All @@ -553,15 +551,15 @@ describe('pretender invoking', function(config) {
clock = sinon.useFakeTimers();
this.pretender.get(
'/downloads',
function(request) {
function(/*request*/) {
return [200, {}, ''];
},
210
);

var xhr = new window.XMLHttpRequest();
xhr.open('GET', '/downloads');
xhr.onprogress = function(e) {
xhr.onprogress = function(/*e*/) {
progressEventCount++;
};
xhr.send('some data');
Expand Down Expand Up @@ -594,7 +592,7 @@ describe('pretender invoking', function(config) {

var json = '{foo: "bar"}';

this.pretender.get('/some/path', function(req) {
this.pretender.get('/some/path', function(/*req*/) {
return new Promise(function(resolve) {
resolve([200, {}, json]);
});
Expand Down
4 changes: 1 addition & 3 deletions test/creation_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ describe('pretender creation', function(config) {
});

it('a mapping function is optional', function(assert) {
var result = false;
try {
pretender = new Pretender();
result = true;
} catch (e) {
// fail
assert.ok(false);
}

assert.ok(true, 'does not raise');
Expand Down
6 changes: 2 additions & 4 deletions test/force_passthrough_test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var originalXMLHttpRequest;
var describe = QUnit.module;
var it = QUnit.test;

Expand All @@ -12,11 +11,10 @@ describe('passthrough requests', function(config) {
});

it('passthrough request when forcePassthrough is true', function(assert) {
var pretender = this.pretender;
var done = assert.async();

var passthroughInvoked = false;
this.pretender.passthroughRequest = function(verb, path, request) {
this.pretender.passthroughRequest = function(verb, path/*, request*/) {
passthroughInvoked = true;
assert.equal(verb, 'GET');
assert.equal(path, '/some/path');
Expand All @@ -36,7 +34,7 @@ describe('passthrough requests', function(config) {
var pretender = this.pretender;
pretender.forcePassthrough = false;

this.pretender.unhandledRequest = function(verb, path, request) {
this.pretender.unhandledRequest = function(verb, path/*, request*/) {
assert.equal(verb, 'GET');
assert.equal(path, '/some/path');
};
Expand Down
Loading

0 comments on commit 654f317

Please sign in to comment.