From 247c3b6ee19d5fe380f4ad5296f9c8a7363ffbbc Mon Sep 17 00:00:00 2001 From: Andrew Kirwin Date: Mon, 20 Jul 2020 13:50:48 +0100 Subject: [PATCH] add basic example --- app/controllers/application.js | 17 +++++++++++++ app/routes/application.js | 4 +++ app/templates/application.hbs | 6 +---- tests/acceptance/application-test.js | 29 ++++++++++++++++++++++ tests/unit/controllers/application-test.js | 12 +++++++++ tests/unit/routes/application-test.js | 11 ++++++++ 6 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 app/controllers/application.js create mode 100644 app/routes/application.js create mode 100644 tests/acceptance/application-test.js create mode 100644 tests/unit/controllers/application-test.js create mode 100644 tests/unit/routes/application-test.js diff --git a/app/controllers/application.js b/app/controllers/application.js new file mode 100644 index 0000000..bdf7b39 --- /dev/null +++ b/app/controllers/application.js @@ -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') + } + +} diff --git a/app/routes/application.js b/app/routes/application.js new file mode 100644 index 0000000..2772446 --- /dev/null +++ b/app/routes/application.js @@ -0,0 +1,4 @@ +import Route from '@ember/routing/route'; + +export default class ApplicationRoute extends Route { +} diff --git a/app/templates/application.hbs b/app/templates/application.hbs index 7b1b104..590eccb 100644 --- a/app/templates/application.hbs +++ b/app/templates/application.hbs @@ -1,5 +1 @@ -{{!-- The following component displays Ember's default welcome message. --}} - -{{!-- Feel free to remove this! --}} - -{{outlet}} \ No newline at end of file + \ No newline at end of file diff --git a/tests/acceptance/application-test.js b/tests/acceptance/application-test.js new file mode 100644 index 0000000..81b23a3 --- /dev/null +++ b/tests/acceptance/application-test.js @@ -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(); + }); +}); diff --git a/tests/unit/controllers/application-test.js b/tests/unit/controllers/application-test.js new file mode 100644 index 0000000..e4b814b --- /dev/null +++ b/tests/unit/controllers/application-test.js @@ -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); + }); +}); diff --git a/tests/unit/routes/application-test.js b/tests/unit/routes/application-test.js new file mode 100644 index 0000000..21e9fb3 --- /dev/null +++ b/tests/unit/routes/application-test.js @@ -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); + }); +});