Skip to content

Commit

Permalink
Merge pull request #116 from wkw/mocha-fewer-arrow-funcs
Browse files Browse the repository at this point in the history
Pass fewer arrow functions to Mocha. #297
  • Loading branch information
daffl committed Aug 25, 2018
1 parent 97096ce commit 3767c49
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 19 deletions.
10 changes: 10 additions & 0 deletions packages/generator-feathers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ yo feathers:model
yo feathers:service
```

## Contributing

To contribute PRs for these generators, you will need to clone the repo
then inside the repo's directory, run `npm link`. This sets up a global
link to your local package for running tests (`npm test`) and generating
new feathers apps/services/hooks/etc.

When finished testing, optionally run `npm uninstall generator-feathers` to remove
the link.


## Changelog

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const assert = require('assert');
const request = require('request');
const app = require('../src/app');

describe('Feathers application tests', () => {
describe('Feathers application tests', function() {
before(function(done) {
this.server = app.listen(3030);
this.server.once('listening', () => done());
Expand All @@ -14,32 +14,32 @@ describe('Feathers application tests', () => {
this.server.close(done);
});

it('starts and shows the index page', done => {
request('http://localhost:3030', (err, res, body) => {
it('starts and shows the index page', function(done) {
request('http://localhost:3030', function(err, res, body) {
assert.ok(body.indexOf('<html>') !== -1);
done(err);
});
});

describe('404', () => {
it('shows a 404 HTML page', done => {
describe('404', function() {
it('shows a 404 HTML page', function(done) {
request({
url: 'http://localhost:3030/path/to/nowhere',
headers: {
'Accept': 'text/html'
}
}, (err, res, body) => {
}, function(err, res, body) {
assert.equal(res.statusCode, 404);
assert.ok(body.indexOf('<html>') !== -1);
done(err);
});
});

it('shows a 404 JSON error without stack trace', done => {
it('shows a 404 JSON error without stack trace', function(done) {
request({
url: 'http://localhost:3030/path/to/nowhere',
json: true
}, (err, res, body) => {
}, function(err, res, body) {
assert.equal(res.statusCode, 404);
assert.equal(body.code, 404);
assert.equal(body.message, 'Page not found');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
const assert = require('assert');
const <%= codeName %> = require('../../../../<%= hookPath %>');

describe('<%= service %> <%= codeName %> hook', () => {
it('hook can be used', () => {
describe('<%= service %> <%= codeName %> hook', function() {
it('hook can be used', function() {
const mockHook = {
type: '<%= type %>',
app: {},
params: {},
result: {},
data: {}
};

<%= codeName %>()(mockHook);

assert.ok(mockHook.<%= codeName %>);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const assert = require('assert');
const app = require('../../../src/app');

describe('<%= name %> service', () => {
describe('<%= name %> service', function() {
it('registered the <%= pluralizedName %> service', () => {
assert.ok(app.service('<%= pluralizedName %>'));
});
Expand Down
12 changes: 6 additions & 6 deletions packages/generator-feathers/test/generators.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const helpers = require('yeoman-test');
const exec = require('child_process').exec;


describe('generator-feathers', () => {
describe('generator-feathers', function() {
let appDir;

function runTest(expectedText, done) {
Expand All @@ -27,7 +27,7 @@ describe('generator-feathers', () => {
});
}

before(done => {
before(function(done) {
helpers.run(path.join(__dirname, '../generators/app'))
.inTmpDir(dir => appDir = dir)
.withPrompts({
Expand All @@ -43,11 +43,11 @@ describe('generator-feathers', () => {
}).on('end', () => done());
});

it('feathers:app', done => {
it('feathers:app', function(done) {
runTest('starts and shows the index page', done);
});

it('feathers:service(memory)', done => {
it('feathers:service(memory)', function(done) {
helpers.run(path.join(__dirname, '../generators/service'))
.inTmpDir(() => process.chdir(appDir))
.withPrompts({
Expand All @@ -60,7 +60,7 @@ describe('generator-feathers', () => {
);
});

it('feathers:service(generic)', done => {
it('feathers:service(generic)', function(done) {
helpers.run(path.join(__dirname, '../generators/service'))
.inTmpDir(() => process.chdir(appDir))
.withPrompts({
Expand All @@ -72,7 +72,7 @@ describe('generator-feathers', () => {
);
});

it('feathers:hook', done => {
it('feathers:hook', function(done) {
helpers.run(path.join(__dirname, '../generators/hook'))
.inTmpDir(() => process.chdir(appDir))
.withPrompts({
Expand Down

0 comments on commit 3767c49

Please sign in to comment.