From ca0aec721cd003bc09fc50f6a00dd16122c97e71 Mon Sep 17 00:00:00 2001 From: spalger Date: Fri, 18 Sep 2015 17:10:14 -0700 Subject: [PATCH] [chrome/apps] fix tests broken by removal of internals.appCount --- src/ui/index.js | 1 - src/ui/public/chrome/api/__tests__/apps.js | 25 ++++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/ui/index.js b/src/ui/index.js index 82edc47c7ea9..bd06b9631839 100644 --- a/src/ui/index.js +++ b/src/ui/index.js @@ -59,7 +59,6 @@ module.exports = async (kbnServer, server, config) => { server.decorate('reply', 'renderApp', function (app) { let payload = { app: app, - appCount: uiExports.apps.size, nav: uiExports.apps, version: kbnServer.version, buildNum: config.get('pkg.buildNum'), diff --git a/src/ui/public/chrome/api/__tests__/apps.js b/src/ui/public/chrome/api/__tests__/apps.js index 57fc8ed4558d..ddb53ada7186 100644 --- a/src/ui/public/chrome/api/__tests__/apps.js +++ b/src/ui/public/chrome/api/__tests__/apps.js @@ -8,13 +8,13 @@ describe('Chrome API :: apps', function () { describe('defaults to false if there are less than two apps', function () { it('appCount = 0', function () { const chrome = {}; - setup(chrome, { appCount: 0 }); + setup(chrome, { nav: [] }); expect(chrome.getShowAppsLink()).to.equal(false); }); it('appCount = 1', function () { const chrome = {}; - setup(chrome, { appCount: 1 }); + setup(chrome, { nav: [ { url: '/' } ] }); expect(chrome.getShowAppsLink()).to.equal(false); }); }); @@ -22,26 +22,26 @@ describe('Chrome API :: apps', function () { describe('defaults to true if there are two or more apps', function () { it('appCount = 2', function () { const chrome = {}; - setup(chrome, { appCount: 2 }); + setup(chrome, { nav: [ { url: '/' }, { url: '/2' } ] }); expect(chrome.getShowAppsLink()).to.equal(true); }); it('appCount = 3', function () { const chrome = {}; - setup(chrome, { appCount: 3 }); + setup(chrome, { nav: [ { url: '/' }, { url: '/2' }, { url: '/3' } ] }); expect(chrome.getShowAppsLink()).to.equal(true); }); }); it('is chainable', function () { const chrome = {}; - setup(chrome, { appCount: 1 }); + setup(chrome, { nav: [ { url: '/' } ] }); expect(chrome.setShowAppsLink(true)).to.equal(chrome); }); it('can be changed', function () { const chrome = {}; - setup(chrome, { appCount: 1 }); + setup(chrome, { nav: [ { url: '/' } ] }); expect(chrome.setShowAppsLink(true).getShowAppsLink()).to.equal(true); expect(chrome.getShowAppsLink()).to.equal(true); @@ -54,7 +54,7 @@ describe('Chrome API :: apps', function () { describe('#getApp()', function () { it('returns a clone of the current app', function () { const chrome = {}; - const app = { 1: 2 }; + const app = { url: '/' }; setup(chrome, { app }); expect(chrome.getApp()).to.eql(app); @@ -71,7 +71,7 @@ describe('Chrome API :: apps', function () { describe('#getAppTitle()', function () { it('returns the title property of the current app', function () { const chrome = {}; - const app = { title: 'foo' }; + const app = { url: '/', title: 'foo' }; setup(chrome, { app }); expect(chrome.getAppTitle()).to.eql('foo'); }); @@ -84,11 +84,14 @@ describe('Chrome API :: apps', function () { }); describe('#getAppUrl()', function () { - it('returns the url property of the current app', function () { + it('returns the resolved url of the current app', function () { const chrome = {}; - const app = { url: 'foo' }; + const app = { url: '/foo' }; setup(chrome, { app }); - expect(chrome.getAppUrl()).to.eql('foo'); + + const a = document.createElement('a'); + a.setAttribute('href', app.url); + expect(chrome.getAppUrl()).to.equal(a.href); }); it('returns undefined if no active app', function () {