1
0
Fork 0

Finished quick start

This commit is contained in:
Jo Wroten 2019-09-26 10:02:57 -05:00
parent c7091471b3
commit 9987cb72dc
8 changed files with 65 additions and 3 deletions

View 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>

View 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}!`);
}
}

View file

@ -7,4 +7,5 @@ export default class Router extends EmberRouter {
}
Router.map(function() {
this.route('scientists');
});

7
app/routes/scientists.js Normal file
View 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'];
}
}

View file

@ -1,6 +1,4 @@
{{!-- The following component displays Ember's default welcome message. --}}
<WelcomePage />
{{!-- Feel free to remove this! --}}
<h1>People Tracker</h1>
{{outlet}}

View file

@ -0,0 +1 @@
<PeopleList @title="List of Scientists" @people={{@model}} />

View 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');
});
});

View 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);
});
});