Skip to content
This repository has been archived by the owner on Dec 17, 2018. It is now read-only.

Commit

Permalink
Merge pull request #26 from feathersjs/semistandard
Browse files Browse the repository at this point in the history
jshint —> semistandard
  • Loading branch information
corymsmith authored Oct 22, 2016
2 parents e7ba36b + 908c278 commit 6653406
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 65 deletions.
30 changes: 0 additions & 30 deletions .jshintrc

This file was deleted.

17 changes: 13 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,17 @@
"release:major": "npm version major && npm publish",
"compile": "rm -rf lib/ && babel -d lib/ src/",
"watch": "babel --watch -d lib/ src/",
"jshint": "jshint src/. test/. --config",
"lint": "eslint-if-supported semistandard --fix",
"mocha": "mocha test/ --compilers js:babel-core/register",
"test": "npm run jshint && npm run mocha"
"test": "npm run lint && npm run mocha"
},
"semistandard": {
"env": [
"mocha"
],
"ignore": [
"/lib"
]
},
"directories": {
"lib": "lib"
Expand All @@ -54,7 +62,8 @@
"babel-core": "^6.7.4",
"babel-plugin-add-module-exports": "^0.2.0",
"babel-preset-es2015": "^6.6.0",
"jshint": "^2.8.0",
"mocha": "^3.0.0"
"eslint-if-supported": "^1.0.1",
"mocha": "^3.0.0",
"semistandard": "^9.1.0"
}
}
40 changes: 19 additions & 21 deletions src/common-tests.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
/*jshint expr: true*/

import { expect } from 'chai';

function common(app, errors, serviceName = 'people', idProp = 'id') {
function common (app, errors, serviceName = 'people', idProp = 'id') {
describe(`Common tests, ${serviceName} service with ${idProp} id property`, () => {
const _ids = {};

beforeEach(() =>
app.service(serviceName).create({
name: 'Doug',
age: 32
}).then(data => _ids.Doug = data[idProp])
}).then(data => (_ids.Doug = data[idProp]))
);

afterEach(() =>
Expand All @@ -29,7 +27,7 @@ function common(app, errors, serviceName = 'people', idProp = 'id') {
it('extends and uses extended method', () => {
let now = new Date().getTime();
let extended = app.service(serviceName).extend({
create(data) {
create (data) {
data.time = now;
return this._super.apply(this, arguments);
}
Expand Down Expand Up @@ -97,7 +95,7 @@ function common(app, errors, serviceName = 'people', idProp = 'id') {
name: 'Alice',
age: 19
});
}).then(alice => _ids.Alice = alice[idProp].toString());
}).then(alice => (_ids.Alice = alice[idProp].toString()));
});

afterEach(() =>
Expand Down Expand Up @@ -134,7 +132,7 @@ function common(app, errors, serviceName = 'people', idProp = 'id') {
});
});

describe('special filters', () => {
describe('special filters', () => {
it('can $sort', () => {
const params = {
query: {
Expand Down Expand Up @@ -391,12 +389,12 @@ function common(app, errors, serviceName = 'people', idProp = 'id') {
});
});

describe('paginate', function() {
describe('paginate', function () {
beforeEach(() =>
app.service(serviceName).paginate = { default: 1, max: 2 }
(app.service(serviceName).paginate = { default: 1, max: 2 })
);

afterEach(() => app.service(serviceName).paginate = {});
afterEach(() => (app.service(serviceName).paginate = {}));

it('returns paginated object, paginates by default and shows total', () => {
return app.service(serviceName).find().then(paginator => {
Expand Down Expand Up @@ -606,26 +604,26 @@ function common(app, errors, serviceName = 'people', idProp = 'id') {

before(() => {
throwing = app.service(serviceName).extend({
get store() {
get store () {
return app.service(serviceName).store;
},

find() {
find () {
throw new Error('find method called');
},
get() {
get () {
throw new Error('get method called');
},
create() {
create () {
throw new Error('create method called');
},
update() {
update () {
throw new Error('update method called');
},
patch() {
patch () {
throw new Error('patch method called');
},
remove() {
remove () {
throw new Error('remove method called');
}
});
Expand All @@ -638,10 +636,10 @@ function common(app, errors, serviceName = 'people', idProp = 'id') {
);

it('create', () => app.service(serviceName).create.call(throwing, {
[idProp]: 33,
name: 'Bob',
age: 25
})
[idProp]: 33,
name: 'Bob',
age: 25
})
);

it('update', () =>
Expand Down
6 changes: 2 additions & 4 deletions src/example-tests.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/*jshint expr: true*/

import { expect } from 'chai';
import request from 'request-promise';

export default function(idProp = 'id', url = 'http://localhost:3030/todos') {
export default function (idProp = 'id', url = 'http://localhost:3030/todos') {
let firstId;

it('POST', () => {
Expand Down Expand Up @@ -94,7 +92,7 @@ export default function(idProp = 'id', url = 'http://localhost:3030/todos') {
return request.post({
url,
json: true,
body: { text: 'to delete', complete : false }
body: { text: 'to delete', complete: false }
}).then(todo =>
request.del({ url: `${url}/${todo[idProp]}`, json: true })
.then(todo => expect(todo.text).to.equal('to delete'))
Expand Down
4 changes: 1 addition & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/*jshint expr: true*/

import example from './example-tests';
import base from './common-tests';
import orm from './orm-tests';

export { example };
export { base };
export { orm };
export { orm };
4 changes: 1 addition & 3 deletions src/orm-tests.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/*jshint expr: true*/

import { expect } from 'chai';

export default function orm(people, _ids, errors) {
export default function orm (people, _ids, errors) {
describe('Feathers ORM Specific Tests', () => {
it('wraps an ORM error in a feathers error', () => {
return people.create({}).catch(error =>
Expand Down

0 comments on commit 6653406

Please sign in to comment.