updated format and lint scripts and applied them

This commit is contained in:
JJ Kasper
2018-06-01 16:52:12 -05:00
parent 53ac8a6793
commit 017a9993ee
58 changed files with 1711 additions and 1568 deletions

View File

@@ -1,55 +1,56 @@
const assert = require('assert');
const rp = require('request-promise');
const url = require('url');
const app = require('../src/app');
const getUrlPath = require('../util/getUrl');
const assert = require('assert')
const rp = require('request-promise')
const url = require('url')
const app = require('../src/app')
const getUrlPath = require('../util/getUrl')
const port = app.get('port') || 3030;
const getUrl = pathname => url.format({
hostname: app.get('host') || 'localhost',
protocol: 'http',
port,
pathname: getUrlPath(pathname)
});
const port = app.get('port') || 3030
const getUrl = pathname =>
url.format({
hostname: app.get('host') || 'localhost',
protocol: 'http',
port,
pathname: getUrlPath(pathname),
})
describe('Feathers application tests', () => {
before(async () => {
this.server = await app.run(port);
});
this.server = await app.run(port)
})
after(done => {
this.server.close(done);
});
this.server.close(done)
})
it('starts and shows the index page', () => {
return rp(getUrl('/')).then(body =>
assert.ok(body.indexOf('<html>') !== -1)
);
});
)
})
describe('404', function() {
it('shows a 404 HTML page', () => {
return rp({
url: getUrl('path/to/nowhere'),
headers: {
'Accept': 'text/html'
}
Accept: 'text/html',
},
}).catch(res => {
assert.equal(res.statusCode, 404);
assert.ok(res.error.indexOf('<html>') !== -1);
});
});
assert.equal(res.statusCode, 404)
assert.ok(res.error.indexOf('<html>') !== -1)
})
})
it('shows a 404 JSON error without stack trace', () => {
return rp({
url: getUrl('path/to/nowhere'),
json: true
json: true,
}).catch(res => {
assert.equal(res.statusCode, 404);
assert.equal(res.error.code, 404);
assert.equal(res.error.message, 'Page not found');
assert.equal(res.error.name, 'NotFound');
});
});
});
});
assert.equal(res.statusCode, 404)
assert.equal(res.error.code, 404)
assert.equal(res.error.message, 'Page not found')
assert.equal(res.error.name, 'NotFound')
})
})
})
})

View File

@@ -1,10 +1,10 @@
const assert = require('assert');
const app = require('../../src/app');
const getUrl = require('../../util/getUrl');
const assert = require('assert')
const app = require('../../src/app')
const getUrl = require('../../util/getUrl')
describe('\'docs\' service', () => {
describe("'docs' service", () => {
it('registered the service', () => {
const service = app.service(getUrl('docs'));
assert.ok(service, 'Registered the service');
});
});
const service = app.service(getUrl('docs'))
assert.ok(service, 'Registered the service')
})
})

View File

@@ -1,10 +1,10 @@
const assert = require('assert');
const app = require('../../src/app');
const getUrl = require('../../util/getUrl');
const assert = require('assert')
const app = require('../../src/app')
const getUrl = require('../../util/getUrl')
describe('\'users\' service', () => {
describe("'users' service", () => {
it('registered the service', () => {
const service = app.service(getUrl('users'));
assert.ok(service, 'Registered the service');
});
});
const service = app.service(getUrl('users'))
assert.ok(service, 'Registered the service')
})
})