Skip to content

Commit

Permalink
Fix indentaoin
Browse files Browse the repository at this point in the history
  • Loading branch information
zakkudo committed Jan 30, 2019
1 parent c1d2191 commit ef8666d
Show file tree
Hide file tree
Showing 9 changed files with 933 additions and 933 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ insert_final_newline = true

# Matches multiple files with brace expansion notation
# Set default charset
[*.{js}]
[*.js]
charset = utf-8
indent_style = space
indent_size = 2
6 changes: 3 additions & 3 deletions src/HttpError.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import HttpError from '@zakkudo/fetch/HttpError';
import LocalHttpError from './HttpError';

describe('HttpError', () => {
it('aliases the error', () => {
expect(HttpError).toEqual(LocalHttpError);
});
it('aliases the error', () => {
expect(HttpError).toEqual(LocalHttpError);
});
});

6 changes: 3 additions & 3 deletions src/MockTestHelper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

export default class MockTestHelper {
static getCallArguments(mock) {
return mock.mock.calls;
}
static getCallArguments(mock) {
return mock.mock.calls;
}
}

6 changes: 3 additions & 3 deletions src/QueryStringError.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import QueryStringError from '@zakkudo/query-string/QueryStringError';
import LocalQueryStringError from './QueryStringError';

describe('QueryStringError', () => {
it('aliases the error', () => {
expect(QueryStringError).toEqual(LocalQueryStringError);
});
it('aliases the error', () => {
expect(QueryStringError).toEqual(LocalQueryStringError);
});
});

6 changes: 3 additions & 3 deletions src/UrlError.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import UrlError from '@zakkudo/url/UrlError';
import LocalUrlError from './UrlError';

describe('UrlError', () => {
it('aliases the error', () => {
expect(UrlError).toEqual(LocalUrlError);
});
it('aliases the error', () => {
expect(UrlError).toEqual(LocalUrlError);
});
});

44 changes: 22 additions & 22 deletions src/ValidationError.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@
* @extends Error
*/
class ValidationError extends Error {
/**
* @param {String} url - The url when the validation errors were found
* @param {Array<String>} errors - The list of the validation errors
* @param {Object} schema - The JSON schema used to generated the validation errors
*/
constructor(url, errors = [], schema) {
const messages = errors.map((e) => `<${url}> ${e.dataPath}: ${e.message}`);

super(JSON.stringify(messages, null, 4));
/**
* @param {String} url - The url when the validation errors were found
* @param {Array<String>} errors - The list of the validation errors
* @param {Object} schema - The JSON schema used to generated the validation errors
*/
constructor(url, errors = [], schema) {
const messages = errors.map((e) => `<${url}> ${e.dataPath}: ${e.message}`);

/**
* The list of validation errors
*/
this.errors = errors;
super(JSON.stringify(messages, null, 4));

/**
* The JSON schema used to generated the validation errors
*/
this.schema = schema;
}
/**
* The list of validation errors
*/
this.errors = errors;

/**
* @private
* The JSON schema used to generated the validation errors
*/
toString() {
return `ValidationError: ${this.message}`;
}
this.schema = schema;
}

/**
* @private
*/
toString() {
return `ValidationError: ${this.message}`;
}
}

export default ValidationError;
32 changes: 16 additions & 16 deletions src/ValidationError.test.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import ValidationError from './ValidationError';

describe('ValidationError', () => {
it('constructs an error with the custom message', () => {
const error = new ValidationError('test url', [{dataPath: 'testpath', message: 'testmessage'}], 'test schema');
function toString() {
return ValidationError.prototype.toString.apply(error);
}
it('constructs an error with the custom message', () => {
const error = new ValidationError('test url', [{dataPath: 'testpath', message: 'testmessage'}], 'test schema');
function toString() {
return ValidationError.prototype.toString.apply(error);
}

expect(error.message).toEqual(`[
expect(error.message).toEqual(`[
"<test url> testpath: testmessage"
]`);

expect(toString()).toEqual(`ValidationError: [
expect(toString()).toEqual(`ValidationError: [
"<test url> testpath: testmessage"
]`);
});
});

it('works when no constructor value passed in', () => {
const error = new ValidationError();
function toString() {
return ValidationError.prototype.toString.apply(error);
}
it('works when no constructor value passed in', () => {
const error = new ValidationError();
function toString() {
return ValidationError.prototype.toString.apply(error);
}

expect(error.message).toEqual(`[]`);
expect(error.message).toEqual(`[]`);

expect(toString()).toEqual(`ValidationError: []`);
});
expect(toString()).toEqual(`ValidationError: []`);
});
});

0 comments on commit ef8666d

Please sign in to comment.