Skip to content

Commit

Permalink
fix(auth0#160) : changed AuthHttpError to Error
Browse files Browse the repository at this point in the history
  • Loading branch information
HNeukermans committed Oct 4, 2016
1 parent a3d2093 commit 132ec1b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
26 changes: 24 additions & 2 deletions angular2-jwt.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "core-js";
import {AuthConfig, AuthHttp, tokenNotExpired, JwtHelper} from "./angular2-jwt";
import {AuthConfig, AuthHttp, tokenNotExpired, JwtHelper, AuthHttpError} from "./angular2-jwt";
import {Observable} from "rxjs";
import {Base64} from "js-base64";

Expand Down Expand Up @@ -173,4 +173,26 @@ describe("AuthHttp", () => {
});
});
});
});
});

describe("AuthHttpError", () => {

'use strict';

it("constructor fails to set the error message", () => {
const message = 'This is an error';
let error = new AuthHttpError(message);
expect(error.message).toBe('');
});
});

describe("Error", () => {

'use strict';

it("constructor should set the error message", () => {
const message = 'This is an error';
let error = new Error(message);
expect(error.message).toBe(message);
});
});
2 changes: 1 addition & 1 deletion angular2-jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export class AuthHttp {
if (!tokenNotExpired(undefined, token)) {
if (!this.config.noJwtError) {
return new Observable<Response>((obs: any) => {
obs.error(new AuthHttpError('No JWT present or has expired'));
obs.error(new Error('No JWT present or has expired'));
});
}
} else {
Expand Down

0 comments on commit 132ec1b

Please sign in to comment.