-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #490 from NullVoxPopuli/remote-data-in-templates
fix(RemoteData, function-resource): wrapped template usage
- Loading branch information
Showing
6 changed files
with
242 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
public-hoist-pattern[]=*@types* | ||
|
||
# Required because broccoli has hard-coded paths to *all* packages | ||
# not just relevant ones.......... | ||
public-hoist-pattern[]=eslint-plugin* | ||
public-hoist-pattern[]=eslint-config* |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
50 changes: 50 additions & 0 deletions
50
testing/ember-app/tests/utils/remote-data/rendering-test.ts
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,50 @@ | ||
import { render } from '@ember/test-helpers'; | ||
import { hbs } from 'ember-cli-htmlbars'; | ||
import { module, test } from 'qunit'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
|
||
import { setupMSW } from 'ember-app/tests/msw'; | ||
import { RemoteData } from 'ember-resources/util/remote-data'; | ||
|
||
let data = [ | ||
{ id: '1', type: 'blogs', attributes: { name: `name:1` } }, | ||
{ id: '2', type: 'blogs', attributes: { name: `name:2` } }, | ||
{ id: '3', type: 'blogs', attributes: { name: `name:3` } }, | ||
]; | ||
|
||
module('Utils | remote-data | rendering', function (hooks) { | ||
setupRenderingTest(hooks); | ||
setupMSW(hooks, ({ rest }) => [ | ||
rest.get('/blogs/:id', (req, res, ctx) => { | ||
let record = data.find((datum) => datum.id === req.params.id); | ||
|
||
return res(ctx.json({ ...record })); | ||
}), | ||
]); | ||
|
||
module('RemoteData', function () { | ||
test('works with static url', async function (assert) { | ||
this.setProperties({ RemoteData }); | ||
|
||
await render(hbs` | ||
{{#let (this.RemoteData "/blogs/1") as |blog|}} | ||
{{blog.value.attributes.name}} | ||
{{/let}} | ||
`); | ||
|
||
assert.dom().hasText('name:1'); | ||
}); | ||
|
||
test('works with dynamic url', async function (assert) { | ||
this.setProperties({ RemoteData }); | ||
|
||
await render(hbs` | ||
{{#let (this.RemoteData "/blogs/1") as |blog|}} | ||
{{blog.value.attributes.name}} | ||
{{/let}} | ||
`); | ||
|
||
assert.dom().hasText('name:1'); | ||
}); | ||
}); | ||
}); |