-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds more detailed ("friendly") RESTAdapter Error Messages
- Loading branch information
Showing
3 changed files
with
157 additions
and
8 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,51 @@ | ||
import setupStore from 'dummy/tests/helpers/store'; | ||
|
||
import {module, test} from 'qunit'; | ||
|
||
import DS from 'ember-data'; | ||
|
||
let adapter, env; | ||
|
||
module("unit/adapters/rest_adapter/detailed_message_test - DS.RESTAdapter#generatedDetailedMessage", { | ||
|
||
beforeEach() { | ||
env = setupStore({ adapter: DS.RESTAdapter }); | ||
adapter = env.adapter; | ||
} | ||
|
||
}); | ||
|
||
test("generating a wonderfully friendly error message should work", (assert) => { | ||
assert.expect(1); | ||
|
||
let friendlyMessage = adapter.generatedDetailedMessage( | ||
418, | ||
{ "Content-Type": "text/plain" }, | ||
"I'm a little teapot, short and stout", | ||
{ | ||
url: "/teapots/testing", | ||
method: "GET" | ||
} | ||
); | ||
|
||
assert.equal(friendlyMessage, ["Ember Data Request GET /teapots/testing returned a 418", | ||
"Payload (text/plain)", | ||
"I'm a little teapot, short and stout"].join("\n")); | ||
}); | ||
|
||
test("generating a friendly error message with a missing content-type header should work", (assert) => { | ||
|
||
let friendlyMessage = adapter.generatedDetailedMessage( | ||
418, | ||
{}, | ||
"I'm a little teapot, short and stout", | ||
{ | ||
url: "/teapots/testing", | ||
method: "GET" | ||
} | ||
); | ||
|
||
assert.equal(friendlyMessage, ["Ember Data Request GET /teapots/testing returned a 418", | ||
"Payload (Empty Content-Type)", | ||
"I'm a little teapot, short and stout"].join("\n")); | ||
}); |