From 535711008fe3daf39b0ba2e70d092c4b86e9bb8d Mon Sep 17 00:00:00 2001 From: spalger Date: Thu, 12 Jul 2018 15:00:01 -0700 Subject: [PATCH] restore app_entry_template tests --- .../__tests__/app_entry_template.js | 49 +++++++++++++++++++ src/ui/ui_bundles/ui_bundles_controller.js | 4 +- 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 src/ui/ui_bundles/__tests__/app_entry_template.js diff --git a/src/ui/ui_bundles/__tests__/app_entry_template.js b/src/ui/ui_bundles/__tests__/app_entry_template.js new file mode 100644 index 000000000000..79b57955ebd6 --- /dev/null +++ b/src/ui/ui_bundles/__tests__/app_entry_template.js @@ -0,0 +1,49 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import sinon from 'sinon'; +import expect from 'expect.js'; + +import { appEntryTemplate } from '../app_entry_template'; + +function createMockBundle() { + return { + getContext: sinon.stub().returns(''), + getRequires: sinon.stub().returns([]) + }; +} + +describe('ui bundles / appEntryTemplate', () => { + it('embeds bundle.getContext() result', () => { + const bundle = createMockBundle(); + bundle.getContext.returns('foo bar baz'); + expect(appEntryTemplate(bundle)).to.contain('foo bar baz'); + }); + + it('joins requires into list', () => { + const bundle = createMockBundle(); + const requires = [ + 'foo', + 'bar', + 'baz' + ]; + bundle.getRequires.returns(requires); + expect(appEntryTemplate(bundle)).to.contain(requires.join('\n ')); + }); +}); diff --git a/src/ui/ui_bundles/ui_bundles_controller.js b/src/ui/ui_bundles/ui_bundles_controller.js index 0a890393ee78..887e5f028899 100644 --- a/src/ui/ui_bundles/ui_bundles_controller.js +++ b/src/ui/ui_bundles/ui_bundles_controller.js @@ -27,7 +27,7 @@ import { makeRe } from 'minimatch'; import mkdirp from 'mkdirp'; import { UiBundle } from './ui_bundle'; -import { newPlatformEntryTemplate } from './new_platform_entry_template'; +import { appEntryTemplate } from './app_entry_template'; const mkdirpAsync = promisify(mkdirp); @@ -84,7 +84,7 @@ export class UiBundlesController { this.add({ id: uiApp.getId(), modules: [uiApp.getMainModuleId()], - template: newPlatformEntryTemplate, + template: appEntryTemplate, }); } }