From 2601fcfea7105b376282486a82332552097deb90 Mon Sep 17 00:00:00 2001 From: Shaunak Kashyap Date: Fri, 1 Jul 2016 11:54:01 -0700 Subject: [PATCH] Adding unit tests for default paths involving various properties --- src/ui/__tests__/ui_nav_link.js | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/ui/__tests__/ui_nav_link.js b/src/ui/__tests__/ui_nav_link.js index f7676fb9cd9c..e5a2ea8a2a70 100644 --- a/src/ui/__tests__/ui_nav_link.js +++ b/src/ui/__tests__/ui_nav_link.js @@ -24,7 +24,66 @@ describe('UiNavLink', () => { expect(link.url).to.be(`${uiExports.urlBasePath}${spec.url}`); expect(link.description).to.be(spec.description); expect(link.icon).to.be(spec.icon); + }); + it ('initializes the url property without a base path when one is not specified in the spec', () => { + const uiExports = {}; + const spec = { + id: 'kibana:discover', + title: 'Discover', + order: -1003, + url: '/app/kibana#/discover', + description: 'interactively explore your data', + icon: 'plugins/kibana/assets/discover.svg', + }; + const link = new UiNavLink(uiExports, spec); + + expect(link.url).to.be(spec.url); + }); + + it ('initializes the order property to 0 when order is not specified in the spec', () => { + const uiExports = {}; + const spec = { + id: 'kibana:discover', + title: 'Discover', + url: '/app/kibana#/discover', + description: 'interactively explore your data', + icon: 'plugins/kibana/assets/discover.svg', + }; + const link = new UiNavLink(uiExports, spec); + + expect(link.order).to.be(0); + }); + + it ('initializes the linkToLastSubUrl property to false when false is specified in the spec', () => { + const uiExports = {}; + const spec = { + id: 'kibana:discover', + title: 'Discover', + order: -1003, + url: '/app/kibana#/discover', + description: 'interactively explore your data', + icon: 'plugins/kibana/assets/discover.svg', + linkToLastSubUrl: false + }; + const link = new UiNavLink(uiExports, spec); + + expect(link.linkToLastSubUrl).to.be(false); + }); + + it ('initializes the linkToLastSubUrl property to true by default', () => { + const uiExports = {}; + const spec = { + id: 'kibana:discover', + title: 'Discover', + order: -1003, + url: '/app/kibana#/discover', + description: 'interactively explore your data', + icon: 'plugins/kibana/assets/discover.svg', + }; + const link = new UiNavLink(uiExports, spec); + + expect(link.linkToLastSubUrl).to.be(true); }); });