-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: DataServiceError.message and more (beta.3) (#204)
* refactor: DataServiceError for better message (beta.3)
* fix: `EntityDispatcherBase.upsert` action (should upsert not add) (beta.3)
closes #201
- Loading branch information
Showing
6 changed files
with
122 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { HttpErrorResponse } from '@angular/common/http'; | ||
import { DataServiceError } from './data-service-error'; | ||
import { RequestData } from './interfaces'; | ||
|
||
describe('DataServiceError', () => { | ||
describe('#message', () => { | ||
it('should define message when ctor error is string', () => { | ||
const expected = 'The error'; | ||
const dse = new DataServiceError(expected, null); | ||
expect(dse.message).toBe(expected); | ||
}); | ||
|
||
it('should define message when ctor error is new Error("message")', () => { | ||
const expected = 'The error'; | ||
const dse = new DataServiceError(new Error(expected), null); | ||
expect(dse.message).toBe(expected); | ||
}); | ||
|
||
it('should define message when ctor error is typical HttpResponseError', () => { | ||
const expected = 'The error'; | ||
const body = expected; // server error is typically in the body of the server response | ||
const httpErr = new HttpErrorResponse({ | ||
status: 400, | ||
statusText: 'Bad Request', | ||
url: 'http://foo.com/bad', | ||
error: body | ||
}); | ||
const dse = new DataServiceError(httpErr, null); | ||
expect(dse.message).toBe(expected); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters