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

Update dependencies and tests for testing middleware fix #100

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@
"babel-eslint": "8.2.2",
"babel-plugin-transform-flow-strip-types": "6.22.0",
"create-universal-package": "3.4.1",
"eslint": "4.18.1",
"eslint": "4.18.2",
"eslint-config-fusion": "^1.0.0",
"eslint-plugin-cup": "1.0.0",
"eslint-plugin-flowtype": "2.46.1",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-prettier": "2.6.0",
"eslint-plugin-react": "7.7.0",
"flow-bin": "0.66.0",
"fusion-core": "^1.0.0",
"flow-bin": "0.67.1",
"fusion-core": "^1.2.0",
"fusion-test-utils": "^1.0.1",
"fusion-tokens": "^1.0.1",
"nyc": "11.4.1",
"fusion-tokens": "^1.0.2",
"nyc": "11.6.0",
"prettier": "1.11.1",
"tape-cup": "4.7.1",
"unitest": "2.1.1"
},
"peerDependencies": {
"fusion-core": "^1.0.0",
"fusion-tokens": "^1.0.1"
"fusion-core": "^1.2.0",
"fusion-tokens": "^1.0.2"
},
"scripts": {
"clean": "rm -rf dist",
Expand Down
16 changes: 8 additions & 8 deletions src/__tests__/index.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ import {fork} from 'child_process';
import ErrorHandling, {ErrorHandlerToken} from '../server';

test('request errors', async t => {
t.plan(2);
t.plan(4);

const app = new App('test', el => el);

let called = 0;
const onError = () => {
const expectedTypes = ['browser', 'request'];
const onError = (body, type) => {
t.equal(type, expectedTypes.shift());
called++;
};
app.register(ErrorHandling);
Expand All @@ -26,14 +28,13 @@ test('request errors', async t => {

await getSimulator(app)
.request('/_errors', {
prefix: '',
request: {body: {message: 'test'}},
body: {message: 'test'},
})
.catch(e => {
t.equals(e, 'REJECTED');
});

t.equals(called, 1, 'emits browser error');
t.equals(called, 2, 'emits browser error');
process.removeAllListeners('uncaughtException');
process.removeAllListeners('unhandledRejection');

Expand All @@ -55,9 +56,8 @@ test('request errors send early response', async t => {
app.register(ErrorHandlerToken, onError);
app.middleware(() => Promise.reject('REJECTED'));
await getSimulator(app)
.request('/_errors', {
prefix: '',
request: {body: {message: 'test'}},
.request('/someRoute', {
body: {message: 'test'},
})
.catch(e => {
t.equals(e, 'REJECTED');
Expand Down
2 changes: 1 addition & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ onerror = function(m,s,l,c,e) {
};
</script>`;
ctx.template.head.unshift(script);
} else if (ctx.path === ctx.prefix + '/_errors') {
} else if (ctx.path === '/_errors') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want the prefix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was told that we strip the prefix, but it looks like we might only strip it for the URL, and not path?

https://github.com/fusionjs/fusion-cli/blob/master/lib/strip-prefix.js

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Path is probably derived from the URL, but will do some verification)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, almost forget about the stripping

await parseBody(ctx, () => Promise.resolve());
await onError(ctx.request.body, captureTypes.browser);
ctx.body = {ok: 1};
Expand Down
Loading