From ef642bb2d0182cb9f170ee57460b3a5228b1eaa8 Mon Sep 17 00:00:00 2001 From: Ryan Tablada Date: Thu, 16 Jul 2015 18:53:30 -0500 Subject: [PATCH] Allow use of custom homeRoute in md-navbar Make dat homeRoute customizable!!! Added tests to check that a custom navbar homeRoute can be defined --- addon/components/md-navbar.js | 1 + addon/templates/components/md-navbar.hbs | 2 +- tests/dummy/app/templates/navbar.hbs | 5 +++++ .../templates/snippets/navbar-custom-home.hbs | 10 ++++++++++ tests/integration/navbar-test.js | 17 +++++++++++++++++ 5 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tests/dummy/app/templates/snippets/navbar-custom-home.hbs diff --git a/addon/components/md-navbar.js b/addon/components/md-navbar.js index d2faea80..968e6078 100644 --- a/addon/components/md-navbar.js +++ b/addon/components/md-navbar.js @@ -5,6 +5,7 @@ import computed from 'ember-new-computed'; export default Ember.Component.extend({ tagName: 'nav', layout: layout, + homeRoute: 'index', didInsertElement() { this._super(...arguments); diff --git a/addon/templates/components/md-navbar.hbs b/addon/templates/components/md-navbar.hbs index 3d715e11..12538a09 100644 --- a/addon/templates/components/md-navbar.hbs +++ b/addon/templates/components/md-navbar.hbs @@ -1,6 +1,6 @@ diff --git a/tests/dummy/app/templates/snippets/navbar-custom-home.hbs b/tests/dummy/app/templates/snippets/navbar-custom-home.hbs new file mode 100644 index 00000000..7f7cc70f --- /dev/null +++ b/tests/dummy/app/templates/snippets/navbar-custom-home.hbs @@ -0,0 +1,10 @@ +{{#md-navbar name='Example' class='indigo' homeRoute='navbar'}} + + {{#link-to 'navbar' tagName='li'}} + {{link-to 'Navbar' 'navbar'}} + {{/link-to}} + {{#link-to 'tabs' tagName='li'}} + {{link-to 'Tabs' 'tabs'}} + {{/link-to}} +{{/md-navbar}} \ No newline at end of file diff --git a/tests/integration/navbar-test.js b/tests/integration/navbar-test.js index 3fd1a207..df693284 100644 --- a/tests/integration/navbar-test.js +++ b/tests/integration/navbar-test.js @@ -50,3 +50,20 @@ test('SideNav', assert => { }); }); + +test('Navbar Custom Home Route', assert => { + visit('/navbar'); + + window.QUnit.stop(); + + andThen(() => { + click('.navbar-custom-home a.brand-logo'); + }); + + andThen(() => { + assert.equal('/navbar', currentURL(), 'Navbar can have a custom home route'); + + window.QUnit.start(); + }); +}); +