Finished quick start
This commit is contained in:
parent
c7091471b3
commit
9987cb72dc
8 changed files with 65 additions and 3 deletions
9
app/components/people-list.hbs
Normal file
9
app/components/people-list.hbs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<h2>{{@title}}</h2>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
{{#each @people as |person|}}
|
||||||
|
<li>
|
||||||
|
<button {{on "click" (fn this.showPerson person)}}>{{person}}</button>
|
||||||
|
</li>
|
||||||
|
{{/each}}
|
||||||
|
</ul>
|
9
app/components/people-list.js
Normal file
9
app/components/people-list.js
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
import Component from '@glimmer/component';
|
||||||
|
import { action } from '@ember/object';
|
||||||
|
|
||||||
|
export default class PeopleListComponent extends Component {
|
||||||
|
@action
|
||||||
|
showPerson(person) {
|
||||||
|
alert(`The person's name is ${person}!`);
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,4 +7,5 @@ export default class Router extends EmberRouter {
|
||||||
}
|
}
|
||||||
|
|
||||||
Router.map(function() {
|
Router.map(function() {
|
||||||
|
this.route('scientists');
|
||||||
});
|
});
|
||||||
|
|
7
app/routes/scientists.js
Normal file
7
app/routes/scientists.js
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
import Route from '@ember/routing/route';
|
||||||
|
|
||||||
|
export default class ScientistsRoute extends Route {
|
||||||
|
model() {
|
||||||
|
return ['Marie Curie', 'Mae Jemison', 'Albert Hofmann'];
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,4 @@
|
||||||
{{!-- The following component displays Ember's default welcome message. --}}
|
<h1>People Tracker</h1>
|
||||||
<WelcomePage />
|
|
||||||
{{!-- Feel free to remove this! --}}
|
|
||||||
|
|
||||||
{{outlet}}
|
{{outlet}}
|
||||||
|
|
||||||
|
|
1
app/templates/scientists.hbs
Normal file
1
app/templates/scientists.hbs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<PeopleList @title="List of Scientists" @people={{@model}} />
|
26
tests/integration/components/people-list-test.js
Normal file
26
tests/integration/components/people-list-test.js
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
import { module, test } from 'qunit';
|
||||||
|
import { setupRenderingTest } from 'ember-qunit';
|
||||||
|
import { render } from '@ember/test-helpers';
|
||||||
|
import { hbs } from 'ember-cli-htmlbars';
|
||||||
|
|
||||||
|
module('Integration | Component | people-list', function(hooks) {
|
||||||
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
|
test('it renders', async function(assert) {
|
||||||
|
// Set any properties with this.set('myProperty', 'value');
|
||||||
|
// Handle any actions with this.set('myAction', function(val) { ... });
|
||||||
|
|
||||||
|
await render(hbs`<PeopleList />`);
|
||||||
|
|
||||||
|
assert.equal(this.element.textContent.trim(), '');
|
||||||
|
|
||||||
|
// Template block usage:
|
||||||
|
await render(hbs`
|
||||||
|
<PeopleList>
|
||||||
|
template block text
|
||||||
|
</PeopleList>
|
||||||
|
`);
|
||||||
|
|
||||||
|
assert.equal(this.element.textContent.trim(), 'template block text');
|
||||||
|
});
|
||||||
|
});
|
11
tests/unit/routes/scientists-test.js
Normal file
11
tests/unit/routes/scientists-test.js
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import { module, test } from 'qunit';
|
||||||
|
import { setupTest } from 'ember-qunit';
|
||||||
|
|
||||||
|
module('Unit | Route | scientists', function(hooks) {
|
||||||
|
setupTest(hooks);
|
||||||
|
|
||||||
|
test('it exists', function(assert) {
|
||||||
|
let route = this.owner.lookup('route:scientists');
|
||||||
|
assert.ok(route);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Add table
Reference in a new issue