Skip to content

Commit

Permalink
add basic example
Browse files Browse the repository at this point in the history
  • Loading branch information
amk221 committed Jul 20, 2020
1 parent a824c76 commit 247c3b6
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 5 deletions.
17 changes: 17 additions & 0 deletions app/controllers/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Controller from '@ember/controller';
import { action } from '@ember/object';
// import { reject } from 'rsvp';

export default class ApplicationController extends Controller {

// @action
// doSomethingAsyncThatFails() {
// return reject('failed');
// }

@action
async doSomethingAsyncThatFails() {
throw new Error('failed')
}

}
4 changes: 4 additions & 0 deletions app/routes/application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Route from '@ember/routing/route';

export default class ApplicationRoute extends Route {
}
6 changes: 1 addition & 5 deletions app/templates/application.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
{{!-- The following component displays Ember's default welcome message. --}}
<WelcomePage />
{{!-- Feel free to remove this! --}}

{{outlet}}
<button type="button" {{on "click" this.doSomethingAsyncThatFails}}>Do something async that fails</button>
29 changes: 29 additions & 0 deletions tests/acceptance/application-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { module, test } from 'qunit';
import { visit, click } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import { setupOnerror, resetOnerror } from '@ember/test-helpers';

module('Acceptance | application', function(hooks) {
setupApplicationTest(hooks);

test('visiting /', async function(assert) {
assert.expect(0);

// We know the application will error in this test, but that's OK,
// we want to specifically test the error state so that the test
// doesn't fail.
setupOnerror(error => {
if (error === 'failed') {
return;
}

throw error;
});

await visit('/');

await click('button');

resetOnerror();
});
});
12 changes: 12 additions & 0 deletions tests/unit/controllers/application-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

module('Unit | Controller | application', function(hooks) {
setupTest(hooks);

// TODO: Replace this with your real tests.
test('it exists', function(assert) {
let controller = this.owner.lookup('controller:application');
assert.ok(controller);
});
});
11 changes: 11 additions & 0 deletions tests/unit/routes/application-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

module('Unit | Route | application', function(hooks) {
setupTest(hooks);

test('it exists', function(assert) {
let route = this.owner.lookup('route:application');
assert.ok(route);
});
});

0 comments on commit 247c3b6

Please sign in to comment.