Skip to content

Commit

Permalink
Merge commit '018e6eea9db7aa30d969ab2bc9798914c48a0557'
Browse files Browse the repository at this point in the history
* commit '018e6eea9db7aa30d969ab2bc9798914c48a0557':
  Updated the real-world API tests from apis.guru
  ESLint fixes
  updated tooling files
  • Loading branch information
JamesMessinger committed Apr 10, 2016
2 parents efffb4c + 018e6ee commit af2b284
Show file tree
Hide file tree
Showing 14 changed files with 72 additions and 71 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ coverage
dist
www
node_modules
tests
12 changes: 6 additions & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"browser": true, // browser global variables.
"node": true, // Node.js global variables and Node.js-specific rules.
"amd": false, // defines require() and define() as global variables as per the amd spec.
"mocha": true, // adds all of the Mocha testing global variables.
"mocha": false, // adds all of the Mocha testing global variables.
"jasmine": false, // adds all of the Jasmine testing global variables for version 0.3 and 0.0.
"phantomjs": false, // phantomjs global variables.
"jquery": false, // jquery global variables.
Expand Down Expand Up @@ -75,7 +75,7 @@
"no-sparse-arrays": 2, // disallow sparse arrays
"no-unreachable": 2, // disallow unreachable statements after a return, throw, continue, or break statement
"use-isnan": 2, // disallow comparisons with the value NaN
"valid-jsdoc": [2, { // Ensure JSDoc comments are valid (off by default)
"valid-jsdoc": [1, { // Ensure JSDoc comments are valid (off by default)
"requireReturn": false, // require an @returns tag for all functions, even if they don't return anything
"requireParamDescription": false, // require a description for all @param tags
"requireReturnDescription": false // require a description for the @returns tag
Expand Down Expand Up @@ -157,7 +157,7 @@
"no-catch-shadow": 2, // disallow the catch clause parameter name being the same as a variable in the outer scope (off by default in the node environment)
"no-delete-var": 2, // disallow deletion of variables
"no-label-var": 2, // disallow labels that share a name with a variable
"no-shadow": 2, // disallow declaration of variables already declared in the outer scope
"no-shadow": 1, // disallow declaration of variables already declared in the outer scope
"no-shadow-restricted-names": 2, // disallow shadowing of names such as arguments
"no-undef": 2, // disallow use of undeclared variables unless mentioned in a /*global */ block
"no-undef-init": 2, // disallow use of undefined when initializing variables
Expand Down Expand Up @@ -236,14 +236,14 @@
"no-trailing-spaces": 2, // disallow trailing whitespace at the end of lines
"no-underscore-dangle": 0, // disallow dangling underscores in identifiers
"no-unneeded-ternary": 2, // disallow the use of ternary operators when a simpler alternative exists
"object-curly-spacing": [2, "never"], // require or disallow space inside curly brackets
"object-curly-spacing": [0, "never"], // require or disallow space inside curly brackets
"one-var": 0, // allow just one var statement per function (off by default)
"operator-assignment": [2, "always"], // require assignment operator shorthand where possible or prohibit it entirely (off by default)
"operator-linebreak": [2, "after"], // require linebreaks to be placed before or after operators
"padded-blocks": [2, "never"], // enforce padding within blocks (off by default)
"padded-blocks": [0, "never"], // enforce padding within blocks (off by default)
"quote-props": [2, "as-needed"], // require quotes around object literal property names (off by default)
"quotes": [2, "single"], // specify whether double or single quotes should be used
"require-jsdoc": 2, // require JSDoc comment
"require-jsdoc": 1, // require JSDoc comment
"semi": [2, "always"], // require or disallow use of semicolons instead of ASI
"semi-spacing": [2, { // enforce spacing before and after semicolons
"before": false, // require a space before semicolons
Expand Down
40 changes: 0 additions & 40 deletions .gitattributes

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
**/*~
**/._*
**/.DS_Store
*.sublime-*
npm-debug.log
/.idea
/coverage
Expand Down
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
**/*~
**/._*
**/.DS_Store
*.sublime-*
npm-debug.log
/.idea
/coverage
Expand Down
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ matrix:
env: KARMA=false
- node_js: 4
env: KARMA=false
- node_js: 5
env: KARMA=false

# Local Browsers
- node_js: 0.12
Expand Down
1 change: 1 addition & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ function configureSauceLabs(config) {
config.exclude = (config.exclude || []).concat([
'tests/specs/invalid/*',
'tests/specs/unknown/*',
'tests/specs/validate-schema/*',
'tests/specs/real-world/*'
]);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"homepage": "https://bigstickcarpet.github.io/swagger-parser",
"main": "lib/index.js",
"scripts": {
"lint": "eslint lib && jscs lib --verbose",
"lint": "eslint lib --fix && jscs lib --verbose",
"build": "npm run lint && npm run browserify && npm run build-www",
"browserify": "simplifyify lib/index.js --outfile dist/swagger-parser.js --standalone SwaggerParser --bundle --debug --minify",
"watch": "npm run browserify -- --watch & npm run browserify-www -- --watch",
Expand Down
28 changes: 28 additions & 0 deletions tests/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// ESLint config
// http://eslint.org/docs/rules/

"env": {
"mocha": true, // Mocha
},

"globals": {
"SwaggerParser": true, // Swagger Parser
"helper": true, // Test fixtures
"userAgent": true, // Test fixtrues
"chai": true, // Chai
"expect": true, // Chai
"path": true, // Node
"superagent": true, // SuperAgent
},

"rules": {
"require-jsdoc": 0, // Don't require doc comments for tests
"no-unused-expressions": 0, // Chai property syntax triggers this rule
"max-nested-callbacks": 0, // Mocha BDD syntax leads to deeply-nested callbacks
"no-invalid-this": 0, // Mocha BDD syntax triggers this rule
"no-loop-func": 0, // We need to dynamically create BDD suites/tests
"global-require": 0, // Nested `require` is required, since tests can run in Node or browsers
"strict": [2, "function"], // require the "use strict" pragma in a function
}
}
4 changes: 2 additions & 2 deletions tests/fixtures/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
(function() {
'use strict';

if (typeof(window) === 'object') {
if (typeof window === 'object') {
// Expose Browser globals
window.global = window;
window.expect = chai.expect;
Expand All @@ -34,4 +34,4 @@
};
}

})();
}());
38 changes: 19 additions & 19 deletions tests/fixtures/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@
/**
* Throws an error if called.
*/
helper.shouldNotGetCalled = function shouldNotGetCalled(done) {
var err = new Error('This function should not have gotten called.');
if (typeof done === 'function') {
return function(err2) {
if (err2 instanceof Error) {
done(err2);
}
else {
done(err);
}
}
}
else {
throw err;
}
};
helper.shouldNotGetCalled = function shouldNotGetCalled(done) {
var err = new Error('This function should not have gotten called.');
if (typeof done === 'function') {
return function(err2) {
if (err2 instanceof Error) {
done(err2);
}
else {
done(err);
}
};
}
else {
throw err;
}
};

/**
* Tests the {@link SwaggerParser.resolve} method,
Expand Down Expand Up @@ -92,7 +92,7 @@
done();
})
.catch(helper.shouldNotGetCalled(done));
}
};
};

/**
Expand All @@ -116,7 +116,7 @@
*/
helper.cloneDeep = function cloneDeep(value) {
var clone = value;
if (value && typeof(value) === 'object') {
if (value && typeof value === 'object') {
clone = value instanceof Array ? [] : {};
var keys = Object.keys(value);
for (var i = 0; i < keys.length; i++) {
Expand All @@ -126,4 +126,4 @@
return clone;
};

})();
}());
2 changes: 1 addition & 1 deletion tests/fixtures/mocha.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
this.currentTest.slow(500);
});

})();
}());
2 changes: 1 addition & 1 deletion tests/fixtures/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@
return encodeURIComponent(file).split('%2F').join('/');
}

})();
}());
9 changes: 9 additions & 0 deletions tests/specs/real-world/real-world.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('Real-world APIs', function() {
delete apis['motaword.com']; // invalid (see https://github.com/BigstickCarpet/swagger-parser/issues/26)
delete apis['uploady.com']; // invalid (see https://github.com/BigstickCarpet/swagger-parser/issues/26)
delete apis['watchful.li']; // invalid (see https://github.com/BigstickCarpet/swagger-parser/issues/26)
delete apis['versioneye.com']; // invalid (same reason as above)

// Transform the list into an array of {name: string, url: string}
realWorldAPIs = [];
Expand All @@ -34,6 +35,14 @@ describe('Real-world APIs', function() {
});
});

beforeEach(function() {
// Some of these APIs are vary large, so we need to increase the timouts
// to allow time for them to be downloaded, dereferenced, and validated.
// so we need to increase the timeouts to allow for that
this.currentTest.timeout(30000);
this.currentTest.slow(5000);
});

// Mocha requires us to create our tests synchronously. But the list of APIs is downloaded asynchronously.
// So, we just create 200 placeholder tests, and then rename them later to reflect which API they're testing.
for (var i = 1; i <= 300; i++) {
Expand Down

0 comments on commit af2b284

Please sign in to comment.