From adeed8bf1ce45105716b9cc2584757c55b1121ce Mon Sep 17 00:00:00 2001 From: Tobias Bieniek Date: Wed, 27 Jan 2021 14:45:11 +0100 Subject: [PATCH] tests/components/link: Add "incomplete model" tests --- tests/dummy/app/router.ts | 1 + tests/integration/components/link-test.ts | 42 +++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/tests/dummy/app/router.ts b/tests/dummy/app/router.ts index 7d0c2a5e..b7751f62 100644 --- a/tests/dummy/app/router.ts +++ b/tests/dummy/app/router.ts @@ -15,5 +15,6 @@ DummyRouter.map(function () { this.route('parent', { path: 'parent/:parent_id' }, function () { this.route('child', { path: 'child/:child_id' }); + this.route('second-child'); }); }); diff --git a/tests/integration/components/link-test.ts b/tests/integration/components/link-test.ts index 4854cab7..ae2d2385 100644 --- a/tests/integration/components/link-test.ts +++ b/tests/integration/components/link-test.ts @@ -49,4 +49,46 @@ module('Integration | Component | link', function (hooks) { 'Assertion Failed: You can only call `transitionTo`, when the router is initialized, e.g. when using `setupApplicationTest`.' ); }); + + module('with incomplete models', function () { + test('it renders', async function (assert) { + await render(hbs` + + + Link + + + `); + + assert.dom('[data-test-link]').hasAttribute('href', ''); + assert.dom('[data-test-link]').hasNoClass('is-active'); + }); + + test('triggering a transition has no effect', async function (assert) { + await render(hbs` + + + Link + + + `); + + const error = await waitForError(() => click('[data-test-link]')); + assert.ok(error instanceof Error); + assert.strictEqual( + error.message, + 'Assertion Failed: You can only call `transitionTo`, when the router is initialized, e.g. when using `setupApplicationTest`.' + ); + }); + }); });